pgindent run for 8.2.
authorBruce Momjian
Wed, 4 Oct 2006 00:30:14 +0000 (00:30 +0000)
committerBruce Momjian
Wed, 4 Oct 2006 00:30:14 +0000 (00:30 +0000)
522 files changed:
contrib/adminpack/adminpack.c
contrib/cube/cube.c
contrib/dblink/dblink.c
contrib/hstore/hstore.h
contrib/hstore/hstore_gist.c
contrib/hstore/hstore_io.c
contrib/hstore/hstore_op.c
contrib/intarray/_int.h
contrib/intarray/_int_bool.c
contrib/intarray/_int_gin.c
contrib/intarray/_int_gist.c
contrib/intarray/_int_tool.c
contrib/intarray/_intbig_gist.c
contrib/isn/EAN13.h
contrib/isn/ISBN.h
contrib/isn/ISMN.h
contrib/isn/ISSN.h
contrib/isn/UPC.h
contrib/isn/isn.c
contrib/ltree/_ltree_gist.c
contrib/ltree/lquery_op.c
contrib/ltree/ltree.h
contrib/ltree/ltree_gist.c
contrib/ltree/ltree_op.c
contrib/pg_buffercache/pg_buffercache_pages.c
contrib/pg_freespacemap/pg_freespacemap.c
contrib/pg_trgm/trgm_gist.c
contrib/pgbench/pgbench.c
contrib/pgcrypto/crypt-gensalt.c
contrib/pgcrypto/crypt-md5.c
contrib/pgcrypto/fortuna.c
contrib/pgcrypto/imath.c
contrib/pgcrypto/imath.h
contrib/pgcrypto/internal-sha2.c
contrib/pgcrypto/internal.c
contrib/pgcrypto/openssl.c
contrib/pgcrypto/pgcrypto.c
contrib/pgcrypto/pgp-mpi-internal.c
contrib/pgcrypto/sha2.c
contrib/pgrowlocks/pgrowlocks.c
contrib/pgstattuple/pgstattuple.c
contrib/sslinfo/sslinfo.c
contrib/tablefunc/tablefunc.c
contrib/tsearch2/common.c
contrib/tsearch2/common.h
contrib/tsearch2/dict.c
contrib/tsearch2/dict.h
contrib/tsearch2/dict_thesaurus.c
contrib/tsearch2/ginidx.c
contrib/tsearch2/gistidx.c
contrib/tsearch2/ispell/regis.c
contrib/tsearch2/ispell/regis.h
contrib/tsearch2/ispell/spell.c
contrib/tsearch2/ispell/spell.h
contrib/tsearch2/prs_dcfg.c
contrib/tsearch2/query.c
contrib/tsearch2/query.h
contrib/tsearch2/query_cleanup.h
contrib/tsearch2/query_gist.c
contrib/tsearch2/rank.c
contrib/tsearch2/snowball/russian_stem_UTF8.c
contrib/tsearch2/snowball/russian_stem_UTF8.h
contrib/tsearch2/stopword.c
contrib/tsearch2/ts_cfg.c
contrib/tsearch2/ts_lexize.c
contrib/tsearch2/ts_locale.c
contrib/tsearch2/ts_locale.h
contrib/tsearch2/ts_stat.c
contrib/tsearch2/tsvector.c
contrib/tsearch2/tsvector.h
contrib/tsearch2/wordparser/parser.c
contrib/tsearch2/wparser.c
contrib/xml2/xpath.c
src/backend/access/common/heaptuple.c
src/backend/access/common/printtup.c
src/backend/access/common/reloptions.c
src/backend/access/gin/ginarrayproc.c
src/backend/access/gin/ginbtree.c
src/backend/access/gin/ginbulk.c
src/backend/access/gin/gindatapage.c
src/backend/access/gin/ginentrypage.c
src/backend/access/gin/ginget.c
src/backend/access/gin/gininsert.c
src/backend/access/gin/ginscan.c
src/backend/access/gin/ginutil.c
src/backend/access/gin/ginvacuum.c
src/backend/access/gin/ginxlog.c
src/backend/access/gist/gist.c
src/backend/access/gist/gistget.c
src/backend/access/gist/gistproc.c
src/backend/access/gist/gistscan.c
src/backend/access/gist/gistsplit.c
src/backend/access/gist/gistutil.c
src/backend/access/gist/gistvacuum.c
src/backend/access/gist/gistxlog.c
src/backend/access/hash/hashfunc.c
src/backend/access/hash/hashpage.c
src/backend/access/heap/heapam.c
src/backend/access/heap/tuptoaster.c
src/backend/access/index/genam.c
src/backend/access/index/indexam.c
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtpage.c
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtsearch.c
src/backend/access/nbtree/nbtsort.c
src/backend/access/nbtree/nbtutils.c
src/backend/access/nbtree/nbtxlog.c
src/backend/access/transam/clog.c
src/backend/access/transam/multixact.c
src/backend/access/transam/slru.c
src/backend/access/transam/twophase.c
src/backend/access/transam/varsup.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogutils.c
src/backend/bootstrap/bootstrap.c
src/backend/catalog/aclchk.c
src/backend/catalog/catalog.c
src/backend/catalog/dependency.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/namespace.c
src/backend/catalog/pg_aggregate.c
src/backend/catalog/pg_depend.c
src/backend/catalog/pg_shdepend.c
src/backend/catalog/pg_type.c
src/backend/catalog/toasting.c
src/backend/commands/aggregatecmds.c
src/backend/commands/analyze.c
src/backend/commands/cluster.c
src/backend/commands/comment.c
src/backend/commands/copy.c
src/backend/commands/dbcommands.c
src/backend/commands/define.c
src/backend/commands/explain.c
src/backend/commands/functioncmds.c
src/backend/commands/indexcmds.c
src/backend/commands/opclasscmds.c
src/backend/commands/operatorcmds.c
src/backend/commands/portalcmds.c
src/backend/commands/prepare.c
src/backend/commands/proclang.c
src/backend/commands/sequence.c
src/backend/commands/tablecmds.c
src/backend/commands/tablespace.c
src/backend/commands/trigger.c
src/backend/commands/typecmds.c
src/backend/commands/user.c
src/backend/commands/vacuum.c
src/backend/commands/vacuumlazy.c
src/backend/commands/variable.c
src/backend/commands/view.c
src/backend/executor/execMain.c
src/backend/executor/execProcnode.c
src/backend/executor/execQual.c
src/backend/executor/execTuples.c
src/backend/executor/execUtils.c
src/backend/executor/functions.c
src/backend/executor/nodeAgg.c
src/backend/executor/nodeAppend.c
src/backend/executor/nodeBitmapHeapscan.c
src/backend/executor/nodeBitmapIndexscan.c
src/backend/executor/nodeHashjoin.c
src/backend/executor/nodeIndexscan.c
src/backend/executor/nodeMaterial.c
src/backend/executor/nodeMergejoin.c
src/backend/executor/nodeNestloop.c
src/backend/executor/nodeSeqscan.c
src/backend/executor/nodeSort.c
src/backend/executor/nodeSubplan.c
src/backend/executor/nodeSubqueryscan.c
src/backend/executor/nodeTidscan.c
src/backend/executor/nodeValuesscan.c
src/backend/executor/spi.c
src/backend/libpq/auth.c
src/backend/libpq/be-secure.c
src/backend/libpq/hba.c
src/backend/libpq/pqcomm.c
src/backend/main/main.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/makefuncs.c
src/backend/nodes/params.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/clausesel.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/path/orindxpath.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/path/tidpath.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planagg.c
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/prep/prepjointree.c
src/backend/optimizer/prep/prepqual.c
src/backend/optimizer/prep/preptlist.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/plancat.c
src/backend/optimizer/util/predtest.c
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/restrictinfo.c
src/backend/parser/analyze.c
src/backend/parser/parse_clause.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_expr.c
src/backend/parser/parse_func.c
src/backend/parser/parse_node.c
src/backend/parser/parse_oper.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/backend/parser/parse_type.c
src/backend/parser/parser.c
src/backend/port/win32/socket.c
src/backend/port/win32/timer.c
src/backend/port/win32_sema.c
src/backend/postmaster/autovacuum.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/pgstat.c
src/backend/postmaster/postmaster.c
src/backend/rewrite/rewriteDefine.c
src/backend/rewrite/rewriteHandler.c
src/backend/rewrite/rewriteManip.c
src/backend/rewrite/rewriteRemove.c
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/freelist.c
src/backend/storage/file/fd.c
src/backend/storage/freespace/freespace.c
src/backend/storage/ipc/ipci.c
src/backend/storage/ipc/procarray.c
src/backend/storage/ipc/shmem.c
src/backend/storage/lmgr/lmgr.c
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/lwlock.c
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/s_lock.c
src/backend/storage/page/itemptr.c
src/backend/storage/smgr/md.c
src/backend/storage/smgr/smgr.c
src/backend/tcop/fastpath.c
src/backend/tcop/postgres.c
src/backend/tcop/pquery.c
src/backend/tcop/utility.c
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/domains.c
src/backend/utils/adt/float.c
src/backend/utils/adt/formatting.c
src/backend/utils/adt/int.c
src/backend/utils/adt/int8.c
src/backend/utils/adt/like.c
src/backend/utils/adt/lockfuncs.c
src/backend/utils/adt/misc.c
src/backend/utils/adt/network.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/oid.c
src/backend/utils/adt/pg_locale.c
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/adt/regexp.c
src/backend/utils/adt/ri_triggers.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/tid.c
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/varchar.c
src/backend/utils/adt/varlena.c
src/backend/utils/cache/catcache.c
src/backend/utils/cache/inval.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/backend/utils/cache/typcache.c
src/backend/utils/fmgr/dfmgr.c
src/backend/utils/fmgr/fmgr.c
src/backend/utils/hash/dynahash.c
src/backend/utils/hash/hashfn.c
src/backend/utils/init/globals.c
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/backend/utils/mb/conv.c
src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c
src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c
src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c
src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c
src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c
src/backend/utils/mb/mbutils.c
src/backend/utils/mb/wchar.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/ps_status.c
src/backend/utils/misc/tzparser.c
src/backend/utils/mmgr/aset.c
src/backend/utils/mmgr/portalmem.c
src/backend/utils/sort/logtape.c
src/backend/utils/sort/tuplesort.c
src/backend/utils/sort/tuplestore.c
src/backend/utils/time/tqual.c
src/bin/initdb/initdb.c
src/bin/pg_config/pg_config.c
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_dump/dumputils.c
src/bin/pg_dump/dumputils.h
src/bin/pg_dump/pg_backup.h
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.h
src/bin/pg_dump/pg_backup_custom.c
src/bin/pg_dump/pg_backup_db.c
src/bin/pg_dump/pg_backup_tar.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dumpall.c
src/bin/pg_resetxlog/pg_resetxlog.c
src/bin/psql/command.c
src/bin/psql/command.h
src/bin/psql/common.c
src/bin/psql/common.h
src/bin/psql/copy.c
src/bin/psql/describe.c
src/bin/psql/input.c
src/bin/psql/mainloop.c
src/bin/psql/mbprint.c
src/bin/psql/mbprint.h
src/bin/psql/print.c
src/bin/psql/settings.h
src/bin/psql/startup.c
src/bin/psql/stringutils.c
src/bin/psql/tab-complete.c
src/bin/psql/variables.h
src/bin/scripts/common.c
src/bin/scripts/createuser.c
src/include/access/gin.h
src/include/access/gist.h
src/include/access/gist_private.h
src/include/access/heapam.h
src/include/access/hio.h
src/include/access/htup.h
src/include/access/nbtree.h
src/include/access/reloptions.h
src/include/access/relscan.h
src/include/access/skey.h
src/include/access/slru.h
src/include/access/tupdesc.h
src/include/access/xlog_internal.h
src/include/bootstrap/bootstrap.h
src/include/c.h
src/include/catalog/pg_aggregate.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_attribute.h
src/include/catalog/pg_class.h
src/include/catalog/pg_control.h
src/include/catalog/pg_index.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_shdescription.h
src/include/catalog/pg_type.h
src/include/catalog/toasting.h
src/include/commands/comment.h
src/include/commands/defrem.h
src/include/commands/explain.h
src/include/commands/prepare.h
src/include/commands/tablecmds.h
src/include/commands/user.h
src/include/executor/executor.h
src/include/executor/nodeIndexscan.h
src/include/executor/nodeValuesscan.h
src/include/executor/spi.h
src/include/executor/tuptable.h
src/include/fmgr.h
src/include/funcapi.h
src/include/getaddrinfo.h
src/include/libpq/hba.h
src/include/libpq/libpq-be.h
src/include/mb/pg_wchar.h
src/include/nodes/params.h
src/include/nodes/parsenodes.h
src/include/nodes/primnodes.h
src/include/nodes/relation.h
src/include/optimizer/cost.h
src/include/optimizer/pathnode.h
src/include/optimizer/plancat.h
src/include/optimizer/prep.h
src/include/optimizer/restrictinfo.h
src/include/parser/analyze.h
src/include/parser/parse_coerce.h
src/include/parser/parse_func.h
src/include/parser/parse_node.h
src/include/parser/parse_oper.h
src/include/parser/parse_relation.h
src/include/pg_trace.h
src/include/pgstat.h
src/include/port.h
src/include/port/darwin.h
src/include/port/linux.h
src/include/port/netbsd.h
src/include/port/win32.h
src/include/port/win32/dlfcn.h
src/include/port/win32/grp.h
src/include/port/win32/netdb.h
src/include/port/win32/sys/socket.h
src/include/port/win32_msvc/dirent.h
src/include/port/win32_msvc/sys/file.h
src/include/port/win32_msvc/sys/param.h
src/include/port/win32_msvc/sys/time.h
src/include/port/win32_msvc/unistd.h
src/include/port/win32_msvc/utime.h
src/include/storage/freespace.h
src/include/storage/lock.h
src/include/storage/pg_sema.h
src/include/storage/pg_shmem.h
src/include/storage/proc.h
src/include/tcop/tcopprot.h
src/include/utils/acl.h
src/include/utils/catcache.h
src/include/utils/hsearch.h
src/include/utils/lsyscache.h
src/include/utils/portal.h
src/include/utils/rel.h
src/include/utils/resowner.h
src/include/utils/selfuncs.h
src/include/utils/timestamp.h
src/include/utils/tqual.h
src/include/utils/tuplesort.h
src/include/utils/tuplestore.h
src/include/utils/typcache.h
src/include/utils/tzparser.h
src/interfaces/ecpg/compatlib/informix.c
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/ecpglib/descriptor.c
src/interfaces/ecpg/ecpglib/error.c
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/extern.h
src/interfaces/ecpg/ecpglib/misc.c
src/interfaces/ecpg/ecpglib/prepare.c
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/include/pgtypes_date.h
src/interfaces/ecpg/include/pgtypes_interval.h
src/interfaces/ecpg/pgtypeslib/datetime.c
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/numeric.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/preproc/output.c
src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c
src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c
src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c
src/interfaces/ecpg/test/expected/compat_informix-rnull.c
src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c
src/interfaces/ecpg/test/expected/connect-test1.c
src/interfaces/ecpg/test/expected/connect-test2.c
src/interfaces/ecpg/test/expected/connect-test3.c
src/interfaces/ecpg/test/expected/connect-test4.c
src/interfaces/ecpg/test/expected/connect-test5.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test.c
src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c
src/interfaces/ecpg/test/expected/pgtypeslib-num_test.c
src/interfaces/ecpg/test/expected/pgtypeslib-num_test2.c
src/interfaces/ecpg/test/expected/preproc-comment.c
src/interfaces/ecpg/test/expected/preproc-define.c
src/interfaces/ecpg/test/expected/preproc-init.c
src/interfaces/ecpg/test/expected/preproc-type.c
src/interfaces/ecpg/test/expected/preproc-variable.c
src/interfaces/ecpg/test/expected/preproc-whenever.c
src/interfaces/ecpg/test/expected/sql-array.c
src/interfaces/ecpg/test/expected/sql-binary.c
src/interfaces/ecpg/test/expected/sql-code100.c
src/interfaces/ecpg/test/expected/sql-copystdout.c
src/interfaces/ecpg/test/expected/sql-define.c
src/interfaces/ecpg/test/expected/sql-desc.c
src/interfaces/ecpg/test/expected/sql-dynalloc.c
src/interfaces/ecpg/test/expected/sql-dynalloc2.c
src/interfaces/ecpg/test/expected/sql-dyntest.c
src/interfaces/ecpg/test/expected/sql-execute.c
src/interfaces/ecpg/test/expected/sql-fetch.c
src/interfaces/ecpg/test/expected/sql-func.c
src/interfaces/ecpg/test/expected/sql-indicators.c
src/interfaces/ecpg/test/expected/sql-quote.c
src/interfaces/ecpg/test/expected/sql-show.c
src/interfaces/ecpg/test/expected/sql-update.c
src/interfaces/ecpg/test/expected/thread-thread.c
src/interfaces/ecpg/test/expected/thread-thread_implicit.c
src/interfaces/libpq/fe-auth.c
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-lobj.c
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-print.c
src/interfaces/libpq/fe-protocol3.c
src/interfaces/libpq/fe-secure.c
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-int.h
src/interfaces/libpq/win32.c
src/pl/plperl/plperl.c
src/pl/plperl/plperl.h
src/pl/plpgsql/src/pl_comp.c
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/pl_handler.c
src/pl/plpgsql/src/plpgsql.h
src/pl/plpython/plpython.c
src/pl/tcl/pltcl.c
src/port/dirent.c
src/port/getaddrinfo.c
src/port/isinf.c
src/port/open.c
src/port/path.c
src/port/pgsleep.c
src/port/qsort_arg.c
src/port/snprintf.c
src/port/sprompt.c
src/port/strlcpy.c
src/port/strtol.c
src/test/regress/pg_regress.c
src/timezone/pgtz.c

index 3213420ba15dce786c5dd57dba6fe176020abf0d..dc756e4303f461ae532c699abffcef58dde6258c 100644 (file)
@@ -4,11 +4,11 @@
  *
  *
  * Copyright (c) 2002 - 2006, PostgreSQL Global Development Group
- * 
+ *
  * Author: Andreas Pflug 
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/contrib/adminpack/adminpack.c,v 1.3 2006/07/11 16:35:30 momjian Exp $
+ *   $PostgreSQL: pgsql/contrib/adminpack/adminpack.c,v 1.4 2006/10/04 00:29:44 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,7 +35,6 @@
 #ifdef unlink
 #undef unlink
 #endif
-
 #endif
 
 extern DLLIMPORT char *DataDir;
@@ -44,20 +43,20 @@ extern DLLIMPORT char *Log_filename;
 
 PG_MODULE_MAGIC;
 
-Datum pg_file_write(PG_FUNCTION_ARGS);
-Datum pg_file_rename(PG_FUNCTION_ARGS);
-Datum pg_file_unlink(PG_FUNCTION_ARGS);
-Datum pg_logdir_ls(PG_FUNCTION_ARGS);
+Datum      pg_file_write(PG_FUNCTION_ARGS);
+Datum      pg_file_rename(PG_FUNCTION_ARGS);
+Datum      pg_file_unlink(PG_FUNCTION_ARGS);
+Datum      pg_logdir_ls(PG_FUNCTION_ARGS);
 
 PG_FUNCTION_INFO_V1(pg_file_write);
 PG_FUNCTION_INFO_V1(pg_file_rename);
 PG_FUNCTION_INFO_V1(pg_file_unlink);
 PG_FUNCTION_INFO_V1(pg_logdir_ls);
 
-typedef struct 
+typedef struct
 {
-   char *location;
-   DIR *dirdesc;
+   char       *location;
+   DIR        *dirdesc;
 } directory_fctx;
 
 /*-----------------------
@@ -65,30 +64,31 @@ typedef struct
  */
 
 /*
- * Return an absolute path. Argument may be absolute or 
+ * Return an absolute path. Argument may be absolute or
  * relative to the DataDir.
  */
-static char *absClusterPath(text *arg, bool logAllowed)
+static char *
+absClusterPath(text *arg, bool logAllowed)
 {
-   char *filename;
-   int len=VARSIZE(arg) - VARHDRSZ;
-   int dlen = strlen(DataDir);
+   char       *filename;
+   int         len = VARSIZE(arg) - VARHDRSZ;
+   int         dlen = strlen(DataDir);
 
-   filename = palloc(len+1);
+   filename = palloc(len + 1);
    memcpy(filename, VARDATA(arg), len);
    filename[len] = 0;
 
    if (strstr(filename, "..") != NULL)
-     ereport(ERROR,
-             (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-              (errmsg("No .. allowed in filenames"))));
-   
+       ereport(ERROR,
+               (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+                (errmsg("No .. allowed in filenames"))));
+
    if (is_absolute_path(filename))
    {
-       if (logAllowed && !strncmp(filename, Log_directory, strlen(Log_directory)))
-           return filename;
+       if (logAllowed && !strncmp(filename, Log_directory, strlen(Log_directory)))
+           return filename;
        if (strncmp(filename, DataDir, dlen))
-           ereport(ERROR,
+           ereport(ERROR,
                    (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                     (errmsg("Absolute path not allowed"))));
 
@@ -96,7 +96,8 @@ static char *absClusterPath(text *arg, bool logAllowed)
    }
    else
    {
-       char *absname = palloc(dlen+len+2);
+       char       *absname = palloc(dlen + len + 2);
+
        sprintf(absname, "%s/%s", DataDir, filename);
        pfree(filename);
        return absname;
@@ -111,9 +112,9 @@ static void
 requireSuperuser(void)
 {
    if (!superuser())
-       ereport(ERROR,
+       ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                (errmsg("only superuser may access generic file functions"))));
+             (errmsg("only superuser may access generic file functions"))));
 }
 
 
@@ -122,12 +123,13 @@ requireSuperuser(void)
  * generic file handling functions
  */
 
-Datum pg_file_write(PG_FUNCTION_ARGS)
+Datum
+pg_file_write(PG_FUNCTION_ARGS)
 {
-   FILE *f;
-   char *filename;
-   text *data;
-   int64 count = 0;
+   FILE       *f;
+   char       *filename;
+   text       *data;
+   int64       count = 0;
 
    requireSuperuser();
 
@@ -136,16 +138,17 @@ Datum pg_file_write(PG_FUNCTION_ARGS)
 
    if (PG_ARGISNULL(2) || !PG_GETARG_BOOL(2))
    {
-       struct stat fst;
+       struct stat fst;
+
        if (stat(filename, &fst) >= 0)
-           ereport(ERROR,
+           ereport(ERROR,
                    (ERRCODE_DUPLICATE_FILE,
                     errmsg("file %s exists", filename)));
 
-       f = fopen(filename, "wb");
+       f = fopen(filename, "wb");
    }
    else
-       f = fopen(filename, "ab");
+       f = fopen(filename, "ab");
 
    if (!f)
    {
@@ -159,7 +162,7 @@ Datum pg_file_write(PG_FUNCTION_ARGS)
        count = fwrite(VARDATA(data), 1, VARSIZE(data) - VARHDRSZ, f);
 
        if (count != VARSIZE(data) - VARHDRSZ)
-           ereport(ERROR,
+           ereport(ERROR,
                    (errcode_for_file_access(),
                     errmsg("error writing file %s: %m", filename)));
    }
@@ -169,22 +172,25 @@ Datum pg_file_write(PG_FUNCTION_ARGS)
 }
 
 
-Datum pg_file_rename(PG_FUNCTION_ARGS)
+Datum
+pg_file_rename(PG_FUNCTION_ARGS)
 {
-    char *fn1, *fn2, *fn3;
-   int rc;
+   char       *fn1,
+              *fn2,
+              *fn3;
+   int         rc;
 
    requireSuperuser();
 
    if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
        PG_RETURN_NULL();
 
-   fn1=absClusterPath(PG_GETARG_TEXT_P(0), false);
-   fn2=absClusterPath(PG_GETARG_TEXT_P(1), false);
+   fn1 = absClusterPath(PG_GETARG_TEXT_P(0), false);
+   fn2 = absClusterPath(PG_GETARG_TEXT_P(1), false);
    if (PG_ARGISNULL(2))
-       fn3=0;
+       fn3 = 0;
    else
-       fn3=absClusterPath(PG_GETARG_TEXT_P(2), false);
+       fn3 = absClusterPath(PG_GETARG_TEXT_P(2), false);
 
    if (access(fn1, W_OK) < 0)
    {
@@ -192,7 +198,7 @@ Datum pg_file_rename(PG_FUNCTION_ARGS)
                (errcode_for_file_access(),
                 errmsg("file %s not accessible: %m", fn1)));
 
-       PG_RETURN_BOOL(false);
+       PG_RETURN_BOOL(false);
    }
 
    if (fn3 && access(fn2, W_OK) < 0)
@@ -201,7 +207,7 @@ Datum pg_file_rename(PG_FUNCTION_ARGS)
                (errcode_for_file_access(),
                 errmsg("file %s not accessible: %m", fn2)));
 
-       PG_RETURN_BOOL(false);
+       PG_RETURN_BOOL(false);
    }
 
 
@@ -212,10 +218,10 @@ Datum pg_file_rename(PG_FUNCTION_ARGS)
                (ERRCODE_DUPLICATE_FILE,
                 errmsg("cannot rename to target file %s", fn3 ? fn3 : fn2)));
    }
-   
+
    if (fn3)
    {
-       if (rename(fn2, fn3) != 0)
+       if (rename(fn2, fn3) != 0)
        {
            ereport(ERROR,
                    (errcode_for_file_access(),
@@ -231,7 +237,7 @@ Datum pg_file_rename(PG_FUNCTION_ARGS)
            {
                ereport(ERROR,
                        (errcode_for_file_access(),
-                        errmsg("could not rename %s back to %s: %m", fn3, fn2)));
+                   errmsg("could not rename %s back to %s: %m", fn3, fn2)));
            }
            else
            {
@@ -244,9 +250,9 @@ Datum pg_file_rename(PG_FUNCTION_ARGS)
    }
    else if (rename(fn1, fn2) != 0)
    {
-           ereport(WARNING,
-                   (errcode_for_file_access(),
-                    errmsg("renaming %s to %s %m", fn1, fn2)));
+       ereport(WARNING,
+               (errcode_for_file_access(),
+                errmsg("renaming %s to %s %m", fn1, fn2)));
        ereport(ERROR,
                (errcode_for_file_access(),
                 errmsg("could not rename %s to %s: %m", fn1, fn2)));
@@ -256,20 +262,21 @@ Datum pg_file_rename(PG_FUNCTION_ARGS)
 }
 
 
-Datum pg_file_unlink(PG_FUNCTION_ARGS)
+Datum
+pg_file_unlink(PG_FUNCTION_ARGS)
 {
-    char *filename;
+   char       *filename;
 
    requireSuperuser();
 
-    filename = absClusterPath(PG_GETARG_TEXT_P(0), false);
+   filename = absClusterPath(PG_GETARG_TEXT_P(0), false);
 
    if (access(filename, W_OK) < 0)
    {
-       if (errno == ENOENT)
-           PG_RETURN_BOOL(false);
+       if (errno == ENOENT)
+           PG_RETURN_BOOL(false);
        else
-           ereport(ERROR,
+           ereport(ERROR,
                    (errcode_for_file_access(),
                     errmsg("file %s not accessible: %m", filename)));
 
@@ -287,17 +294,18 @@ Datum pg_file_unlink(PG_FUNCTION_ARGS)
 }
 
 
-Datum pg_logdir_ls(PG_FUNCTION_ARGS)
+Datum
+pg_logdir_ls(PG_FUNCTION_ARGS)
 {
    FuncCallContext *funcctx;
    struct dirent *de;
    directory_fctx *fctx;
 
-   if (!superuser()) 
+   if (!superuser())
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
                 (errmsg("only superuser can list the log directory"))));
-   
+
    if (memcmp(Log_filename, "postgresql-%Y-%m-%d_%H%M%S.log", 30) != 0)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -306,17 +314,17 @@ Datum pg_logdir_ls(PG_FUNCTION_ARGS)
    if (SRF_IS_FIRSTCALL())
    {
        MemoryContext oldcontext;
-       TupleDesc tupdesc;
+       TupleDesc   tupdesc;
 
-       funcctx=SRF_FIRSTCALL_INIT();
+       funcctx = SRF_FIRSTCALL_INIT();
        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
        fctx = palloc(sizeof(directory_fctx));
        if (is_absolute_path(Log_directory))
-           fctx->location = Log_directory;
+           fctx->location = Log_directory;
        else
        {
-           fctx->location = palloc(strlen(DataDir) + strlen(Log_directory) +2);
+           fctx->location = palloc(strlen(DataDir) + strlen(Log_directory) + 2);
            sprintf(fctx->location, "%s/%s", DataDir, Log_directory);
        }
        tupdesc = CreateTemplateTupleDesc(2, false);
@@ -326,11 +334,11 @@ Datum pg_logdir_ls(PG_FUNCTION_ARGS)
                           TEXTOID, -1, 0);
 
        funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
-       
+
        fctx->dirdesc = AllocateDir(fctx->location);
 
        if (!fctx->dirdesc)
-           ereport(ERROR,
+           ereport(ERROR,
                    (errcode_for_file_access(),
                     errmsg("%s is not browsable: %m", fctx->location)));
 
@@ -338,47 +346,47 @@ Datum pg_logdir_ls(PG_FUNCTION_ARGS)
        MemoryContextSwitchTo(oldcontext);
    }
 
-   funcctx=SRF_PERCALL_SETUP();
-   fctx = (directory_fctx*) funcctx->user_fctx;
+   funcctx = SRF_PERCALL_SETUP();
+   fctx = (directory_fctx *) funcctx->user_fctx;
 
-   if (!fctx->dirdesc)  /* not a readable directory  */
+   if (!fctx->dirdesc)         /* not a readable directory  */
        SRF_RETURN_DONE(funcctx);
 
    while ((de = readdir(fctx->dirdesc)) != NULL)
    {
-       char *values[2];
-       HeapTuple tuple;
-            
-       char        *field[MAXDATEFIELDS];
+       char       *values[2];
+       HeapTuple   tuple;
+
+       char       *field[MAXDATEFIELDS];
        char        lowstr[MAXDATELEN + 1];
-       int     dtype;
-       int     nf, ftype[MAXDATEFIELDS];
+       int         dtype;
+       int         nf,
+                   ftype[MAXDATEFIELDS];
        fsec_t      fsec;
-       int     tz = 0;
-       struct      pg_tm date;
+       int         tz = 0;
+       struct pg_tm date;
 
        /*
-        * Default format:
-        *        postgresql-YYYY-MM-DD_HHMMSS.log
+        * Default format: postgresql-YYYY-MM-DD_HHMMSS.log
         */
        if (strlen(de->d_name) != 32
-           || memcmp(de->d_name, "postgresql-", 11)
+           || memcmp(de->d_name, "postgresql-", 11)
            || de->d_name[21] != '_'
            || strcmp(de->d_name + 28, ".log"))
-             continue;
+           continue;
 
        values[1] = palloc(strlen(fctx->location) + strlen(de->d_name) + 2);
        sprintf(values[1], "%s/%s", fctx->location, de->d_name);
 
-       values[0] = de->d_name + 11;       /* timestamp */
+       values[0] = de->d_name + 11;    /* timestamp */
        values[0][17] = 0;
 
-                    /* parse and decode expected timestamp */
+       /* parse and decode expected timestamp */
        if (ParseDateTime(values[0], lowstr, MAXDATELEN, field, ftype, MAXDATEFIELDS, &nf))
-           continue;
+           continue;
 
        if (DecodeDateTime(field, ftype, nf, &dtype, &date, &fsec, &tz))
-           continue;
+           continue;
 
        /* Seems the format fits the expected format; feed it into the tuple */
 
index 16ba5340fbfb34e4c8483f692dd49b0d3055ceed..9d3b46648efa99443874e4ace81cd749ab568372 100644 (file)
@@ -1,5 +1,5 @@
 /******************************************************************************
-  $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.29 2006/09/10 17:36:50 tgl Exp $
+  $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.30 2006/10/04 00:29:44 momjian Exp $
 
   This file contains routines that can be bound to a Postgres backend and
   called by the backend in the process of processing queries.  The calling
@@ -159,7 +159,7 @@ Datum
 cube_in(PG_FUNCTION_ARGS)
 {
    void       *result;
-   char        *str;
+   char       *str;
 
    str = PG_GETARG_CSTRING(0);
 
@@ -170,7 +170,7 @@ cube_in(PG_FUNCTION_ARGS)
 
    cube_scanner_finish();
 
-   PG_RETURN_POINTER (result);
+   PG_RETURN_POINTER(result);
 }
 
 /* Allow conversion from text to cube to allow input of computed strings */
@@ -178,11 +178,11 @@ cube_in(PG_FUNCTION_ARGS)
 Datum
 cube(PG_FUNCTION_ARGS)
 {
-   char    *cstring;
+   char       *cstring;
 
    cstring = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0))));
 
-   PG_RETURN_DATUM (DirectFunctionCall1 (cube_in, PointerGetDatum(cstring)));
+   PG_RETURN_DATUM(DirectFunctionCall1(cube_in, PointerGetDatum(cstring)));
 }
 
 
@@ -192,12 +192,14 @@ cube(PG_FUNCTION_ARGS)
 Datum
 cube_a_f8_f8(PG_FUNCTION_ARGS)
 {
-   int     i;
-   int     dim;
-   int     size;
-   NDBOX   *result;
-   ArrayType   *ur, *ll;
-   double  *dur, *dll;
+   int         i;
+   int         dim;
+   int         size;
+   NDBOX      *result;
+   ArrayType  *ur,
+              *ll;
+   double     *dur,
+              *dll;
 
    ur = (ArrayType *) PG_GETARG_VARLENA_P(0);
    ll = (ArrayType *) PG_GETARG_VARLENA_P(1);
@@ -205,31 +207,31 @@ cube_a_f8_f8(PG_FUNCTION_ARGS)
    if (ARR_HASNULL(ur) || ARR_HASNULL(ll))
    {
        ereport(ERROR,
-           (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-           errmsg("Cannot work with NULL arrays")));
+               (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
+                errmsg("Cannot work with NULL arrays")));
    }
 
    dim = ARRNELEMS(ur);
    if (ARRNELEMS(ll) != dim)
    {
        ereport(ERROR,
-           (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-           errmsg("UR and LL arrays must be of same length")));
+               (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
+                errmsg("UR and LL arrays must be of same length")));
    }
 
    dur = ARRPTR(ur);
    dll = ARRPTR(ll);
 
    size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim;
-   result = (NDBOX *) palloc (size);
-   memset (result, 0, size);
+   result = (NDBOX *) palloc(size);
+   memset(result, 0, size);
    result->size = size;
    result->dim = dim;
 
-   for (i=0; i<dim; i++)
+   for (i = 0; i < dim; i++)
    {
        result->x[i] = dur[i];
-       result->x[i+dim] = dll[i];
+       result->x[i + dim] = dll[i];
    }
 
    PG_RETURN_POINTER(result);
@@ -241,20 +243,20 @@ cube_a_f8_f8(PG_FUNCTION_ARGS)
 Datum
 cube_a_f8(PG_FUNCTION_ARGS)
 {
-   int     i;
-   int     dim;
-   int     size;
-   NDBOX   *result;
-   ArrayType   *ur;
-   double  *dur;
+   int         i;
+   int         dim;
+   int         size;
+   NDBOX      *result;
+   ArrayType  *ur;
+   double     *dur;
 
    ur = (ArrayType *) PG_GETARG_VARLENA_P(0);
 
    if (ARR_HASNULL(ur))
    {
        ereport(ERROR,
-           (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-           errmsg("Cannot work with NULL arrays")));
+               (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
+                errmsg("Cannot work with NULL arrays")));
    }
 
    dim = ARRNELEMS(ur);
@@ -262,15 +264,15 @@ cube_a_f8(PG_FUNCTION_ARGS)
    dur = ARRPTR(ur);
 
    size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim;
-   result = (NDBOX *) palloc (size);
-   memset (result, 0, size);
+   result = (NDBOX *) palloc(size);
+   memset(result, 0, size);
    result->size = size;
    result->dim = dim;
 
-   for (i=0; i<dim; i++)
+   for (i = 0; i < dim; i++)
    {
        result->x[i] = dur[i];
-       result->x[i+dim] = dur[i];
+       result->x[i + dim] = dur[i];
    }
 
    PG_RETURN_POINTER(result);
@@ -279,10 +281,13 @@ cube_a_f8(PG_FUNCTION_ARGS)
 Datum
 cube_subset(PG_FUNCTION_ARGS)
 {
-   NDBOX       *c, *result;
-   ArrayType   *idx;
-   int          size, dim, i;
-   int         *dx;
+   NDBOX      *c,
+              *result;
+   ArrayType  *idx;
+   int         size,
+               dim,
+               i;
+   int        *dx;
 
    c = (NDBOX *) PG_GETARG_POINTER(0);
    idx = (ArrayType *) PG_GETARG_VARLENA_P(1);
@@ -290,30 +295,30 @@ cube_subset(PG_FUNCTION_ARGS)
    if (ARR_HASNULL(idx))
    {
        ereport(ERROR,
-           (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-           errmsg("Cannot work with NULL arrays")));
+               (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
+                errmsg("Cannot work with NULL arrays")));
    }
 
-   dx = (int4 *) ARR_DATA_PTR (idx);
+   dx = (int4 *) ARR_DATA_PTR(idx);
 
    dim = ARRNELEMS(idx);
    size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim;
-   result = (NDBOX *) palloc (size);
-   memset (result, 0, size);
+   result = (NDBOX *) palloc(size);
+   memset(result, 0, size);
    result->size = size;
    result->dim = dim;
 
-   for (i=0; i<dim; i++)
+   for (i = 0; i < dim; i++)
    {
        if ((dx[i] <= 0) || (dx[i] > c->dim))
        {
-           pfree (result);
+           pfree(result);
            ereport(ERROR,
-               (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
-               errmsg("Index out of bounds")));
+                   (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
+                    errmsg("Index out of bounds")));
        }
-       result->x[i] = c->x[dx[i]-1];
-       result->x[i+dim] = c->x[dx[i]+c->dim-1];
+       result->x[i] = c->x[dx[i] - 1];
+       result->x[i + dim] = c->x[dx[i] + c->dim - 1];
    }
 
    PG_RETURN_POINTER(result);
@@ -327,11 +332,11 @@ cube_out(PG_FUNCTION_ARGS)
    int         dim;
    int         i;
    int         ndig;
-   NDBOX       *cube;
+   NDBOX      *cube;
 
    initStringInfo(&buf);
 
-   cube = (NDBOX *) PG_GETARG_POINTER (0);
+   cube = (NDBOX *) PG_GETARG_POINTER(0);
 
    dim = cube->dim;
 
@@ -369,7 +374,7 @@ cube_out(PG_FUNCTION_ARGS)
        appendStringInfoChar(&buf, ')');
    }
 
-   PG_RETURN_CSTRING (buf.data);
+   PG_RETURN_CSTRING(buf.data);
 }
 
 
@@ -383,11 +388,11 @@ cube_out(PG_FUNCTION_ARGS)
 ** the predicate x op query == FALSE, where op is the oper
 ** corresponding to strategy in the pg_amop table.
 */
-Datum  
+Datum
 g_cube_consistent(PG_FUNCTION_ARGS)
 {
-   GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
-   NDBOX *query = (NDBOX *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1)));
+   GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
+   NDBOX      *query = (NDBOX *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1)));
    StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
 
    /*
@@ -414,7 +419,7 @@ g_cube_union(PG_FUNCTION_ARGS)
    NDBOX      *out = (NDBOX *) NULL;
    NDBOX      *tmp;
    int        *sizep;
-   GistEntryVector *entryvec;
+   GistEntryVector *entryvec;
 
    entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
    sizep = (int *) PG_GETARG_POINTER(1);
@@ -446,15 +451,15 @@ g_cube_union(PG_FUNCTION_ARGS)
 */
 
 Datum
-g_cube_compress (PG_FUNCTION_ARGS)
+g_cube_compress(PG_FUNCTION_ARGS)
 {
-    PG_RETURN_DATUM(PG_GETARG_DATUM(0));
+   PG_RETURN_DATUM(PG_GETARG_DATUM(0));
 }
 
 Datum
-g_cube_decompress (PG_FUNCTION_ARGS)
+g_cube_decompress(PG_FUNCTION_ARGS)
 {
-    PG_RETURN_DATUM(PG_GETARG_DATUM(0));
+   PG_RETURN_DATUM(PG_GETARG_DATUM(0));
 }
 
 
@@ -463,17 +468,17 @@ g_cube_decompress (PG_FUNCTION_ARGS)
 ** As in the R-tree paper, we use change in area as our penalty metric
 */
 Datum
-g_cube_penalty (PG_FUNCTION_ARGS)
+g_cube_penalty(PG_FUNCTION_ARGS)
 {
-   GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0);
-   GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
-   float     *result = (float *) PG_GETARG_POINTER(2);
+   GISTENTRY  *origentry = (GISTENTRY *) PG_GETARG_POINTER(0);
+   GISTENTRY  *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
+   float      *result = (float *) PG_GETARG_POINTER(2);
    NDBOX      *ud;
    double      tmp1,
                tmp2;
 
    ud = cube_union_v0((NDBOX *) DatumGetPointer(origentry->key),
-                   (NDBOX *) DatumGetPointer(newentry->key));
+                      (NDBOX *) DatumGetPointer(newentry->key));
    rt_cube_size(ud, &tmp1);
    rt_cube_size((NDBOX *) DatumGetPointer(origentry->key), &tmp2);
    *result = (float) (tmp1 - tmp2);
@@ -481,7 +486,7 @@ g_cube_penalty (PG_FUNCTION_ARGS)
    /*
     * fprintf(stderr, "penalty\n"); fprintf(stderr, "\t%g\n", *result);
     */
-   PG_RETURN_FLOAT8 (*result);
+   PG_RETURN_FLOAT8(*result);
 }
 
 
@@ -493,8 +498,8 @@ g_cube_penalty (PG_FUNCTION_ARGS)
 Datum
 g_cube_picksplit(PG_FUNCTION_ARGS)
 {
-   GistEntryVector *entryvec;
-   GIST_SPLITVEC   *v;
+   GistEntryVector *entryvec;
+   GIST_SPLITVEC *v;
    OffsetNumber i,
                j;
    NDBOX      *datum_alpha,
@@ -546,9 +551,9 @@ g_cube_picksplit(PG_FUNCTION_ARGS)
            /* size_waste = size_union - size_inter; */
            union_d = cube_union_v0(datum_alpha, datum_beta);
            rt_cube_size(union_d, &size_union);
-           inter_d = (NDBOX *) DatumGetPointer (DirectFunctionCall2 
-                                (cube_inter, 
-                                 entryvec->vector[i].key, entryvec->vector[j].key));
+           inter_d = (NDBOX *) DatumGetPointer(DirectFunctionCall2
+                                               (cube_inter,
+                         entryvec->vector[i].key, entryvec->vector[j].key));
            rt_cube_size(inter_d, &size_inter);
            size_waste = size_union - size_inter;
 
@@ -649,12 +654,13 @@ g_cube_picksplit(PG_FUNCTION_ARGS)
 Datum
 g_cube_same(PG_FUNCTION_ARGS)
 {
-   NDBOX   *b1, *b2;
-   bool    *result;
-   
-   b1 = (NDBOX *) PG_GETARG_POINTER (0);
-   b2 = (NDBOX *) PG_GETARG_POINTER (1);
-   result = (bool *) PG_GETARG_POINTER (2);
+   NDBOX      *b1,
+              *b2;
+   bool       *result;
+
+   b1 = (NDBOX *) PG_GETARG_POINTER(0);
+   b2 = (NDBOX *) PG_GETARG_POINTER(1);
+   result = (bool *) PG_GETARG_POINTER(2);
 
    if (cube_cmp_v0(b1, b2) == 0)
        *result = TRUE;
@@ -664,7 +670,7 @@ g_cube_same(PG_FUNCTION_ARGS)
    /*
     * fprintf(stderr, "same: %s\n", (*result ? "TRUE" : "FALSE" ));
     */
-   PG_RETURN_POINTER (result);
+   PG_RETURN_POINTER(result);
 }
 
 /*
@@ -803,14 +809,15 @@ cube_union_v0(NDBOX * a, NDBOX * b)
 }
 
 Datum
-cube_union (PG_FUNCTION_ARGS)
+cube_union(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
 
-   PG_RETURN_POINTER(cube_union_v0(a,b));
+   PG_RETURN_POINTER(cube_union_v0(a, b));
 }
 
 /* cube_inter */
@@ -818,7 +825,9 @@ Datum
 cube_inter(PG_FUNCTION_ARGS)
 {
    int         i;
-   NDBOX      *result, *a, *b;
+   NDBOX      *result,
+              *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -874,17 +883,17 @@ cube_inter(PG_FUNCTION_ARGS)
    /*
     * Is it OK to return a non-null intersection for non-overlapping boxes?
     */
-   PG_RETURN_POINTER (result);
+   PG_RETURN_POINTER(result);
 }
 
 /* cube_size */
 Datum
 cube_size(PG_FUNCTION_ARGS)
 {
-   NDBOX       *a;
+   NDBOX      *a;
    int         i,
                j;
-   double      result;
+   double      result;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
 
@@ -892,7 +901,7 @@ cube_size(PG_FUNCTION_ARGS)
    for (i = 0, j = a->dim; i < a->dim; i++, j++)
        result = result * Abs((a->x[j] - a->x[i]));
 
-   PG_RETURN_FLOAT8 (result);
+   PG_RETURN_FLOAT8(result);
 }
 
 void
@@ -994,10 +1003,11 @@ cube_cmp_v0(NDBOX * a, NDBOX * b)
    return 0;
 }
 
-Datum 
+Datum
 cube_cmp(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1009,7 +1019,8 @@ cube_cmp(PG_FUNCTION_ARGS)
 Datum
 cube_eq(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1021,7 +1032,8 @@ cube_eq(PG_FUNCTION_ARGS)
 Datum
 cube_ne(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1033,7 +1045,8 @@ cube_ne(PG_FUNCTION_ARGS)
 Datum
 cube_lt(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1045,7 +1058,8 @@ cube_lt(PG_FUNCTION_ARGS)
 Datum
 cube_gt(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1057,7 +1071,8 @@ cube_gt(PG_FUNCTION_ARGS)
 Datum
 cube_le(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1069,7 +1084,8 @@ cube_le(PG_FUNCTION_ARGS)
 Datum
 cube_ge(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1122,7 +1138,8 @@ cube_contains_v0(NDBOX * a, NDBOX * b)
 Datum
 cube_contains(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1135,12 +1152,13 @@ cube_contains(PG_FUNCTION_ARGS)
 Datum
 cube_contained(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
 
-   PG_RETURN_BOOL (cube_contains_v0(b, a));
+   PG_RETURN_BOOL(cube_contains_v0(b, a));
 }
 
 /* Overlap */
@@ -1193,12 +1211,13 @@ cube_overlap_v0(NDBOX * a, NDBOX * b)
 Datum
 cube_overlap(PG_FUNCTION_ARGS)
 {
-   NDBOX   *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
 
-   PG_RETURN_BOOL (cube_overlap_v0(a, b));
+   PG_RETURN_BOOL(cube_overlap_v0(a, b));
 }
 
 
@@ -1213,7 +1232,8 @@ cube_distance(PG_FUNCTION_ARGS)
    int         i;
    double      d,
                distance;
-   NDBOX      *a, *b;
+   NDBOX      *a,
+              *b;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
    b = (NDBOX *) PG_GETARG_POINTER(1);
@@ -1266,7 +1286,7 @@ cube_is_point(PG_FUNCTION_ARGS)
 {
    int         i,
                j;
-   NDBOX       *a;
+   NDBOX      *a;
 
    a = (NDBOX *) PG_GETARG_POINTER(0);
 
@@ -1283,7 +1303,7 @@ cube_is_point(PG_FUNCTION_ARGS)
 Datum
 cube_dim(PG_FUNCTION_ARGS)
 {
-   NDBOX   *c;
+   NDBOX      *c;
 
    c = (NDBOX *) PG_GETARG_POINTER(0);
 
@@ -1397,8 +1417,8 @@ cube_f8(PG_FUNCTION_ARGS)
    result->dim = 1;
    result->x[0] = PG_GETARG_FLOAT8(0);
    result->x[1] = result->x[0];
-   
-   PG_RETURN_POINTER (result);
+
+   PG_RETURN_POINTER(result);
 }
 
 /* Create a one dimensional box */
@@ -1416,7 +1436,7 @@ cube_f8_f8(PG_FUNCTION_ARGS)
    result->x[0] = PG_GETARG_FLOAT8(0);
    result->x[1] = PG_GETARG_FLOAT8(1);
 
-   PG_RETURN_POINTER (result);
+   PG_RETURN_POINTER(result);
 }
 
 /* Add a dimension to an existing cube with the same values for the new
@@ -1431,7 +1451,7 @@ cube_c_f8(PG_FUNCTION_ARGS)
    int         i;
 
    c = (NDBOX *) PG_GETARG_POINTER(0);
-   x = PG_GETARG_FLOAT8 (1);
+   x = PG_GETARG_FLOAT8(1);
 
    size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2;
    result = (NDBOX *) palloc(size);
@@ -1446,7 +1466,7 @@ cube_c_f8(PG_FUNCTION_ARGS)
    result->x[result->dim - 1] = x;
    result->x[2 * result->dim - 1] = x;
 
-   PG_RETURN_POINTER(result);  
+   PG_RETURN_POINTER(result);
 }
 
 /* Add a dimension to an existing cube */
@@ -1455,13 +1475,14 @@ cube_c_f8_f8(PG_FUNCTION_ARGS)
 {
    NDBOX      *c;
    NDBOX      *result;
-   double      x1, x2;
+   double      x1,
+               x2;
    int         size;
    int         i;
 
    c = (NDBOX *) PG_GETARG_POINTER(0);
-   x1 = PG_GETARG_FLOAT8 (1);
-   x2 = PG_GETARG_FLOAT8 (2);
+   x1 = PG_GETARG_FLOAT8(1);
+   x2 = PG_GETARG_FLOAT8(2);
 
    size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2;
    result = (NDBOX *) palloc(size);
@@ -1476,7 +1497,5 @@ cube_c_f8_f8(PG_FUNCTION_ARGS)
    result->x[result->dim - 1] = x1;
    result->x[2 * result->dim - 1] = x2;
 
-   PG_RETURN_POINTER(result);  
+   PG_RETURN_POINTER(result);
 }
-
-
index 7a46673b6b170858c0781ef3b6497ea4b84e3211..08fb6328fbcfbce44befbc212b89fcbf5329d1bf 100644 (file)
@@ -8,7 +8,7 @@
  * Darko Prenosil 
  * Shridhar Daithankar 
  *
- * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.58 2006/09/02 21:11:15 joe Exp $
+ * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.59 2006/10/04 00:29:44 momjian Exp $
  * Copyright (c) 2001-2006, PostgreSQL Global Development Group
  * ALL RIGHTS RESERVED;
  *
@@ -362,11 +362,11 @@ dblink_open(PG_FUNCTION_ARGS)
            DBLINK_RES_INTERNALERROR("begin error");
        PQclear(res);
        rconn->newXactForCursor = TRUE;
+
        /*
         * Since transaction state was IDLE, we force cursor count to
-        * initially be 0. This is needed as a previous ABORT might
-        * have wiped out our transaction without maintaining the
-        * cursor count for us.
+        * initially be 0. This is needed as a previous ABORT might have wiped
+        * out our transaction without maintaining the cursor count for us.
         */
        rconn->openCursorCount = 0;
    }
@@ -621,8 +621,8 @@ dblink_fetch(PG_FUNCTION_ARGS)
        if (PQnfields(res) != tupdesc->natts)
            ereport(ERROR,
                    (errcode(ERRCODE_DATATYPE_MISMATCH),
-               errmsg("remote query result rowtype does not match "
-                       "the specified FROM clause rowtype")));
+                    errmsg("remote query result rowtype does not match "
+                           "the specified FROM clause rowtype")));
 
        /* fast track when no results */
        if (funcctx->max_calls < 1)
@@ -827,7 +827,7 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
 
            if (!res ||
                (PQresultStatus(res) != PGRES_COMMAND_OK &&
-               PQresultStatus(res) != PGRES_TUPLES_OK))
+                PQresultStatus(res) != PGRES_TUPLES_OK))
            {
                if (fail)
                    DBLINK_RES_ERROR("sql error");
@@ -839,33 +839,33 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
                    SRF_RETURN_DONE(funcctx);
                }
            }
-   
+
            if (PQresultStatus(res) == PGRES_COMMAND_OK)
            {
                is_sql_cmd = true;
-   
+
                /* need a tuple descriptor representing one TEXT column */
                tupdesc = CreateTemplateTupleDesc(1, false);
                TupleDescInitEntry(tupdesc, (AttrNumber) 1, "status",
-                               TEXTOID, -1, 0);
-   
+                                  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;
            }
            else
                funcctx->max_calls = PQntuples(res);
-   
+
            /* got results, keep track of them */
            funcctx->user_fctx = res;
-   
+
            /* if needed, close the connection to the database and cleanup */
            if (freeconn)
                PQfinish(conn);
-   
+
            if (!is_sql_cmd)
            {
                /* get a tuple descriptor for our result type */
@@ -878,26 +878,29 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
                        /* 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 */
                        elog(ERROR, "return type must be a row type");
                        break;
                }
-   
+
                /* make sure we have a persistent copy of the tupdesc */
                tupdesc = CreateTupleDescCopy(tupdesc);
            }
-   
-           /* check result and tuple descriptor have the same number of columns */
+
+           /*
+            * check result and tuple descriptor have the same number of
+            * columns
+            */
            if (PQnfields(res) != tupdesc->natts)
                ereport(ERROR,
                        (errcode(ERRCODE_DATATYPE_MISMATCH),
-                   errmsg("remote query result rowtype does not match "
-                           "the specified FROM clause rowtype")));
-   
+                        errmsg("remote query result rowtype does not match "
+                               "the specified FROM clause rowtype")));
+
            /* fast track when no results */
            if (funcctx->max_calls < 1)
            {
@@ -905,11 +908,11 @@ dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
                    PQclear(res);
                SRF_RETURN_DONE(funcctx);
            }
-   
+
            /* store needed metadata for subsequent calls */
            attinmeta = TupleDescGetAttInMetadata(tupdesc);
            funcctx->attinmeta = attinmeta;
-   
+
            MemoryContextSwitchTo(oldcontext);
        }
        else
@@ -991,9 +994,9 @@ PG_FUNCTION_INFO_V1(dblink_get_connections);
 Datum
 dblink_get_connections(PG_FUNCTION_ARGS)
 {
-   HASH_SEQ_STATUS         status;
-   remoteConnHashEnt      *hentry;
-   ArrayBuildState        *astate = NULL;
+   HASH_SEQ_STATUS status;
+   remoteConnHashEnt *hentry;
+   ArrayBuildState *astate = NULL;
 
    if (remoteConnHash)
    {
@@ -1019,19 +1022,19 @@ dblink_get_connections(PG_FUNCTION_ARGS)
  *
  * Returns 1 if the connection is busy, 0 otherwise
  * Params:
- *     text connection_name - name of the connection to check
- * 
+ * text connection_name - name of the connection to check
+ *
  */
 PG_FUNCTION_INFO_V1(dblink_is_busy);
 Datum
 dblink_is_busy(PG_FUNCTION_ARGS)
 {
-   char           *msg;
-   PGconn         *conn = NULL;
-   char           *conname = NULL;
-   char           *connstr = NULL;
-   remoteConn     *rconn = NULL;
-   bool            freeconn = false;
+   char       *msg;
+   PGconn     *conn = NULL;
+   char       *conname = NULL;
+   char       *connstr = NULL;
+   remoteConn *rconn = NULL;
+   bool        freeconn = false;
 
    DBLINK_INIT;
    DBLINK_GET_CONN;
@@ -1045,27 +1048,27 @@ dblink_is_busy(PG_FUNCTION_ARGS)
 /*
  * Cancels a running request on a connection
  *
- * Returns text: 
+ * Returns text:
  * "OK" if the cancel request has been sent correctly,
- *      an error message otherwise
- * 
+ *     an error message otherwise
+ *
  * Params:
- *     text connection_name - name of the connection to check
- * 
+ * text connection_name - name of the connection to check
+ *
  */
 PG_FUNCTION_INFO_V1(dblink_cancel_query);
 Datum
 dblink_cancel_query(PG_FUNCTION_ARGS)
 {
-   char           *msg;
-   int             res = 0;
-   PGconn         *conn = NULL;
-   char           *conname = NULL;
-   char           *connstr = NULL;
-   remoteConn     *rconn = NULL;
-   bool            freeconn = false;
-   PGcancel       *cancel;
-   char            errbuf[256];
+   char       *msg;
+   int         res = 0;
+   PGconn     *conn = NULL;
+   char       *conname = NULL;
+   char       *connstr = NULL;
+   remoteConn *rconn = NULL;
+   bool        freeconn = false;
+   PGcancel   *cancel;
+   char        errbuf[256];
 
    DBLINK_INIT;
    DBLINK_GET_CONN;
@@ -1077,7 +1080,7 @@ dblink_cancel_query(PG_FUNCTION_ARGS)
    PQfreeCancel(cancel);
 
    if (res == 0)
-       PG_RETURN_TEXT_P(GET_TEXT("OK"));   
+       PG_RETURN_TEXT_P(GET_TEXT("OK"));
    else
        PG_RETURN_TEXT_P(GET_TEXT(errbuf));
 }
@@ -1086,23 +1089,23 @@ dblink_cancel_query(PG_FUNCTION_ARGS)
 /*
  * Get error message from a connection
  *
- * Returns text: 
+ * Returns text:
  * "OK" if no error, an error message otherwise
- * 
+ *
  * Params:
- *     text connection_name - name of the connection to check
- * 
+ * text connection_name - name of the connection to check
+ *
  */
 PG_FUNCTION_INFO_V1(dblink_error_message);
 Datum
 dblink_error_message(PG_FUNCTION_ARGS)
 {
-   char           *msg;
-   PGconn         *conn = NULL;
-   char           *conname = NULL;
-   char           *connstr = NULL;
-   remoteConn     *rconn = NULL;
-   bool            freeconn = false;
+   char       *msg;
+   PGconn     *conn = NULL;
+   char       *conname = NULL;
+   char       *connstr = NULL;
+   remoteConn *rconn = NULL;
+   bool        freeconn = false;
 
    DBLINK_INIT;
    DBLINK_GET_CONN;
@@ -1859,7 +1862,7 @@ get_sql_delete(Oid relid, int2vector *pkattnums, int16 pknumatts, char **tgt_pka
    char       *relname;
    TupleDesc   tupdesc;
    int         natts;
-   StringInfoData  buf;
+   StringInfoData buf;
    int         i;
 
    initStringInfo(&buf);
index 5fb5999610378f533bdb572da19d196a2e9b2285..20ae203416a38abbbe0a9082e9185365c8578387 100644 (file)
 #include "storage/bufpage.h"
 
 
-typedef struct {
-   uint16  keylen;
-   uint16  vallen;
-   uint32  
-       valisnull:1,
-       pos:31;
-} HEntry; 
-
-
-typedef struct {
-   int4    len;
-   int4    size;
-   char    data[1];
-} HStore;
+typedef struct
+{
+   uint16      keylen;
+   uint16      vallen;
+   uint32
+               valisnull:1,
+               pos:31;
+}  HEntry;
+
+
+typedef struct
+{
+   int4        len;
+   int4        size;
+   char        data[1];
+}  HStore;
 
 #define HSHRDSIZE  (2*sizeof(int4))
 #define CALCDATASIZE(x, lenstr) ( (x) * sizeof(HEntry) + HSHRDSIZE + (lenstr) )
-#define ARRPTR(x)       ( (HEntry*) ( (char*)(x) + HSHRDSIZE ) )
-#define STRPTR(x)       ( (char*)(x) + HSHRDSIZE + ( sizeof(HEntry) * ((HStore*)x)->size ) )
+#define ARRPTR(x)      ( (HEntry*) ( (char*)(x) + HSHRDSIZE ) )
+#define STRPTR(x)      ( (char*)(x) + HSHRDSIZE + ( sizeof(HEntry) * ((HStore*)x)->size ) )
 
 
-#define PG_GETARG_HS(x)    ((HStore*)PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))
+#define PG_GETARG_HS(x) ((HStore*)PG_DETOAST_DATUM(PG_GETARG_DATUM(x)))
 
-typedef struct {
-        char    *key;
-        char    *val;
-        uint16  keylen;
-        uint16  vallen;
-        bool    isnull;  
-        bool    needfree;  
-} Pairs;
+typedef struct
+{
+   char       *key;
+   char       *val;
+   uint16      keylen;
+   uint16      vallen;
+   bool        isnull;
+   bool        needfree;
+}  Pairs;
 
-int comparePairs(const void *a, const void *b);
-int uniquePairs(Pairs * a, int4 l, int4 *buflen);
+int            comparePairs(const void *a, const void *b);
+int            uniquePairs(Pairs * a, int4 l, int4 *buflen);
 
 #endif
index f1c8738266552f7c0460d7b8ba35103743da15c6..4220a5541d193f09bbbfe552e0d8671f6d3f746e 100644 (file)
@@ -7,8 +7,8 @@
 
 /* bigint defines */
 #define BITBYTE 8
-#define SIGLENINT  4          /* >122 => key will toast, so very slow!!! */
-#define SIGLEN  ( sizeof(int)*SIGLENINT )
+#define SIGLENINT  4           /* >122 => key will toast, so very slow!!! */
+#define SIGLEN ( sizeof(int)*SIGLENINT )
 #define SIGLENBIT (SIGLEN*BITBYTE)
 
 typedef char BITVEC[SIGLEN];
@@ -36,22 +36,23 @@ typedef char *BITVECP;
 #define HASHVAL(val) (((unsigned int)(val)) % SIGLENBIT)
 #define HASH(sign, val) SETBIT((sign), HASHVAL(val))
 
-typedef struct {
-   int4        len;
-   int4        flag;
-   char        data[1];
-}       GISTTYPE;
+typedef struct
+{
+   int4        len;
+   int4        flag;
+   char        data[1];
+}  GISTTYPE;
 
-#define ALLISTRUE       0x04
+#define ALLISTRUE      0x04
 
-#define ISALLTRUE(x)    ( ((GISTTYPE*)x)->flag & ALLISTRUE )
+#define ISALLTRUE(x)   ( ((GISTTYPE*)x)->flag & ALLISTRUE )
 
-#define GTHDRSIZE       ( sizeof(int4)*2  )
+#define GTHDRSIZE      ( sizeof(int4)*2  )
 #define CALCGTSIZE(flag) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : SIGLEN) )
-  
-#define GETSIGN(x)      ( (BITVECP)( (char*)x+GTHDRSIZE ) )
 
-#define SUMBIT(val) (       \
+#define GETSIGN(x)     ( (BITVECP)( (char*)x+GTHDRSIZE ) )
+
+#define SUMBIT(val) (      \
    GETBITBYTE((val),0) + \
    GETBITBYTE((val),1) + \
    GETBITBYTE((val),2) + \
@@ -67,20 +68,22 @@ typedef struct {
 #define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
 
 PG_FUNCTION_INFO_V1(ghstore_in);
-Datum     ghstore_in(PG_FUNCTION_ARGS);
+Datum      ghstore_in(PG_FUNCTION_ARGS);
 
 PG_FUNCTION_INFO_V1(ghstore_out);
-Datum     ghstore_out(PG_FUNCTION_ARGS);
-  
+Datum      ghstore_out(PG_FUNCTION_ARGS);
+
 
 Datum
-ghstore_in(PG_FUNCTION_ARGS) {
+ghstore_in(PG_FUNCTION_ARGS)
+{
    elog(ERROR, "Not implemented");
    PG_RETURN_DATUM(0);
 }
 
 Datum
-ghstore_out(PG_FUNCTION_ARGS) {
+ghstore_out(PG_FUNCTION_ARGS)
+{
    elog(ERROR, "Not implemented");
    PG_RETURN_DATUM(0);
 }
@@ -93,36 +96,41 @@ PG_FUNCTION_INFO_V1(ghstore_picksplit);
 PG_FUNCTION_INFO_V1(ghstore_union);
 PG_FUNCTION_INFO_V1(ghstore_same);
 
-Datum     ghstore_consistent(PG_FUNCTION_ARGS);
-Datum     ghstore_compress(PG_FUNCTION_ARGS);
-Datum     ghstore_decompress(PG_FUNCTION_ARGS);
-Datum     ghstore_penalty(PG_FUNCTION_ARGS);
-Datum     ghstore_picksplit(PG_FUNCTION_ARGS);
-Datum     ghstore_union(PG_FUNCTION_ARGS);
-Datum     ghstore_same(PG_FUNCTION_ARGS);
+Datum      ghstore_consistent(PG_FUNCTION_ARGS);
+Datum      ghstore_compress(PG_FUNCTION_ARGS);
+Datum      ghstore_decompress(PG_FUNCTION_ARGS);
+Datum      ghstore_penalty(PG_FUNCTION_ARGS);
+Datum      ghstore_picksplit(PG_FUNCTION_ARGS);
+Datum      ghstore_union(PG_FUNCTION_ARGS);
+Datum      ghstore_same(PG_FUNCTION_ARGS);
 
 Datum
-ghstore_compress(PG_FUNCTION_ARGS) {
+ghstore_compress(PG_FUNCTION_ARGS)
+{
    GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
    GISTENTRY  *retval = entry;
-    
-   if (entry->leafkey) {                              
-       GISTTYPE   *res = (GISTTYPE*)palloc(CALCGTSIZE(0));
-       HStore     *toastedval = (HStore *) DatumGetPointer(entry->key);
-       HStore     *val = (HStore *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
-       HEntry     *ptr = ARRPTR(val);
-       char       *words = STRPTR(val);
-
-       memset(res,0,CALCGTSIZE(0));
-       res->len=CALCGTSIZE(0);
-   
-       while(ptr-ARRPTR(val) < val->size) {
-           int h;
-           h = crc32_sz((char*)(words+ptr->pos), ptr->keylen);
-           HASH( GETSIGN(res), h);
-           if ( !ptr->valisnull ) {
-               h = crc32_sz((char *)(words+ptr->pos+ptr->keylen), ptr->vallen);
-               HASH( GETSIGN(res), h);
+
+   if (entry->leafkey)
+   {
+       GISTTYPE   *res = (GISTTYPE *) palloc(CALCGTSIZE(0));
+       HStore     *toastedval = (HStore *) DatumGetPointer(entry->key);
+       HStore     *val = (HStore *) DatumGetPointer(PG_DETOAST_DATUM(entry->key));
+       HEntry     *ptr = ARRPTR(val);
+       char       *words = STRPTR(val);
+
+       memset(res, 0, CALCGTSIZE(0));
+       res->len = CALCGTSIZE(0);
+
+       while (ptr - ARRPTR(val) < val->size)
+       {
+           int         h;
+
+           h = crc32_sz((char *) (words + ptr->pos), ptr->keylen);
+           HASH(GETSIGN(res), h);
+           if (!ptr->valisnull)
+           {
+               h = crc32_sz((char *) (words + ptr->pos + ptr->keylen), ptr->vallen);
+               HASH(GETSIGN(res), h);
            }
            ptr++;
        }
@@ -135,14 +143,16 @@ ghstore_compress(PG_FUNCTION_ARGS) {
                      entry->rel, entry->page,
                      entry->offset,
                      FALSE);
-   } else if ( !ISALLTRUE(DatumGetPointer(entry->key)) ) {
-       int4        i;
+   }
+   else if (!ISALLTRUE(DatumGetPointer(entry->key)))
+   {
+       int4        i;
        GISTTYPE   *res;
-       BITVECP  sign = GETSIGN(DatumGetPointer(entry->key));
-       
+       BITVECP     sign = GETSIGN(DatumGetPointer(entry->key));
+
        LOOPBYTE(
-           if ((sign[i] & 0xff) != 0xff)
-               PG_RETURN_POINTER(retval);
+                if ((sign[i] & 0xff) != 0xff)
+                PG_RETURN_POINTER(retval);
        );
 
        res = (GISTTYPE *) palloc(CALCGTSIZE(ALLISTRUE));
@@ -152,7 +162,7 @@ ghstore_compress(PG_FUNCTION_ARGS) {
        retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
        gistentryinit(*retval, PointerGetDatum(res),
                      entry->rel, entry->page,
-                     entry->offset, 
+                     entry->offset,
                      FALSE);
    }
 
@@ -160,15 +170,17 @@ ghstore_compress(PG_FUNCTION_ARGS) {
 }
 
 Datum
-ghstore_decompress(PG_FUNCTION_ARGS) {
+ghstore_decompress(PG_FUNCTION_ARGS)
+{
    PG_RETURN_DATUM(PG_GETARG_DATUM(0));
 }
 
 Datum
-ghstore_same(PG_FUNCTION_ARGS) {
+ghstore_same(PG_FUNCTION_ARGS)
+{
    GISTTYPE   *a = (GISTTYPE *) PG_GETARG_POINTER(0);
    GISTTYPE   *b = (GISTTYPE *) PG_GETARG_POINTER(1);
-   bool       *result = (bool *) PG_GETARG_POINTER(2);
+   bool       *result = (bool *) PG_GETARG_POINTER(2);
 
    if (ISALLTRUE(a) && ISALLTRUE(b))
        *result = true;
@@ -176,83 +188,97 @@ ghstore_same(PG_FUNCTION_ARGS) {
        *result = false;
    else if (ISALLTRUE(b))
        *result = false;
-   else {
-       int4            i;
-       BITVECP         sa = GETSIGN(a),
-               sb = GETSIGN(b);
+   else
+   {
+       int4        i;
+       BITVECP     sa = GETSIGN(a),
+                   sb = GETSIGN(b);
+
        *result = true;
        LOOPBYTE(
-           if (sa[i] != sb[i]) {
-               *result = false;
-               break;
-           }
+                if (sa[i] != sb[i])
+                {
+           *result = false;
+           break;
+       }
        );
    }
    PG_RETURN_POINTER(result);
 }
 
 static int4
-sizebitvec(BITVECP sign) {
-   int4        size = 0, i;
+sizebitvec(BITVECP sign)
+{
+   int4        size = 0,
+               i;
+
    LOOPBYTE(
-       size += SUMBIT(sign);
-       sign = (BITVECP) (((char *) sign) + 1);
+            size += SUMBIT(sign);
+   sign = (BITVECP) (((char *) sign) + 1);
    );
    return size;
 }
+
 static int
-hemdistsign(BITVECP  a, BITVECP b) {
-   int i,dist=0;
+hemdistsign(BITVECP a, BITVECP b)
+{
+   int         i,
+               dist = 0;
 
    LOOPBIT(
-       if ( GETBIT(a,i) != GETBIT(b,i) )
+           if (GETBIT(a, i) != GETBIT(b, i))
            dist++;
    );
    return dist;
 }
 
 static int
-hemdist(GISTTYPE   *a, GISTTYPE   *b) {
-   if ( ISALLTRUE(a) ) {
+hemdist(GISTTYPE * a, GISTTYPE * b)
+{
+   if (ISALLTRUE(a))
+   {
        if (ISALLTRUE(b))
            return 0;
        else
-           return SIGLENBIT-sizebitvec(GETSIGN(b));
-   } else if (ISALLTRUE(b))
-       return SIGLENBIT-sizebitvec(GETSIGN(a));
+           return SIGLENBIT - sizebitvec(GETSIGN(b));
+   }
+   else if (ISALLTRUE(b))
+       return SIGLENBIT - sizebitvec(GETSIGN(a));
 
-   return hemdistsign( GETSIGN(a), GETSIGN(b) );
+   return hemdistsign(GETSIGN(a), GETSIGN(b));
 }
 
 static int4
 unionkey(BITVECP sbase, GISTTYPE * add)
 {
-   int4        i;
-   BITVECP  sadd = GETSIGN(add);
+   int4        i;
+   BITVECP     sadd = GETSIGN(add);
 
    if (ISALLTRUE(add))
        return 1;
    LOOPBYTE(
-       sbase[i] |= sadd[i];
+            sbase[i] |= sadd[i];
    );
    return 0;
 }
 
 Datum
-ghstore_union(PG_FUNCTION_ARGS) {
-   GistEntryVector      *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
-   int4        len = entryvec->n;
-
-   int     *size = (int *) PG_GETARG_POINTER(1);
-   BITVEC    base;
-   int4        i;
-   int4        flag = 0;
+ghstore_union(PG_FUNCTION_ARGS)
+{
+   GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
+   int4        len = entryvec->n;
+
+   int        *size = (int *) PG_GETARG_POINTER(1);
+   BITVEC      base;
+   int4        i;
+   int4        flag = 0;
    GISTTYPE   *result;
 
    MemSet((void *) base, 0, sizeof(BITVEC));
-   for (i = 0; i < len; i++) {
-       if (unionkey(base, GETENTRY(entryvec, i))) {
+   for (i = 0; i < len; i++)
+   {
+       if (unionkey(base, GETENTRY(entryvec, i)))
+       {
            flag = ALLISTRUE;
            break;
        }
@@ -269,64 +295,72 @@ ghstore_union(PG_FUNCTION_ARGS) {
 }
 
 Datum
-ghstore_penalty(PG_FUNCTION_ARGS) {
+ghstore_penalty(PG_FUNCTION_ARGS)
+{
    GISTENTRY  *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); /* always ISSIGNKEY */
    GISTENTRY  *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
-   float      *penalty = (float *) PG_GETARG_POINTER(2);
+   float      *penalty = (float *) PG_GETARG_POINTER(2);
    GISTTYPE   *origval = (GISTTYPE *) DatumGetPointer(origentry->key);
    GISTTYPE   *newval = (GISTTYPE *) DatumGetPointer(newentry->key);
 
-   *penalty=hemdist(origval,newval);
+   *penalty = hemdist(origval, newval);
    PG_RETURN_POINTER(penalty);
 }
 
 
-typedef struct {
+typedef struct
+{
    OffsetNumber pos;
-   int4        cost;
-} SPLITCOST;
+   int4        cost;
+}  SPLITCOST;
 
 static int
-comparecost(const void *a, const void *b) {
+comparecost(const void *a, const void *b)
+{
    return ((SPLITCOST *) a)->cost - ((SPLITCOST *) b)->cost;
 }
 
 
 Datum
-ghstore_picksplit(PG_FUNCTION_ARGS) {
-   GistEntryVector      *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
+ghstore_picksplit(PG_FUNCTION_ARGS)
+{
+   GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
    OffsetNumber maxoff = entryvec->n - 2;
 
    GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
    OffsetNumber k,
                j;
-   GISTTYPE *datum_l,
+   GISTTYPE   *datum_l,
               *datum_r;
-   BITVECP  union_l,
+   BITVECP     union_l,
                union_r;
-   int4        size_alpha, size_beta;
-   int4        size_waste,
+   int4        size_alpha,
+               size_beta;
+   int4        size_waste,
                waste = -1;
-   int4        nbytes;
+   int4        nbytes;
    OffsetNumber seed_1 = 0,
                seed_2 = 0;
    OffsetNumber *left,
               *right;
-   BITVECP  ptr;
-   int          i;
+   BITVECP     ptr;
+   int         i;
    SPLITCOST  *costvector;
-   GISTTYPE *_k,
+   GISTTYPE   *_k,
               *_j;
 
    nbytes = (maxoff + 2) * sizeof(OffsetNumber);
    v->spl_left = (OffsetNumber *) palloc(nbytes);
    v->spl_right = (OffsetNumber *) palloc(nbytes);
 
-   for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k)) {
+   for (k = FirstOffsetNumber; k < maxoff; k = OffsetNumberNext(k))
+   {
        _k = GETENTRY(entryvec, k);
-       for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j)) {
-           size_waste=hemdist(_k, GETENTRY(entryvec, j));
-           if (size_waste > waste ) {
+       for (j = OffsetNumberNext(k); j <= maxoff; j = OffsetNumberNext(j))
+       {
+           size_waste = hemdist(_k, GETENTRY(entryvec, j));
+           if (size_waste > waste)
+           {
                waste = size_waste;
                seed_1 = k;
                seed_2 = j;
@@ -346,26 +380,32 @@ ghstore_picksplit(PG_FUNCTION_ARGS) {
    }
 
    /* form initial .. */
-   if (ISALLTRUE(GETENTRY(entryvec, seed_1))) {
+   if (ISALLTRUE(GETENTRY(entryvec, seed_1)))
+   {
        datum_l = (GISTTYPE *) palloc(GTHDRSIZE);
        datum_l->len = GTHDRSIZE;
        datum_l->flag = ALLISTRUE;
-   } else {
+   }
+   else
+   {
        datum_l = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
        datum_l->len = GTHDRSIZE + SIGLEN;
        datum_l->flag = 0;
        memcpy((void *) GETSIGN(datum_l), (void *) GETSIGN(GETENTRY(entryvec, seed_1)), sizeof(BITVEC))
-;
+           ;
    }
-   if (ISALLTRUE(GETENTRY(entryvec, seed_2))) {
+   if (ISALLTRUE(GETENTRY(entryvec, seed_2)))
+   {
        datum_r = (GISTTYPE *) palloc(GTHDRSIZE);
        datum_r->len = GTHDRSIZE;
        datum_r->flag = ALLISTRUE;
-   } else {
+   }
+   else
+   {
        datum_r = (GISTTYPE *) palloc(GTHDRSIZE + SIGLEN);
        datum_r->len = GTHDRSIZE + SIGLEN;
        datum_r->flag = 0;
-       memcpy((void *) GETSIGN(datum_r), (void *) GETSIGN(GETENTRY(entryvec, seed_2)), sizeof(BITVEC)) ;
+       memcpy((void *) GETSIGN(datum_r), (void *) GETSIGN(GETENTRY(entryvec, seed_2)), sizeof(BITVEC));
    }
 
    maxoff = OffsetNumberNext(maxoff);
@@ -375,50 +415,63 @@ ghstore_picksplit(PG_FUNCTION_ARGS) {
    {
        costvector[j - 1].pos = j;
        _j = GETENTRY(entryvec, j);
-       size_alpha = hemdist(datum_l,_j);
-       size_beta  = hemdist(datum_r,_j);
+       size_alpha = hemdist(datum_l, _j);
+       size_beta = hemdist(datum_r, _j);
        costvector[j - 1].cost = abs(size_alpha - size_beta);
    }
    qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
 
-   union_l=GETSIGN(datum_l);
-   union_r=GETSIGN(datum_r);
+   union_l = GETSIGN(datum_l);
+   union_r = GETSIGN(datum_r);
 
-   for (k = 0; k < maxoff; k++) {
+   for (k = 0; k < maxoff; k++)
+   {
        j = costvector[k].pos;
-       if (j == seed_1) {
+       if (j == seed_1)
+       {
            *left++ = j;
            v->spl_nleft++;
            continue;
-       } else if (j == seed_2) {
+       }
+       else if (j == seed_2)
+       {
            *right++ = j;
            v->spl_nright++;
            continue;
        }
        _j = GETENTRY(entryvec, j);
-       size_alpha = hemdist(datum_l,_j);
-       size_beta  = hemdist(datum_r,_j);
+       size_alpha = hemdist(datum_l, _j);
+       size_beta = hemdist(datum_r, _j);
 
-       if (size_alpha < size_beta  + WISH_F(v->spl_nleft, v->spl_nright, 0.0001)) {
-           if (ISALLTRUE(datum_l) || ISALLTRUE(_j) ) {
+       if (size_alpha < size_beta + WISH_F(v->spl_nleft, v->spl_nright, 0.0001))
+       {
+           if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
+           {
                if (!ISALLTRUE(datum_l))
                    MemSet((void *) union_l, 0xff, sizeof(BITVEC));
-           } else {
-               ptr=GETSIGN(_j);
+           }
+           else
+           {
+               ptr = GETSIGN(_j);
                LOOPBYTE(
-                   union_l[i] |= ptr[i];
+                        union_l[i] |= ptr[i];
                );
            }
            *left++ = j;
            v->spl_nleft++;
-       } else {
-           if (ISALLTRUE(datum_r) || ISALLTRUE(_j) ) {
+       }
+       else
+       {
+           if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
+           {
                if (!ISALLTRUE(datum_r))
                    MemSet((void *) union_r, 0xff, sizeof(BITVEC));
-           } else {
-               ptr=GETSIGN(_j);
+           }
+           else
+           {
+               ptr = GETSIGN(_j);
                LOOPBYTE(
-                   union_r[i] |= ptr[i];
+                        union_r[i] |= ptr[i];
                );
            }
            *right++ = j;
@@ -436,36 +489,41 @@ ghstore_picksplit(PG_FUNCTION_ARGS) {
 }
 
 
-Datum     
-ghstore_consistent(PG_FUNCTION_ARGS) {
-   GISTTYPE  *entry = (GISTTYPE*) DatumGetPointer( ((GISTENTRY *) PG_GETARG_POINTER(0))->key );
-   HStore *query=PG_GETARG_HS(1);
-   bool res=true;
-   HEntry  *qe = ARRPTR(query);
-   char    *qv = STRPTR(query);
-   BITVECP sign;
-
-   if ( ISALLTRUE(entry) ) {
-       PG_FREE_IF_COPY(query,1);
+Datum
+ghstore_consistent(PG_FUNCTION_ARGS)
+{
+   GISTTYPE   *entry = (GISTTYPE *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
+   HStore     *query = PG_GETARG_HS(1);
+   bool        res = true;
+   HEntry     *qe = ARRPTR(query);
+   char       *qv = STRPTR(query);
+   BITVECP     sign;
+
+   if (ISALLTRUE(entry))
+   {
+       PG_FREE_IF_COPY(query, 1);
        PG_RETURN_BOOL(true);
    }
 
-   sign=GETSIGN(entry); 
-   while(res && qe-ARRPTR(query) < query->size) {
-       int crc = crc32_sz((char *)(qv + qe->pos), qe->keylen);
-       if (GETBIT(sign,HASHVAL(crc))) {
-           if ( !qe->valisnull ) {
-               crc = crc32_sz((char *)(qv + qe->pos + qe->keylen), qe->vallen);
-               if ( !GETBIT(sign,HASHVAL(crc)) )
-                   res=false;
+   sign = GETSIGN(entry);
+   while (res && qe - ARRPTR(query) < query->size)
+   {
+       int         crc = crc32_sz((char *) (qv + qe->pos), qe->keylen);
+
+       if (GETBIT(sign, HASHVAL(crc)))
+       {
+           if (!qe->valisnull)
+           {
+               crc = crc32_sz((char *) (qv + qe->pos + qe->keylen), qe->vallen);
+               if (!GETBIT(sign, HASHVAL(crc)))
+                   res = false;
            }
-       } else
-           res=false;
+       }
+       else
+           res = false;
        qe++;
    }
 
-   PG_FREE_IF_COPY(query,1);
+   PG_FREE_IF_COPY(query, 1);
    PG_RETURN_BOOL(res);
 }
-
-
index 051a411a99346f369275e9eb7fc9e4d74fb1a3e2..e01cb4e7599fe57401bf9586336a11875b23d27a 100644 (file)
 
 PG_MODULE_MAGIC;
 
-typedef struct {
-   char *begin;
-   char *ptr;
-   char *cur;
-   char *word;
-   int wordlen;
-
-   Pairs   *pairs;
-   int pcur;
-   int plen;
-} HSParser;
+typedef struct
+{
+   char       *begin;
+   char       *ptr;
+   char       *cur;
+   char       *word;
+   int         wordlen;
+
+   Pairs      *pairs;
+   int         pcur;
+   int         plen;
+}  HSParser;
 
 #define RESIZEPRSBUF \
 do { \
-        if ( state->cur - state->word + 1 >= state->wordlen ) \
-        { \
-                int4 clen = state->cur - state->word; \
-                state->wordlen *= 2; \
-                state->word = (char*)repalloc( (void*)state->word, state->wordlen ); \
-                state->cur = state->word + clen; \
-        } \
+       if ( state->cur - state->word + 1 >= state->wordlen ) \
+       { \
+               int4 clen = state->cur - state->word; \
+               state->wordlen *= 2; \
+               state->word = (char*)repalloc( (void*)state->word, state->wordlen ); \
+               state->cur = state->word + clen; \
+       } \
 } while (0)
 
 
-#define GV_WAITVAL 0 
-#define GV_INVAL 1 
-#define GV_INESCVAL 2 
-#define GV_WAITESCIN 3 
-#define GV_WAITESCESCIN 4 
+#define GV_WAITVAL 0
+#define GV_INVAL 1
+#define GV_INESCVAL 2
+#define GV_WAITESCIN 3
+#define GV_WAITESCESCIN 4
 
 static bool
-get_val( HSParser *state, bool ignoreeq, bool *escaped ) {
-   int st = GV_WAITVAL;
-   state->wordlen=32;
-   state->cur = state->word = palloc( state->wordlen );
-   *escaped=false;
-
-   while(1) {
-       if ( st == GV_WAITVAL ) {
-           if ( *(state->ptr) == '"' ) {
-               *escaped=true;
+get_val(HSParser * state, bool ignoreeq, bool *escaped)
+{
+   int         st = GV_WAITVAL;
+
+   state->wordlen = 32;
+   state->cur = state->word = palloc(state->wordlen);
+   *escaped = false;
+
+   while (1)
+   {
+       if (st == GV_WAITVAL)
+       {
+           if (*(state->ptr) == '"')
+           {
+               *escaped = true;
                st = GV_INESCVAL;
-           } else if ( *(state->ptr) == '\0' ) {
+           }
+           else if (*(state->ptr) == '\0')
+           {
                return false;
-           } else if (  *(state->ptr) == '=' && !ignoreeq ) {
-               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), (int4)(state->ptr-state->begin));
-           } else if ( *(state->ptr) == '\\' ) {
+           }
+           else if (*(state->ptr) == '=' && !ignoreeq)
+           {
+               elog(ERROR, "Syntax error near '%c' at postion %d", *(state->ptr), (int4) (state->ptr - state->begin));
+           }
+           else if (*(state->ptr) == '\\')
+           {
                st = GV_WAITESCIN;
-           } else if ( !isspace((unsigned char) *(state->ptr)) ) {
+           }
+           else if (!isspace((unsigned char) *(state->ptr)))
+           {
                *(state->cur) = *(state->ptr);
                state->cur++;
                st = GV_INVAL;
            }
-       } else if ( st == GV_INVAL ) {
-           if ( *(state->ptr) == '\\' ) {
+       }
+       else if (st == GV_INVAL)
+       {
+           if (*(state->ptr) == '\\')
+           {
                st = GV_WAITESCIN;
-           } else if ( *(state->ptr) == '=' && !ignoreeq ) {
+           }
+           else if (*(state->ptr) == '=' && !ignoreeq)
+           {
                state->ptr--;
                return true;
-           } else if ( *(state->ptr) == ',' && ignoreeq ) {
+           }
+           else if (*(state->ptr) == ',' && ignoreeq)
+           {
                state->ptr--;
                return true;
-           } else if ( isspace((unsigned char) *(state->ptr)) ) {
+           }
+           else if (isspace((unsigned char) *(state->ptr)))
+           {
                return true;
-           } else if ( *(state->ptr) == '\0' ) {
+           }
+           else if (*(state->ptr) == '\0')
+           {
                state->ptr--;
                return true;
-           } else {
+           }
+           else
+           {
                RESIZEPRSBUF;
                *(state->cur) = *(state->ptr);
                state->cur++;
            }
-       } else if ( st == GV_INESCVAL ) {
-           if ( *(state->ptr) == '\\' ) {
+       }
+       else if (st == GV_INESCVAL)
+       {
+           if (*(state->ptr) == '\\')
+           {
                st = GV_WAITESCESCIN;
-           } else if ( *(state->ptr) == '"' ) {
+           }
+           else if (*(state->ptr) == '"')
+           {
                return true;
-           } else if ( *(state->ptr) == '\0' ) {
-               elog(ERROR,"Unexpected end of string");
-           } else {
+           }
+           else if (*(state->ptr) == '\0')
+           {
+               elog(ERROR, "Unexpected end of string");
+           }
+           else
+           {
                RESIZEPRSBUF;
                *(state->cur) = *(state->ptr);
                state->cur++;
            }
-       } else if ( st == GV_WAITESCIN ) {
-           if ( *(state->ptr) == '\0' )
-               elog(ERROR,"Unexpected end of string");
+       }
+       else if (st == GV_WAITESCIN)
+       {
+           if (*(state->ptr) == '\0')
+               elog(ERROR, "Unexpected end of string");
            RESIZEPRSBUF;
            *(state->cur) = *(state->ptr);
            state->cur++;
-           st = GV_INVAL; 
-       } else if ( st == GV_WAITESCESCIN ) {
-           if ( *(state->ptr) == '\0' )
-               elog(ERROR,"Unexpected end of string");
+           st = GV_INVAL;
+       }
+       else if (st == GV_WAITESCESCIN)
+       {
+           if (*(state->ptr) == '\0')
+               elog(ERROR, "Unexpected end of string");
            RESIZEPRSBUF;
            *(state->cur) = *(state->ptr);
            state->cur++;
            st = GV_INESCVAL;
-       } else
-           elog(ERROR,"Unknown state %d at postion line %d in file '%s'", st, __LINE__, __FILE__); 
+       }
+       else
+           elog(ERROR, "Unknown state %d at postion line %d in file '%s'", st, __LINE__, __FILE__);
 
        state->ptr++;
-   } 
+   }
 
    return false;
 }
 
 #define WKEY   0
 #define WVAL   1
-#define WEQ    2
-#define WGT    3
+#define WEQ 2
+#define WGT 3
 #define WDEL   4
 
 
 static void
-parse_hstore( HSParser *state ) {
-   int st = WKEY;
-   bool escaped=false;
-
-   state->plen=16;
-   state->pairs = (Pairs*)palloc( sizeof(Pairs) * state->plen );
-   state->pcur=0;
+parse_hstore(HSParser * state)
+{
+   int         st = WKEY;
+   bool        escaped = false;
+
+   state->plen = 16;
+   state->pairs = (Pairs *) palloc(sizeof(Pairs) * state->plen);
+   state->pcur = 0;
    state->ptr = state->begin;
-   state->word=NULL;
+   state->word = NULL;
 
-   while(1) {
-       if (st == WKEY) {
-           if ( !get_val(state, false, &escaped) )
+   while (1)
+   {
+       if (st == WKEY)
+       {
+           if (!get_val(state, false, &escaped))
                return;
-           if ( state->pcur >= state->plen ) {
+           if (state->pcur >= state->plen)
+           {
                state->plen *= 2;
-               state->pairs = (Pairs*)repalloc( state->pairs, sizeof(Pairs) * state->plen );
+               state->pairs = (Pairs *) repalloc(state->pairs, sizeof(Pairs) * state->plen);
            }
-           state->pairs[ state->pcur ].key = state->word; 
-           state->pairs[ state->pcur ].keylen = state->cur - state->word;
-           state->pairs[ state->pcur ].val=NULL;
-           state->word=NULL;
+           state->pairs[state->pcur].key = state->word;
+           state->pairs[state->pcur].keylen = state->cur - state->word;
+           state->pairs[state->pcur].val = NULL;
+           state->word = NULL;
            st = WEQ;
-       } else if ( st == WEQ ) {
-           if ( *(state->ptr) == '=' ) {
+       }
+       else if (st == WEQ)
+       {
+           if (*(state->ptr) == '=')
+           {
                st = WGT;
-           } else if ( *(state->ptr) == '\0' ) {
-               elog(ERROR,"Unexpectd end of string");
-           } else if (!isspace((unsigned char) *(state->ptr))) {
-               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), (int4)(state->ptr-state->begin));
            }
-       } else if ( st == WGT ) {
-           if ( *(state->ptr) == '>' ) {
+           else if (*(state->ptr) == '\0')
+           {
+               elog(ERROR, "Unexpectd end of string");
+           }
+           else if (!isspace((unsigned char) *(state->ptr)))
+           {
+               elog(ERROR, "Syntax error near '%c' at postion %d", *(state->ptr), (int4) (state->ptr - state->begin));
+           }
+       }
+       else if (st == WGT)
+       {
+           if (*(state->ptr) == '>')
+           {
                st = WVAL;
-           } else if ( *(state->ptr) == '\0' ) {
-               elog(ERROR,"Unexpectd end of string");
-           } else { 
-               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), (int4)(state->ptr-state->begin));
            }
-       } else if ( st == WVAL ) {
-           if ( !get_val(state, true, &escaped) )
-               elog(ERROR,"Unexpected end of string");
-           state->pairs[ state->pcur ].val = state->word;
-           state->pairs[ state->pcur ].vallen = state->cur - state->word;
-           state->pairs[ state->pcur ].isnull = false;
-           state->pairs[ state->pcur ].needfree = true;
-           if ( state->cur - state->word == 4 && !escaped) {
+           else if (*(state->ptr) == '\0')
+           {
+               elog(ERROR, "Unexpectd end of string");
+           }
+           else
+           {
+               elog(ERROR, "Syntax error near '%c' at postion %d", *(state->ptr), (int4) (state->ptr - state->begin));
+           }
+       }
+       else if (st == WVAL)
+       {
+           if (!get_val(state, true, &escaped))
+               elog(ERROR, "Unexpected end of string");
+           state->pairs[state->pcur].val = state->word;
+           state->pairs[state->pcur].vallen = state->cur - state->word;
+           state->pairs[state->pcur].isnull = false;
+           state->pairs[state->pcur].needfree = true;
+           if (state->cur - state->word == 4 && !escaped)
+           {
                state->word[4] = '\0';
-               if ( 0==pg_strcasecmp(state->word, "null") ) 
-                   state->pairs[ state->pcur ].isnull=true;
-           } 
-           state->word=NULL;
+               if (0 == pg_strcasecmp(state->word, "null"))
+                   state->pairs[state->pcur].isnull = true;
+           }
+           state->word = NULL;
            state->pcur++;
            st = WDEL;
-       } else if ( st == WDEL ) {
-           if (  *(state->ptr) == ',' ) {
+       }
+       else if (st == WDEL)
+       {
+           if (*(state->ptr) == ',')
+           {
                st = WKEY;
-           } else if ( *(state->ptr) == '\0' ) {
+           }
+           else if (*(state->ptr) == '\0')
+           {
                return;
-           } else if (!isspace((unsigned char) *(state->ptr))) {
-               elog(ERROR,"Syntax error near '%c' at postion %d", *(state->ptr), (int4)(state->ptr-state->begin));
            }
-       } else 
-           elog(ERROR,"Unknown state %d at line %d in file '%s'", st, __LINE__, __FILE__);
+           else if (!isspace((unsigned char) *(state->ptr)))
+           {
+               elog(ERROR, "Syntax error near '%c' at postion %d", *(state->ptr), (int4) (state->ptr - state->begin));
+           }
+       }
+       else
+           elog(ERROR, "Unknown state %d at line %d in file '%s'", st, __LINE__, __FILE__);
 
        state->ptr++;
    }
-} 
+}
 
 int
-comparePairs(const void *a, const void *b) {
-   if ( ((Pairs*)a)->keylen == ((Pairs*)b)->keylen ) { 
-       int res =  strncmp(
-               ((Pairs*)a)->key,
-               ((Pairs*)b)->key,
-               ((Pairs*)a)->keylen
-           );
-       if ( res )
+comparePairs(const void *a, const void *b)
+{
+   if (((Pairs *) a)->keylen == ((Pairs *) b)->keylen)
+   {
+       int         res = strncmp(
+                                 ((Pairs *) a)->key,
+                                 ((Pairs *) b)->key,
+                                 ((Pairs *) a)->keylen
+       );
+
+       if (res)
            return res;
 
        /* guarantee that neddfree willl be later */
-       if ( ((Pairs*)b)->needfree == ((Pairs*)a)->needfree )
+       if (((Pairs *) b)->needfree == ((Pairs *) a)->needfree)
            return 0;
-       else if ( ((Pairs*)a)->needfree )
+       else if (((Pairs *) a)->needfree)
            return 1;
        else
-           return -1;  
+           return -1;
    }
-   return ( ((Pairs*)a)->keylen > ((Pairs*)b)->keylen ) ? 1 : -1;
+   return (((Pairs *) a)->keylen > ((Pairs *) b)->keylen) ? 1 : -1;
 }
 
 int
-uniquePairs(Pairs * a, int4 l, int4 *buflen) {
-   Pairs *ptr, *res;
-
-   *buflen=0;
-   if ( l < 2 ) {
-       if ( l==1 )
-           *buflen = a->keylen + ((a->isnull) ? 0 : a->vallen) ;
+uniquePairs(Pairs * a, int4 l, int4 *buflen)
+{
+   Pairs      *ptr,
+              *res;
+
+   *buflen = 0;
+   if (l < 2)
+   {
+       if (l == 1)
+           *buflen = a->keylen + ((a->isnull) ? 0 : a->vallen);
        return l;
    }
 
    qsort((void *) a, l, sizeof(Pairs), comparePairs);
-   ptr=a+1;
-   res=a;  
-   while( ptr - a < l ) {
-       if ( ptr->keylen == res->keylen && strncmp( ptr->key, res->key, res->keylen )==0 ) {
-           if ( ptr->needfree ) {
+   ptr = a + 1;
+   res = a;
+   while (ptr - a < l)
+   {
+       if (ptr->keylen == res->keylen && strncmp(ptr->key, res->key, res->keylen) == 0)
+       {
+           if (ptr->needfree)
+           {
                pfree(ptr->key);
                pfree(ptr->val);
            }
-       } else {
-           *buflen += res->keylen + (( res->isnull ) ? 0 : res->vallen);
+       }
+       else
+       {
+           *buflen += res->keylen + ((res->isnull) ? 0 : res->vallen);
            res++;
-           memcpy(res,ptr,sizeof(Pairs));
+           memcpy(res, ptr, sizeof(Pairs));
        }
 
        ptr++;
    }
 
-   *buflen += res->keylen + (( res->isnull ) ? 0 : res->vallen);
+   *buflen += res->keylen + ((res->isnull) ? 0 : res->vallen);
    return res + 1 - a;
 }
 
 static void
-freeHSParse(HSParser *state) {
-   int i;
-
-   if ( state->word ) pfree( state->word );
-   for (i=0;ipcur;i++)
-       if ( state->pairs[i].needfree ) {
-           if (state->pairs[i].key) pfree(state->pairs[i].key);
-           if (state->pairs[i].val) pfree(state->pairs[i].val);
+freeHSParse(HSParser * state)
+{
+   int         i;
+
+   if (state->word)
+       pfree(state->word);
+   for (i = 0; i < state->pcur; i++)
+       if (state->pairs[i].needfree)
+       {
+           if (state->pairs[i].key)
+               pfree(state->pairs[i].key);
+           if (state->pairs[i].val)
+               pfree(state->pairs[i].val);
        }
-   pfree( state->pairs );
+   pfree(state->pairs);
 }
 
 PG_FUNCTION_INFO_V1(hstore_in);
-Datum           hstore_in(PG_FUNCTION_ARGS);
+Datum      hstore_in(PG_FUNCTION_ARGS);
 Datum
-hstore_in(PG_FUNCTION_ARGS) {
-   HSParser   state;
-   int4 len,buflen,i;
-   HStore  *out;
-   HEntry  *entries;
-   char *ptr;
-
-   state.begin =  PG_GETARG_CSTRING(0);
+hstore_in(PG_FUNCTION_ARGS)
+{
+   HSParser    state;
+   int4        len,
+               buflen,
+               i;
+   HStore     *out;
+   HEntry     *entries;
+   char       *ptr;
+
+   state.begin = PG_GETARG_CSTRING(0);
 
    parse_hstore(&state);
 
-   if ( state.pcur == 0 ) {
+   if (state.pcur == 0)
+   {
        freeHSParse(&state);
-       len = CALCDATASIZE(0,0);
+       len = CALCDATASIZE(0, 0);
        out = palloc(len);
-       out->len=len;
-       out->size=0;
+       out->len = len;
+       out->size = 0;
        PG_RETURN_POINTER(out);
    }
 
    state.pcur = uniquePairs(state.pairs, state.pcur, &buflen);
 
-   len=CALCDATASIZE(state.pcur, buflen);
+   len = CALCDATASIZE(state.pcur, buflen);
    out = palloc(len);
-   out->len=len;
-   out->size=state.pcur;
+   out->len = len;
+   out->size = state.pcur;
 
-   entries=ARRPTR(out);
+   entries = ARRPTR(out);
    ptr = STRPTR(out);
 
-   for(i=0;isize;i++) {
+   for (i = 0; i < out->size; i++)
+   {
        entries[i].keylen = state.pairs[i].keylen;
        entries[i].pos = ptr - STRPTR(out);
        memcpy(ptr, state.pairs[i].key, state.pairs[i].keylen);
-       ptr+=entries[i].keylen;
+       ptr += entries[i].keylen;
 
        entries[i].valisnull = state.pairs[i].isnull;
-       if ( entries[i].valisnull )
-           entries[i].vallen=4; /* null */
-       else {
+       if (entries[i].valisnull)
+           entries[i].vallen = 4;      /* null */
+       else
+       {
            entries[i].vallen = state.pairs[i].vallen;
-           memcpy(ptr, state.pairs[i].val,state.pairs[i].vallen);
-           ptr+=entries[i].vallen;
+           memcpy(ptr, state.pairs[i].val, state.pairs[i].vallen);
+           ptr += entries[i].vallen;
        }
    }
 
@@ -308,63 +400,74 @@ hstore_in(PG_FUNCTION_ARGS) {
    PG_RETURN_POINTER(out);
 }
 
-static char*
-cpw(char *dst, char *src, int len) {
-   char *ptr = src;
+static char *
+cpw(char *dst, char *src, int len)
+{
+   char       *ptr = src;
 
-   while(ptr-src
-       if ( *ptr == '"' || *ptr == '\\' )
-           *dst++='\\';
+   while (ptr - src < len)
+   {
+       if (*ptr == '"' || *ptr == '\\')
+           *dst++ = '\\';
        *dst++ = *ptr++;
    }
    return dst;
 }
 
 PG_FUNCTION_INFO_V1(hstore_out);
-Datum           hstore_out(PG_FUNCTION_ARGS);
+Datum      hstore_out(PG_FUNCTION_ARGS);
 Datum
-hstore_out(PG_FUNCTION_ARGS) {
-   HStore *in = PG_GETARG_HS(0);
-   int buflen,i;
-   char *out,*ptr;
-   char *base = STRPTR(in);
-   HEntry  *entries = ARRPTR(in);
-
-   if ( in->size==0 ) {
-       out=palloc(1);
-       *out='\0';
-       PG_FREE_IF_COPY(in,0);
+hstore_out(PG_FUNCTION_ARGS)
+{
+   HStore     *in = PG_GETARG_HS(0);
+   int         buflen,
+               i;
+   char       *out,
+              *ptr;
+   char       *base = STRPTR(in);
+   HEntry     *entries = ARRPTR(in);
+
+   if (in->size == 0)
+   {
+       out = palloc(1);
+       *out = '\0';
+       PG_FREE_IF_COPY(in, 0);
        PG_RETURN_CSTRING(out);
    }
 
-   buflen = ( 4 /* " */ + 2 /* => */ + 2 /*, */ )*in->size + 
-       2 /* esc */ * ( in->len - CALCDATASIZE(in->size,0) );
-
-   out=ptr=palloc(buflen);
-   for(i=0;isize;i++) {
-       *ptr++='"';
-       ptr = cpw( ptr, base + entries[i].pos, entries[i].keylen );
-       *ptr++='"';
-       *ptr++='=';
-       *ptr++='>';
-       if ( entries[i].valisnull ) {
-           *ptr++='N';
-           *ptr++='U';
-           *ptr++='L';
-           *ptr++='L';
-       } else {
-           *ptr++='"';
-           ptr = cpw( ptr, base + entries[i].pos + entries[i].keylen, entries[i].vallen );
-           *ptr++='"';
+   buflen = (4 /* " */ + 2 /* => */ + 2 /* , */ ) * in->size +
+       2 /* esc */ * (in->len - CALCDATASIZE(in->size, 0));
+
+   out = ptr = palloc(buflen);
+   for (i = 0; i < in->size; i++)
+   {
+       *ptr++ = '"';
+       ptr = cpw(ptr, base + entries[i].pos, entries[i].keylen);
+       *ptr++ = '"';
+       *ptr++ = '=';
+       *ptr++ = '>';
+       if (entries[i].valisnull)
+       {
+           *ptr++ = 'N';
+           *ptr++ = 'U';
+           *ptr++ = 'L';
+           *ptr++ = 'L';
+       }
+       else
+       {
+           *ptr++ = '"';
+           ptr = cpw(ptr, base + entries[i].pos + entries[i].keylen, entries[i].vallen);
+           *ptr++ = '"';
        }
 
-       if ( i+1 != in->size ) {
-           *ptr++=',';
-           *ptr++=' ';
+       if (i + 1 != in->size)
+       {
+           *ptr++ = ',';
+           *ptr++ = ' ';
        }
    }
-   *ptr='\0';
+   *ptr = '\0';
 
-   PG_FREE_IF_COPY(in,0);
+   PG_FREE_IF_COPY(in, 0);
    PG_RETURN_CSTRING(out);
 }
index 12f783cb256c3ee21cf47484baf941a292fc9d29..971e93cf314c77ced41b12794eb71cc9ae99cf1a 100644 (file)
@@ -7,20 +7,22 @@
 
 
 static HEntry *
-findkey(HStore *hs, char *key, int keylen) {
-   HEntry *StopLow  = ARRPTR(hs);
-   HEntry *StopHigh = StopLow + hs->size;
-   HEntry  *StopMiddle;
-   int    difference;
-   char *base = STRPTR(hs);
-
-   while (StopLow < StopHigh) {
+findkey(HStore * hs, char *key, int keylen)
+{
+   HEntry     *StopLow = ARRPTR(hs);
+   HEntry     *StopHigh = StopLow + hs->size;
+   HEntry     *StopMiddle;
+   int         difference;
+   char       *base = STRPTR(hs);
+
+   while (StopLow < StopHigh)
+   {
        StopMiddle = StopLow + (StopHigh - StopLow) / 2;
 
-       if ( StopMiddle->keylen == keylen )
-           difference=strncmp(base+StopMiddle->pos, key, StopMiddle->keylen);
+       if (StopMiddle->keylen == keylen)
+           difference = strncmp(base + StopMiddle->pos, key, StopMiddle->keylen);
        else
-           difference=(StopMiddle->keylen > keylen) ? 1 : -1;
+           difference = (StopMiddle->keylen > keylen) ? 1 : -1;
 
        if (difference == 0)
            return StopMiddle;
@@ -29,520 +31,583 @@ findkey(HStore *hs, char *key, int keylen) {
        else
            StopHigh = StopMiddle;
    }
-       
+
    return NULL;
 }
 
 PG_FUNCTION_INFO_V1(fetchval);
-Datum           fetchval(PG_FUNCTION_ARGS);
+Datum      fetchval(PG_FUNCTION_ARGS);
 Datum
-fetchval(PG_FUNCTION_ARGS) {
-   HStore *hs  = PG_GETARG_HS(0);
-   text   *key = PG_GETARG_TEXT_P(1);
-   HEntry  *entry;
-   text *out;
-
-   if ((entry=findkey(hs,VARDATA(key), VARSIZE(key)-VARHDRSZ))==NULL || entry->valisnull) {
-       PG_FREE_IF_COPY(hs,0);
-       PG_FREE_IF_COPY(key,1);
+fetchval(PG_FUNCTION_ARGS)
+{
+   HStore     *hs = PG_GETARG_HS(0);
+   text       *key = PG_GETARG_TEXT_P(1);
+   HEntry     *entry;
+   text       *out;
+
+   if ((entry = findkey(hs, VARDATA(key), VARSIZE(key) - VARHDRSZ)) == NULL || entry->valisnull)
+   {
+       PG_FREE_IF_COPY(hs, 0);
+       PG_FREE_IF_COPY(key, 1);
        PG_RETURN_NULL();
    }
 
-   out=palloc(VARHDRSZ+entry->vallen);
-   memcpy(VARDATA(out),STRPTR(hs) + entry->pos + entry->keylen, entry->vallen);
-   VARATT_SIZEP(out) = VARHDRSZ+entry->vallen;
+   out = palloc(VARHDRSZ + entry->vallen);
+   memcpy(VARDATA(out), STRPTR(hs) + entry->pos + entry->keylen, entry->vallen);
+   VARATT_SIZEP(out) = VARHDRSZ + entry->vallen;
 
-   PG_FREE_IF_COPY(hs,0);
-   PG_FREE_IF_COPY(key,1);
+   PG_FREE_IF_COPY(hs, 0);
+   PG_FREE_IF_COPY(key, 1);
    PG_RETURN_POINTER(out);
 }
 
 PG_FUNCTION_INFO_V1(exists);
-Datum           exists(PG_FUNCTION_ARGS);
+Datum      exists(PG_FUNCTION_ARGS);
 Datum
-exists(PG_FUNCTION_ARGS) {
-   HStore *hs  = PG_GETARG_HS(0);
-   text   *key = PG_GETARG_TEXT_P(1);
-   HEntry  *entry;
+exists(PG_FUNCTION_ARGS)
+{
+   HStore     *hs = PG_GETARG_HS(0);
+   text       *key = PG_GETARG_TEXT_P(1);
+   HEntry     *entry;
 
-   entry=findkey(hs,VARDATA(key), VARSIZE(key)-VARHDRSZ);
+   entry = findkey(hs, VARDATA(key), VARSIZE(key) - VARHDRSZ);
 
-   PG_FREE_IF_COPY(hs,0);
-   PG_FREE_IF_COPY(key,1);
+   PG_FREE_IF_COPY(hs, 0);
+   PG_FREE_IF_COPY(key, 1);
 
    PG_RETURN_BOOL(entry);
 }
 
 PG_FUNCTION_INFO_V1(defined);
-Datum           defined(PG_FUNCTION_ARGS);
+Datum      defined(PG_FUNCTION_ARGS);
 Datum
-defined(PG_FUNCTION_ARGS) {
-   HStore *hs  = PG_GETARG_HS(0);
-   text   *key = PG_GETARG_TEXT_P(1);
-   HEntry  *entry;
-   bool res;
+defined(PG_FUNCTION_ARGS)
+{
+   HStore     *hs = PG_GETARG_HS(0);
+   text       *key = PG_GETARG_TEXT_P(1);
+   HEntry     *entry;
+   bool        res;
 
-   entry=findkey(hs,VARDATA(key), VARSIZE(key)-VARHDRSZ);
+   entry = findkey(hs, VARDATA(key), VARSIZE(key) - VARHDRSZ);
 
-   res = ( entry && !entry->valisnull ) ? true : false;
+   res = (entry && !entry->valisnull) ? true : false;
 
-   PG_FREE_IF_COPY(hs,0);
-   PG_FREE_IF_COPY(key,1);
+   PG_FREE_IF_COPY(hs, 0);
+   PG_FREE_IF_COPY(key, 1);
 
    PG_RETURN_BOOL(res);
 }
 
 PG_FUNCTION_INFO_V1(delete);
-Datum           delete(PG_FUNCTION_ARGS);
+Datum      delete(PG_FUNCTION_ARGS);
 Datum
-delete(PG_FUNCTION_ARGS) {
-   HStore *hs  = PG_GETARG_HS(0);
-   text   *key = PG_GETARG_TEXT_P(1);
-   HStore *out = palloc(hs->len);
-   char *ptrs, *ptrd;
-   HEntry  *es, *ed;
-
-   out->len=hs->len;
-   out->size=hs->size; /* temprorary! */
-
-   ptrs=STRPTR(hs);
-   es  =ARRPTR(hs);
-   ptrd=STRPTR(out);
-   ed  =ARRPTR(out);
-
-   while( es - ARRPTR(hs) < hs->size ) { 
-       if ( !(es->keylen == VARSIZE(key) - VARHDRSZ && strncmp(ptrs, VARDATA(key), es->keylen)==0) ) {
-           memcpy( ed, es, sizeof(HEntry) );
-           memcpy( ptrd, ptrs, es->keylen + ( (es->valisnull) ? 0 : es->vallen ) );
+delete(PG_FUNCTION_ARGS)
+{
+   HStore     *hs = PG_GETARG_HS(0);
+   text       *key = PG_GETARG_TEXT_P(1);
+   HStore     *out = palloc(hs->len);
+   char       *ptrs,
+              *ptrd;
+   HEntry     *es,
+              *ed;
+
+   out->len = hs->len;
+   out->size = hs->size;       /* temprorary! */
+
+   ptrs = STRPTR(hs);
+   es = ARRPTR(hs);
+   ptrd = STRPTR(out);
+   ed = ARRPTR(out);
+
+   while (es - ARRPTR(hs) < hs->size)
+   {
+       if (!(es->keylen == VARSIZE(key) - VARHDRSZ && strncmp(ptrs, VARDATA(key), es->keylen) == 0))
+       {
+           memcpy(ed, es, sizeof(HEntry));
+           memcpy(ptrd, ptrs, es->keylen + ((es->valisnull) ? 0 : es->vallen));
            ed->pos = ptrd - STRPTR(out);
-           ptrd += es->keylen + ( (es->valisnull) ? 0 : es->vallen );
+           ptrd += es->keylen + ((es->valisnull) ? 0 : es->vallen);
            ed++;
        }
-       ptrs += es->keylen + ( (es->valisnull) ? 0 : es->vallen );
+       ptrs += es->keylen + ((es->valisnull) ? 0 : es->vallen);
        es++;
    }
 
-   if ( ed - ARRPTR(out) != out->size ) {
-       int buflen=ptrd-STRPTR(out);
+   if (ed - ARRPTR(out) != out->size)
+   {
+       int         buflen = ptrd - STRPTR(out);
+
        ptrd = STRPTR(out);
 
        out->size = ed - ARRPTR(out);
 
-       memmove( STRPTR(out), ptrd, buflen);
+       memmove(STRPTR(out), ptrd, buflen);
        out->len = CALCDATASIZE(out->size, buflen);
    }
-       
 
-   PG_FREE_IF_COPY(hs,0);
-   PG_FREE_IF_COPY(key,1);
+
+   PG_FREE_IF_COPY(hs, 0);
+   PG_FREE_IF_COPY(key, 1);
 
    PG_RETURN_POINTER(out);
 }
 
 PG_FUNCTION_INFO_V1(hs_concat);
-Datum           hs_concat(PG_FUNCTION_ARGS);
+Datum      hs_concat(PG_FUNCTION_ARGS);
 Datum
-hs_concat(PG_FUNCTION_ARGS) {
-   HStore *s1  = PG_GETARG_HS(0);
-   HStore *s2  = PG_GETARG_HS(1);
-   HStore *out = palloc( s1->len + s2->len );
-   char *ps1, *ps2, *pd;
-   HEntry *es1, *es2, *ed;
+hs_concat(PG_FUNCTION_ARGS)
+{
+   HStore     *s1 = PG_GETARG_HS(0);
+   HStore     *s2 = PG_GETARG_HS(1);
+   HStore     *out = palloc(s1->len + s2->len);
+   char       *ps1,
+              *ps2,
+              *pd;
+   HEntry     *es1,
+              *es2,
+              *ed;
 
    out->len = s1->len + s2->len;
    out->size = s1->size + s2->size;
 
-   ps1=STRPTR(s1);
-   ps2=STRPTR(s2);
-   pd=STRPTR(out);
-   es1=ARRPTR(s1);
-   es2=ARRPTR(s2);
-   ed=ARRPTR(out);
-
-   while( es1 - ARRPTR(s1) < s1->size && es2 - ARRPTR(s2) < s2->size ) {
-       int difference;
-       if ( es1->keylen == es2->keylen )
-           difference=strncmp(ps1, ps2, es1->keylen);
+   ps1 = STRPTR(s1);
+   ps2 = STRPTR(s2);
+   pd = STRPTR(out);
+   es1 = ARRPTR(s1);
+   es2 = ARRPTR(s2);
+   ed = ARRPTR(out);
+
+   while (es1 - ARRPTR(s1) < s1->size && es2 - ARRPTR(s2) < s2->size)
+   {
+       int         difference;
+
+       if (es1->keylen == es2->keylen)
+           difference = strncmp(ps1, ps2, es1->keylen);
        else
-           difference=(es1->keylen > es2->keylen) ? 1 : -1;
+           difference = (es1->keylen > es2->keylen) ? 1 : -1;
 
-       if ( difference == 0 ) {
-           memcpy( ed, es2, sizeof(HEntry) );
-           memcpy( pd, ps2, es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen ) );
+       if (difference == 0)
+       {
+           memcpy(ed, es2, sizeof(HEntry));
+           memcpy(pd, ps2, es2->keylen + ((es2->valisnull) ? 0 : es2->vallen));
            ed->pos = pd - STRPTR(out);
-           pd += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+           pd += es2->keylen + ((es2->valisnull) ? 0 : es2->vallen);
            ed++;
-           
-           ps1 += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+
+           ps1 += es1->keylen + ((es1->valisnull) ? 0 : es1->vallen);
            es1++;
-           ps2 += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+           ps2 += es2->keylen + ((es2->valisnull) ? 0 : es2->vallen);
            es2++;
-       } else if ( difference > 0 ) {
-           memcpy( ed, es2, sizeof(HEntry) );
-           memcpy( pd, ps2, es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen ) );
+       }
+       else if (difference > 0)
+       {
+           memcpy(ed, es2, sizeof(HEntry));
+           memcpy(pd, ps2, es2->keylen + ((es2->valisnull) ? 0 : es2->vallen));
            ed->pos = pd - STRPTR(out);
-           pd += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+           pd += es2->keylen + ((es2->valisnull) ? 0 : es2->vallen);
            ed++;
-           
-           ps2 += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+
+           ps2 += es2->keylen + ((es2->valisnull) ? 0 : es2->vallen);
            es2++;
-       } else {
-           memcpy( ed, es1, sizeof(HEntry) );
-           memcpy( pd, ps1, es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen ) );
+       }
+       else
+       {
+           memcpy(ed, es1, sizeof(HEntry));
+           memcpy(pd, ps1, es1->keylen + ((es1->valisnull) ? 0 : es1->vallen));
            ed->pos = pd - STRPTR(out);
-           pd += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+           pd += es1->keylen + ((es1->valisnull) ? 0 : es1->vallen);
            ed++;
-           
-           ps1 += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+
+           ps1 += es1->keylen + ((es1->valisnull) ? 0 : es1->vallen);
            es1++;
        }
    }
 
-   while( es1 - ARRPTR(s1) < s1->size ) {
-       memcpy( ed, es1, sizeof(HEntry) );
-       memcpy( pd, ps1, es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen ) );
+   while (es1 - ARRPTR(s1) < s1->size)
+   {
+       memcpy(ed, es1, sizeof(HEntry));
+       memcpy(pd, ps1, es1->keylen + ((es1->valisnull) ? 0 : es1->vallen));
        ed->pos = pd - STRPTR(out);
-       pd += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+       pd += es1->keylen + ((es1->valisnull) ? 0 : es1->vallen);
        ed++;
-           
-       ps1 += es1->keylen + ( (es1->valisnull) ? 0 : es1->vallen );
+
+       ps1 += es1->keylen + ((es1->valisnull) ? 0 : es1->vallen);
        es1++;
    }
 
-   while( es2 - ARRPTR(s2) < s2->size ) {
-       memcpy( ed, es2, sizeof(HEntry) );
-       memcpy( pd, ps2, es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen ) );
+   while (es2 - ARRPTR(s2) < s2->size)
+   {
+       memcpy(ed, es2, sizeof(HEntry));
+       memcpy(pd, ps2, es2->keylen + ((es2->valisnull) ? 0 : es2->vallen));
        ed->pos = pd - STRPTR(out);
-       pd += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+       pd += es2->keylen + ((es2->valisnull) ? 0 : es2->vallen);
        ed++;
-       
-       ps2 += es2->keylen + ( (es2->valisnull) ? 0 : es2->vallen );
+
+       ps2 += es2->keylen + ((es2->valisnull) ? 0 : es2->vallen);
        es2++;
    }
 
-   if ( ed - ARRPTR(out) != out->size ) {
-       int buflen=pd-STRPTR(out);
+   if (ed - ARRPTR(out) != out->size)
+   {
+       int         buflen = pd - STRPTR(out);
+
        pd = STRPTR(out);
 
        out->size = ed - ARRPTR(out);
 
-       memmove( STRPTR(out), pd, buflen);
+       memmove(STRPTR(out), pd, buflen);
        out->len = CALCDATASIZE(out->size, buflen);
    }
-       
-   PG_FREE_IF_COPY(s1,0);
-   PG_FREE_IF_COPY(s2,1);
+
+   PG_FREE_IF_COPY(s1, 0);
+   PG_FREE_IF_COPY(s2, 1);
 
    PG_RETURN_POINTER(out);
 }
 
 PG_FUNCTION_INFO_V1(tconvert);
-Datum           tconvert(PG_FUNCTION_ARGS);
+Datum      tconvert(PG_FUNCTION_ARGS);
 Datum
-tconvert(PG_FUNCTION_ARGS) {
-   text   *key = PG_GETARG_TEXT_P(0);
-   text   *val = PG_GETARG_TEXT_P(1);
-   int len;
-   HStore  *out;
-
-   len=CALCDATASIZE(1, VARSIZE(key) + VARSIZE(val) - 2*VARHDRSZ);
+tconvert(PG_FUNCTION_ARGS)
+{
+   text       *key = PG_GETARG_TEXT_P(0);
+   text       *val = PG_GETARG_TEXT_P(1);
+   int         len;
+   HStore     *out;
+
+   len = CALCDATASIZE(1, VARSIZE(key) + VARSIZE(val) - 2 * VARHDRSZ);
    out = palloc(len);
-   out->len=len;
-   out->size=1;
+   out->len = len;
+   out->size = 1;
 
    ARRPTR(out)->keylen = VARSIZE(key) - VARHDRSZ;
    ARRPTR(out)->vallen = VARSIZE(val) - VARHDRSZ;
    ARRPTR(out)->valisnull = false;
-   ARRPTR(out)->pos=0;
+   ARRPTR(out)->pos = 0;
 
-   memcpy( STRPTR(out), VARDATA(key), ARRPTR(out)->keylen );
-   memcpy( STRPTR(out) + ARRPTR(out)->keylen, VARDATA(val), ARRPTR(out)->vallen );
-       
-   PG_FREE_IF_COPY(key,0);
-   PG_FREE_IF_COPY(val,1);
+   memcpy(STRPTR(out), VARDATA(key), ARRPTR(out)->keylen);
+   memcpy(STRPTR(out) + ARRPTR(out)->keylen, VARDATA(val), ARRPTR(out)->vallen);
+
+   PG_FREE_IF_COPY(key, 0);
+   PG_FREE_IF_COPY(val, 1);
 
    PG_RETURN_POINTER(out);
 }
 
 PG_FUNCTION_INFO_V1(akeys);
-Datum           akeys(PG_FUNCTION_ARGS);
+Datum      akeys(PG_FUNCTION_ARGS);
 Datum
-akeys(PG_FUNCTION_ARGS) { 
-   HStore *hs  = PG_GETARG_HS(0);
-   Datum   *d;
-   ArrayType *a;
-   HEntry *ptr=ARRPTR(hs);
-   char *base=STRPTR(hs);
-
-   d=(Datum*)palloc(sizeof(Datum)*(hs->size+1));
-   while( ptr-ARRPTR(hs) < hs->size ) {
-       text *item=(text*)palloc(VARHDRSZ + ptr->keylen);
-       VARATT_SIZEP(item) = VARHDRSZ+ptr->keylen;
+akeys(PG_FUNCTION_ARGS)
+{
+   HStore     *hs = PG_GETARG_HS(0);
+   Datum      *d;
+   ArrayType  *a;
+   HEntry     *ptr = ARRPTR(hs);
+   char       *base = STRPTR(hs);
+
+   d = (Datum *) palloc(sizeof(Datum) * (hs->size + 1));
+   while (ptr - ARRPTR(hs) < hs->size)
+   {
+       text       *item = (text *) palloc(VARHDRSZ + ptr->keylen);
+
+       VARATT_SIZEP(item) = VARHDRSZ + ptr->keylen;
        memcpy(VARDATA(item), base + ptr->pos, ptr->keylen);
-       d[ ptr-ARRPTR(hs) ] = PointerGetDatum(item);
+       d[ptr - ARRPTR(hs)] = PointerGetDatum(item);
        ptr++;
    }
-   
+
    a = construct_array(
-       d,
-       hs->size,
-       TEXTOID,
-       -1,
-       false,
-       'i'
-   );
-
-   ptr=ARRPTR(hs);
-   while( ptr-ARRPTR(hs) < hs->size ) {
-       pfree(DatumGetPointer(d[ ptr-ARRPTR(hs) ]));
+                       d,
+                       hs->size,
+                       TEXTOID,
+                       -1,
+                       false,
+                       'i'
+       );
+
+   ptr = ARRPTR(hs);
+   while (ptr - ARRPTR(hs) < hs->size)
+   {
+       pfree(DatumGetPointer(d[ptr - ARRPTR(hs)]));
        ptr++;
    }
 
    pfree(d);
-   PG_FREE_IF_COPY(hs,0);
+   PG_FREE_IF_COPY(hs, 0);
 
    PG_RETURN_POINTER(a);
 }
 
 PG_FUNCTION_INFO_V1(avals);
-Datum           avals(PG_FUNCTION_ARGS);
+Datum      avals(PG_FUNCTION_ARGS);
 Datum
-avals(PG_FUNCTION_ARGS) { 
-   HStore *hs  = PG_GETARG_HS(0);
-   Datum   *d;
-   ArrayType *a;
-   HEntry *ptr=ARRPTR(hs);
-   char *base=STRPTR(hs);
-
-   d=(Datum*)palloc(sizeof(Datum)*(hs->size+1));
-   while( ptr-ARRPTR(hs) < hs->size ) {
-       int vallen = (ptr->valisnull) ? 0 : ptr->vallen; 
-       text *item=(text*)palloc(VARHDRSZ + vallen);
-       VARATT_SIZEP(item) = VARHDRSZ+vallen;
+avals(PG_FUNCTION_ARGS)
+{
+   HStore     *hs = PG_GETARG_HS(0);
+   Datum      *d;
+   ArrayType  *a;
+   HEntry     *ptr = ARRPTR(hs);
+   char       *base = STRPTR(hs);
+
+   d = (Datum *) palloc(sizeof(Datum) * (hs->size + 1));
+   while (ptr - ARRPTR(hs) < hs->size)
+   {
+       int         vallen = (ptr->valisnull) ? 0 : ptr->vallen;
+       text       *item = (text *) palloc(VARHDRSZ + vallen);
+
+       VARATT_SIZEP(item) = VARHDRSZ + vallen;
        memcpy(VARDATA(item), base + ptr->pos + ptr->keylen, vallen);
-       d[ ptr-ARRPTR(hs) ] = PointerGetDatum(item);
+       d[ptr - ARRPTR(hs)] = PointerGetDatum(item);
        ptr++;
    }
-   
+
    a = construct_array(
-       d,
-       hs->size,
-       TEXTOID,
-       -1,
-       false,
-       'i'
-   );
-
-   ptr=ARRPTR(hs);
-   while( ptr-ARRPTR(hs) < hs->size ) {
-       pfree(DatumGetPointer(d[ ptr-ARRPTR(hs) ]));
+                       d,
+                       hs->size,
+                       TEXTOID,
+                       -1,
+                       false,
+                       'i'
+       );
+
+   ptr = ARRPTR(hs);
+   while (ptr - ARRPTR(hs) < hs->size)
+   {
+       pfree(DatumGetPointer(d[ptr - ARRPTR(hs)]));
        ptr++;
    }
 
    pfree(d);
-   PG_FREE_IF_COPY(hs,0);
+   PG_FREE_IF_COPY(hs, 0);
 
    PG_RETURN_POINTER(a);
 }
 
-typedef struct {
-   HStore  *hs;
-   int     i;
-} AKStore;
+typedef struct
+{
+   HStore     *hs;
+   int         i;
+}  AKStore;
 
 static void
-setup_firstcall(FuncCallContext  *funcctx, HStore *hs) {
-   MemoryContext     oldcontext;
-   AKStore     *st;
+setup_firstcall(FuncCallContext *funcctx, HStore * hs)
+{
+   MemoryContext oldcontext;
+   AKStore    *st;
 
    oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
-   st=(AKStore*)palloc( sizeof(AKStore) );
-   st->i=0;
-   st->hs = (HStore*)palloc(hs->len);
-   memcpy( st->hs, hs, hs->len );
+   st = (AKStore *) palloc(sizeof(AKStore));
+   st->i = 0;
+   st->hs = (HStore *) palloc(hs->len);
+   memcpy(st->hs, hs, hs->len);
 
-   funcctx->user_fctx = (void*)st;
+   funcctx->user_fctx = (void *) st;
    MemoryContextSwitchTo(oldcontext);
 }
 
 PG_FUNCTION_INFO_V1(skeys);
-Datum           skeys(PG_FUNCTION_ARGS);
+Datum      skeys(PG_FUNCTION_ARGS);
 Datum
-skeys(PG_FUNCTION_ARGS) {
-   FuncCallContext  *funcctx;
-   AKStore *st;
+skeys(PG_FUNCTION_ARGS)
+{
+   FuncCallContext *funcctx;
+   AKStore    *st;
+
+   if (SRF_IS_FIRSTCALL())
+   {
+       HStore     *hs = PG_GETARG_HS(0);
 
-   if (SRF_IS_FIRSTCALL()) {
-       HStore *hs = PG_GETARG_HS(0);
        funcctx = SRF_FIRSTCALL_INIT();
        setup_firstcall(funcctx, hs);
-       PG_FREE_IF_COPY(hs,0);
+       PG_FREE_IF_COPY(hs, 0);
    }
 
    funcctx = SRF_PERCALL_SETUP();
-   st = (AKStore*)funcctx->user_fctx;
-   
-   if ( st->i < st->hs->size ) {
-       HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
-       text *item=(text*)palloc(VARHDRSZ + ptr->keylen);
+   st = (AKStore *) funcctx->user_fctx;
+
+   if (st->i < st->hs->size)
+   {
+       HEntry     *ptr = &(ARRPTR(st->hs)[st->i]);
+       text       *item = (text *) palloc(VARHDRSZ + ptr->keylen);
 
-       VARATT_SIZEP(item) = VARHDRSZ+ptr->keylen;
+       VARATT_SIZEP(item) = VARHDRSZ + ptr->keylen;
        memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos, ptr->keylen);
        st->i++;
 
        SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
    }
-   
-   pfree( st->hs );
-   pfree( st );
 
-   SRF_RETURN_DONE(funcctx); 
+   pfree(st->hs);
+   pfree(st);
+
+   SRF_RETURN_DONE(funcctx);
 }
 
 PG_FUNCTION_INFO_V1(svals);
-Datum           svals(PG_FUNCTION_ARGS);
+Datum      svals(PG_FUNCTION_ARGS);
 Datum
-svals(PG_FUNCTION_ARGS) {
-   FuncCallContext  *funcctx;
-   AKStore *st;
+svals(PG_FUNCTION_ARGS)
+{
+   FuncCallContext *funcctx;
+   AKStore    *st;
+
+   if (SRF_IS_FIRSTCALL())
+   {
+       HStore     *hs = PG_GETARG_HS(0);
 
-   if (SRF_IS_FIRSTCALL()) {
-       HStore *hs = PG_GETARG_HS(0);
        funcctx = SRF_FIRSTCALL_INIT();
        setup_firstcall(funcctx, hs);
-       PG_FREE_IF_COPY(hs,0);
+       PG_FREE_IF_COPY(hs, 0);
    }
 
    funcctx = SRF_PERCALL_SETUP();
-   st = (AKStore*)funcctx->user_fctx;
-   
-   if ( st->i < st->hs->size ) {
-       HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
+   st = (AKStore *) funcctx->user_fctx;
 
-       if ( ptr->valisnull ) {
-           ReturnSetInfo      *rsi;
+   if (st->i < st->hs->size)
+   {
+       HEntry     *ptr = &(ARRPTR(st->hs)[st->i]);
+
+       if (ptr->valisnull)
+       {
+           ReturnSetInfo *rsi;
 
            st->i++;
            (funcctx)->call_cntr++;
            rsi = (ReturnSetInfo *) fcinfo->resultinfo;
            rsi->isDone = ExprMultipleResult;
            PG_RETURN_NULL();
-       } else {
-           int vallen = ptr->vallen; 
-           text *item=(text*)palloc(VARHDRSZ + vallen);
+       }
+       else
+       {
+           int         vallen = ptr->vallen;
+           text       *item = (text *) palloc(VARHDRSZ + vallen);
 
-           VARATT_SIZEP(item) = VARHDRSZ+vallen;
+           VARATT_SIZEP(item) = VARHDRSZ + vallen;
            memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos + ptr->keylen, vallen);
            st->i++;
 
            SRF_RETURN_NEXT(funcctx, PointerGetDatum(item));
        }
    }
-   
-   pfree( st->hs );
-   pfree( st );
 
-   SRF_RETURN_DONE(funcctx); 
+   pfree(st->hs);
+   pfree(st);
+
+   SRF_RETURN_DONE(funcctx);
 }
 
 PG_FUNCTION_INFO_V1(hs_contains);
-Datum           hs_contains(PG_FUNCTION_ARGS);
+Datum      hs_contains(PG_FUNCTION_ARGS);
 Datum
-hs_contains(PG_FUNCTION_ARGS) {
-   HStore *val   = PG_GETARG_HS(0);
-   HStore *tmpl  = PG_GETARG_HS(1);
-   bool res = true;
-   HEntry  *te = ARRPTR(tmpl);
-   char    *vv = STRPTR(val);
-   char    *tv = STRPTR(tmpl);
-
-   while(res && te-ARRPTR(tmpl) < tmpl->size) {
-       HEntry *entry = findkey(val, tv + te->pos, te->keylen);
-       if ( entry ) {
-           if ( ! te->valisnull ) {
-               if ( entry->valisnull || !(
-                       te->vallen==entry->vallen && 
-                       strncmp( 
-                           vv + entry->pos + entry->keylen, 
-                           tv + te->pos + te->keylen, 
-                       te->vallen ) == 0
-                   ) )
-                   res=false;
+hs_contains(PG_FUNCTION_ARGS)
+{
+   HStore     *val = PG_GETARG_HS(0);
+   HStore     *tmpl = PG_GETARG_HS(1);
+   bool        res = true;
+   HEntry     *te = ARRPTR(tmpl);
+   char       *vv = STRPTR(val);
+   char       *tv = STRPTR(tmpl);
+
+   while (res && te - ARRPTR(tmpl) < tmpl->size)
+   {
+       HEntry     *entry = findkey(val, tv + te->pos, te->keylen);
+
+       if (entry)
+       {
+           if (!te->valisnull)
+           {
+               if (entry->valisnull || !(
+                                         te->vallen == entry->vallen &&
+                                         strncmp(
+                                            vv + entry->pos + entry->keylen,
+                                                 tv + te->pos + te->keylen,
+                                                 te->vallen) == 0
+                                         ))
+                   res = false;
            }
-       } else
+       }
+       else
            res = false;
        te++;
    }
 
-   PG_FREE_IF_COPY(val,0);
-   PG_FREE_IF_COPY(tmpl,1);
+   PG_FREE_IF_COPY(val, 0);
+   PG_FREE_IF_COPY(tmpl, 1);
 
    PG_RETURN_BOOL(res);
 }
-   
+
 PG_FUNCTION_INFO_V1(hs_contained);
-Datum           hs_contained(PG_FUNCTION_ARGS);
+Datum      hs_contained(PG_FUNCTION_ARGS);
 Datum
-hs_contained(PG_FUNCTION_ARGS) {
-   PG_RETURN_DATUM( DirectFunctionCall2(
-       hs_contains,
-       PG_GETARG_DATUM(1),
-       PG_GETARG_DATUM(0)
-   ));
+hs_contained(PG_FUNCTION_ARGS)
+{
+   PG_RETURN_DATUM(DirectFunctionCall2(
+                                       hs_contains,
+                                       PG_GETARG_DATUM(1),
+                                       PG_GETARG_DATUM(0)
+                                       ));
 }
 
 PG_FUNCTION_INFO_V1(each);
-Datum           each(PG_FUNCTION_ARGS);
+Datum      each(PG_FUNCTION_ARGS);
 Datum
-each(PG_FUNCTION_ARGS) {
-   FuncCallContext  *funcctx;
-   AKStore *st;
+each(PG_FUNCTION_ARGS)
+{
+   FuncCallContext *funcctx;
+   AKStore    *st;
 
-   if (SRF_IS_FIRSTCALL()) {
-       TupleDesc            tupdesc;
-       MemoryContext     oldcontext;
-       HStore *hs = PG_GETARG_HS(0);
+   if (SRF_IS_FIRSTCALL())
+   {
+       TupleDesc   tupdesc;
+       MemoryContext oldcontext;
+       HStore     *hs = PG_GETARG_HS(0);
 
        funcctx = SRF_FIRSTCALL_INIT();
        oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
-       st=(AKStore*)palloc( sizeof(AKStore) );
-       st->i=0;
-       st->hs = (HStore*)palloc(hs->len);
-       memcpy( st->hs, hs, hs->len );
-       funcctx->user_fctx = (void*)st;     
-           
+       st = (AKStore *) palloc(sizeof(AKStore));
+       st->i = 0;
+       st->hs = (HStore *) palloc(hs->len);
+       memcpy(st->hs, hs, hs->len);
+       funcctx->user_fctx = (void *) st;
+
        tupdesc = RelationNameGetTupleDesc("hs_each");
        funcctx->slot = TupleDescGetSlot(tupdesc);
        funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc);
 
        MemoryContextSwitchTo(oldcontext);
-       PG_FREE_IF_COPY(hs,0);
+       PG_FREE_IF_COPY(hs, 0);
    }
 
    funcctx = SRF_PERCALL_SETUP();
-   st = (AKStore*)funcctx->user_fctx;
-   
-   if ( st->i < st->hs->size ) {
-       HEntry *ptr = &(ARRPTR(st->hs)[st->i]);
-       Datum res, dvalues[2];
-       char       nulls[] = {' ', ' '};
-       text *item;
-       HeapTuple       tuple;
-
-       item=(text*)palloc(VARHDRSZ + ptr->keylen);
-       VARATT_SIZEP(item) = VARHDRSZ+ptr->keylen;
+   st = (AKStore *) funcctx->user_fctx;
+
+   if (st->i < st->hs->size)
+   {
+       HEntry     *ptr = &(ARRPTR(st->hs)[st->i]);
+       Datum       res,
+                   dvalues[2];
+       char        nulls[] = {' ', ' '};
+       text       *item;
+       HeapTuple   tuple;
+
+       item = (text *) palloc(VARHDRSZ + ptr->keylen);
+       VARATT_SIZEP(item) = VARHDRSZ + ptr->keylen;
        memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos, ptr->keylen);
        dvalues[0] = PointerGetDatum(item);
 
-       if ( ptr->valisnull ) {
-           dvalues[1]=(Datum)0;
-           nulls[1]='n';
-       } else {
-           int vallen = ptr->vallen; 
+       if (ptr->valisnull)
+       {
+           dvalues[1] = (Datum) 0;
+           nulls[1] = 'n';
+       }
+       else
+       {
+           int         vallen = ptr->vallen;
 
-           item=(text*)palloc(VARHDRSZ + vallen);
-           VARATT_SIZEP(item) = VARHDRSZ+vallen;
+           item = (text *) palloc(VARHDRSZ + vallen);
+           VARATT_SIZEP(item) = VARHDRSZ + vallen;
            memcpy(VARDATA(item), STRPTR(st->hs) + ptr->pos + ptr->keylen, vallen);
            dvalues[1] = PointerGetDatum(item);
        }
@@ -551,17 +616,15 @@ each(PG_FUNCTION_ARGS) {
        tuple = heap_formtuple(funcctx->attinmeta->tupdesc, dvalues, nulls);
        res = TupleGetDatum(funcctx->slot, tuple);
 
-       pfree( DatumGetPointer(dvalues[0]) );
-       if ( nulls[1] != 'n' ) 
-           pfree( DatumGetPointer(dvalues[1]) );
+       pfree(DatumGetPointer(dvalues[0]));
+       if (nulls[1] != 'n')
+           pfree(DatumGetPointer(dvalues[1]));
 
        SRF_RETURN_NEXT(funcctx, PointerGetDatum(res));
    }
-   
-   pfree( st->hs );
-   pfree( st );
-
-   SRF_RETURN_DONE(funcctx); 
-}
 
+   pfree(st->hs);
+   pfree(st);
 
+   SRF_RETURN_DONE(funcctx);
+}
index f40dc06a92c150a7cd9c08da55a985efd3c3c5e1..bf10f109220d5d68f9a6f6d888799ee2f7c9c861 100644 (file)
@@ -154,17 +154,17 @@ typedef struct
 #define COMPUTESIZE(size)  ( HDRSIZEQT + size * sizeof(ITEM) )
 #define GETQUERY(x)  (ITEM*)( (char*)(x)+HDRSIZEQT )
 
-#define END     0
-#define ERR     1
-#define VAL     2
-#define OPR     3
-#define OPEN    4
-#define CLOSE   5
+#define END        0
+#define ERR        1
+#define VAL        2
+#define OPR        3
+#define OPEN   4
+#define CLOSE  5
 
 bool       signconsistent(QUERYTYPE * query, BITVEC sign, bool calcnot);
 bool       execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot);
-bool       ginconsistent(QUERYTYPE * query, bool *check);
-int4       shorterquery(ITEM * q, int4 len);
+bool       ginconsistent(QUERYTYPE * query, bool *check);
+int4       shorterquery(ITEM * q, int4 len);
 
 int            compASC(const void *a, const void *b);
 
index 230c412a0486ac55fa06462cfab92323c6428094..8517010e5ed28a364afe785598f1a1917842a8c5 100644 (file)
@@ -232,7 +232,7 @@ typedef struct
  * is there value 'val' in array or not ?
  */
 static bool
-checkcondition_arr(void *checkval, ITEM *item)
+checkcondition_arr(void *checkval, ITEM * item)
 {
    int4       *StopLow = ((CHKVAL *) checkval)->arrb;
    int4       *StopHigh = ((CHKVAL *) checkval)->arre;
@@ -254,7 +254,7 @@ checkcondition_arr(void *checkval, ITEM *item)
 }
 
 static bool
-checkcondition_bit(void *checkval, ITEM *item)
+checkcondition_bit(void *checkval, ITEM * item)
 {
    return GETBIT(checkval, HASHVAL(item->val));
 }
@@ -263,7 +263,7 @@ checkcondition_bit(void *checkval, ITEM *item)
  * check for boolean condition
  */
 static bool
-execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM *item))
+execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * item))
 {
 
    if (curitem->type == VAL)
@@ -319,38 +319,42 @@ execconsistent(QUERYTYPE * query, ArrayType *array, bool calcnot)
        );
 }
 
-typedef struct {
-   ITEM    *first;
-   bool    *mapped_check;
-} GinChkVal;
+typedef struct
+{
+   ITEM       *first;
+   bool       *mapped_check;
+}  GinChkVal;
 
 static bool
-checkcondition_gin(void *checkval, ITEM *item) {
-   GinChkVal   *gcv = (GinChkVal*)checkval;
+checkcondition_gin(void *checkval, ITEM * item)
+{
+   GinChkVal  *gcv = (GinChkVal *) checkval;
 
-   return gcv->mapped_check[ item - gcv->first ];
+   return gcv->mapped_check[item - gcv->first];
 }
 
 bool
-ginconsistent(QUERYTYPE * query, bool *check) {
-   GinChkVal   gcv;
-   ITEM    *items = GETQUERY(query);
-   int i, j=0;
+ginconsistent(QUERYTYPE * query, bool *check)
+{
+   GinChkVal   gcv;
+   ITEM       *items = GETQUERY(query);
+   int         i,
+               j = 0;
 
-   if ( query->size < 0 )
+   if (query->size < 0)
        return FALSE;
 
    gcv.first = items;
-   gcv.mapped_check = (bool*)palloc( sizeof(bool)*query->size );
-   for(i=0; i<query->size; i++)
-       if ( items[i].type == VAL ) 
-           gcv.mapped_check[ i ] = check[ j++ ];
-
-   return execute( 
-       GETQUERY(query) + query->size - 1,
-       (void *) &gcv, true,
-       checkcondition_gin
-   );
+   gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size);
+   for (i = 0; i < query->size; i++)
+       if (items[i].type == VAL)
+           gcv.mapped_check[i] = check[j++];
+
+   return execute(
+                  GETQUERY(query) + query->size - 1,
+                  (void *) &gcv, true,
+                  checkcondition_gin
+       );
 }
 
 /*
index 2a2830e578ddf58af5db5ff002416d9b0939efb2..7bb9599b3350b176a3550b9ea3faff7843fb81d2 100644 (file)
 #include "_int.h"
 
 PG_FUNCTION_INFO_V1(ginint4_queryextract);
-Datum ginint4_queryextract(PG_FUNCTION_ARGS);
+Datum      ginint4_queryextract(PG_FUNCTION_ARGS);
 
 Datum
-ginint4_queryextract(PG_FUNCTION_ARGS) {
-   uint32  *nentries = (uint32*)PG_GETARG_POINTER(1);
-   StrategyNumber  strategy = PG_GETARG_UINT16(2);
-   Datum   *res = NULL;
-   
+ginint4_queryextract(PG_FUNCTION_ARGS)
+{
+   uint32     *nentries = (uint32 *) PG_GETARG_POINTER(1);
+   StrategyNumber strategy = PG_GETARG_UINT16(2);
+   Datum      *res = NULL;
+
    *nentries = 0;
 
-   if ( strategy == BooleanSearchStrategy ) {
-       QUERYTYPE   *query = (QUERYTYPE*)PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(0));
-       ITEM        *items = GETQUERY(query);
-       int i;
+   if (strategy == BooleanSearchStrategy)
+   {
+       QUERYTYPE  *query = (QUERYTYPE *) PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(0));
+       ITEM       *items = GETQUERY(query);
+       int         i;
 
        if (query->size == 0)
            PG_RETURN_POINTER(NULL);
 
-       if ( shorterquery(items, query->size) == 0 )
-           elog(ERROR,"Query requires full scan, GIN doesn't support it");
+       if (shorterquery(items, query->size) == 0)
+           elog(ERROR, "Query requires full scan, GIN doesn't support it");
 
-       pfree( query );
+       pfree(query);
 
-       query = (QUERYTYPE*)PG_DETOAST_DATUM(PG_GETARG_POINTER(0));
+       query = (QUERYTYPE *) PG_DETOAST_DATUM(PG_GETARG_POINTER(0));
        items = GETQUERY(query);
 
-       res = (Datum*)palloc(sizeof(Datum) * query->size);
+       res = (Datum *) palloc(sizeof(Datum) * query->size);
        *nentries = 0;
 
-       for(i=0;isize;i++)
-           if ( items[i].type == VAL ) { 
-               res[*nentries] = Int32GetDatum( items[i].val );
+       for (i = 0; i < query->size; i++)
+           if (items[i].type == VAL)
+           {
+               res[*nentries] = Int32GetDatum(items[i].val);
                (*nentries)++;
            }
-   } else {
-       ArrayType   *query = PG_GETARG_ARRAYTYPE_P(0);
-       int4 *arr;
-       uint32 i;
+   }
+   else
+   {
+       ArrayType  *query = PG_GETARG_ARRAYTYPE_P(0);
+       int4       *arr;
+       uint32      i;
 
        CHECKARRVALID(query);
-       *nentries=ARRNELEMS(query);
-       if ( *nentries > 0 ) {
-           res = (Datum*)palloc(sizeof(Datum) * (*nentries));
-
-           arr=ARRPTR(query);
-           for(i=0;i<*nentries;i++) 
-               res[i] = Int32GetDatum( arr[i] );
+       *nentries = ARRNELEMS(query);
+       if (*nentries > 0)
+       {
+           res = (Datum *) palloc(sizeof(Datum) * (*nentries));
+
+           arr = ARRPTR(query);
+           for (i = 0; i < *nentries; i++)
+               res[i] = Int32GetDatum(arr[i]);
        }
    }
 
-   PG_RETURN_POINTER( res );
+   PG_RETURN_POINTER(res);
 }
 
 PG_FUNCTION_INFO_V1(ginint4_consistent);
-Datum ginint4_consistent(PG_FUNCTION_ARGS);
+Datum      ginint4_consistent(PG_FUNCTION_ARGS);
 
 Datum
-ginint4_consistent(PG_FUNCTION_ARGS) {
-    bool    *check = (bool*)PG_GETARG_POINTER(0);
-    StrategyNumber  strategy = PG_GETARG_UINT16(1);
-    int res=FALSE;
-
-    /* we can do not check array carefully, it's done by previous ginarrayextract call */
-
-    switch( strategy ) {
-        case RTOverlapStrategyNumber:
-        case RTContainedByStrategyNumber:
-        case RTOldContainedByStrategyNumber:
-            /* at least one element in check[] is true, so result = true */
-
-            res = TRUE;
-            break;
-        case RTSameStrategyNumber:
-        case RTContainsStrategyNumber:
-        case RTOldContainsStrategyNumber:
-            res = TRUE;
-           do {
-               ArrayType   *query = PG_GETARG_ARRAYTYPE_P(2);
-               int i, nentries=ARRNELEMS(query);
-
-               for(i=0;i
-                   if ( !check[i] ) {
-                       res = FALSE;
-                       break;
-                   }
-           } while(0);
-            break;
-        case BooleanSearchStrategy:
-           do {
-               QUERYTYPE   *query = (QUERYTYPE*)PG_DETOAST_DATUM(PG_GETARG_POINTER(2));
-               res = ginconsistent( query, check ); 
-           } while(0);
+ginint4_consistent(PG_FUNCTION_ARGS)
+{
+   bool       *check = (bool *) PG_GETARG_POINTER(0);
+   StrategyNumber strategy = PG_GETARG_UINT16(1);
+   int         res = FALSE;
+
+   /*
+    * we can do not check array carefully, it's done by previous
+    * ginarrayextract call
+    */
+
+   switch (strategy)
+   {
+       case RTOverlapStrategyNumber:
+       case RTContainedByStrategyNumber:
+       case RTOldContainedByStrategyNumber:
+           /* at least one element in check[] is true, so result = true */
+
+           res = TRUE;
+           break;
+       case RTSameStrategyNumber:
+       case RTContainsStrategyNumber:
+       case RTOldContainsStrategyNumber:
+           res = TRUE;
+           do
+           {
+               ArrayType  *query = PG_GETARG_ARRAYTYPE_P(2);
+               int         i,
+                           nentries = ARRNELEMS(query);
+
+               for (i = 0; i < nentries; i++)
+                   if (!check[i])
+                   {
+                       res = FALSE;
+                       break;
+                   }
+           } while (0);
            break;
-        default:
-            elog(ERROR, "ginint4_consistent: unknown strategy number: %d", strategy);
-    }
+       case BooleanSearchStrategy:
+           do
+           {
+               QUERYTYPE  *query = (QUERYTYPE *) PG_DETOAST_DATUM(PG_GETARG_POINTER(2));
+
+               res = ginconsistent(query, check);
+           } while (0);
+           break;
+       default:
+           elog(ERROR, "ginint4_consistent: unknown strategy number: %d", strategy);
+   }
 
-    PG_RETURN_BOOL(res);
+   PG_RETURN_BOOL(res);
 }
index 71c9ad0cec517dd3af090abe2c6597f4d91df439..56eb0c08c2e53835755011fba0ce2574ffbc3a83 100644 (file)
@@ -36,19 +36,21 @@ g_int_consistent(PG_FUNCTION_ARGS)
    StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
    bool        retval;
 
-   if (strategy == BooleanSearchStrategy) {
+   if (strategy == BooleanSearchStrategy)
+   {
        retval = execconsistent((QUERYTYPE *) query,
-                                  (ArrayType *) DatumGetPointer(entry->key),
-                                     GIST_LEAF(entry));
+                               (ArrayType *) DatumGetPointer(entry->key),
+                               GIST_LEAF(entry));
 
-       pfree( query );
+       pfree(query);
        PG_RETURN_BOOL(retval);
    }
 
    /* sort query for fast search, key is already sorted */
    CHECKARRVALID(query);
-   if (ARRISVOID(query)) {
-       pfree( query );
+   if (ARRISVOID(query))
+   {
+       pfree(query);
        PG_RETURN_BOOL(false);
    }
    PREPAREARR(query);
@@ -88,7 +90,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
        default:
            retval = FALSE;
    }
-   pfree( query );
+   pfree(query);
    PG_RETURN_BOOL(retval);
 }
 
@@ -156,7 +158,7 @@ g_int_compress(PG_FUNCTION_ARGS)
 
        retval = palloc(sizeof(GISTENTRY));
        gistentryinit(*retval, PointerGetDatum(r),
-                 entry->rel, entry->page, entry->offset, FALSE);
+                     entry->rel, entry->page, entry->offset, FALSE);
 
        PG_RETURN_POINTER(retval);
    }
@@ -203,7 +205,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, FALSE);
+                     entry->rel, entry->page, entry->offset, FALSE);
        PG_RETURN_POINTER(retval);
    }
    else
@@ -240,7 +242,7 @@ g_int_decompress(PG_FUNCTION_ARGS)
        {
            retval = palloc(sizeof(GISTENTRY));
            gistentryinit(*retval, PointerGetDatum(in),
-                entry->rel, entry->page, entry->offset, FALSE);
+                         entry->rel, entry->page, entry->offset, FALSE);
 
            PG_RETURN_POINTER(retval);
        }
@@ -331,7 +333,7 @@ typedef struct
 {
    OffsetNumber pos;
    float       cost;
-} SPLITCOST;
+}  SPLITCOST;
 
 static int
 comparecost(const void *a, const void *b)
index 82ce4b7ac5642959bd7494e0fb2ea981730731f4..2ad0ef0cc04ebf3da23cc8feb297390a2c137b19 100644 (file)
@@ -89,22 +89,27 @@ inner_int_union(ArrayType *a, ArrayType *b)
 
    if (!r)
    {
-       int     na = ARRNELEMS(a),
-               nb = ARRNELEMS(b);
-       int     *da = ARRPTR(a),
-               *db = ARRPTR(b);
-       int     i,j, *dr;
+       int         na = ARRNELEMS(a),
+                   nb = ARRNELEMS(b);
+       int        *da = ARRPTR(a),
+                  *db = ARRPTR(b);
+       int         i,
+                   j,
+                  *dr;
 
        r = new_intArrayType(na + nb);
        dr = ARRPTR(r);
 
        /* union */
        i = j = 0;
-       while (i < na && j < nb) {
-           if (da[i] == db[j]) {
+       while (i < na && j < nb)
+       {
+           if (da[i] == db[j])
+           {
                *dr++ = da[i++];
                j++;
-           } else if (da[i] < db[j])
+           }
+           else if (da[i] < db[j])
                *dr++ = da[i++];
            else
                *dr++ = db[j++];
@@ -115,7 +120,7 @@ inner_int_union(ArrayType *a, ArrayType *b)
        while (j < nb)
            *dr++ = db[j++];
 
-       r = resize_intArrayType(r, dr-ARRPTR(r));
+       r = resize_intArrayType(r, dr - ARRPTR(r));
    }
 
    if (ARRNELEMS(r) > 1)
index b25814c7ce7ba3f74a9b31104497918febc4dd52..cb80d8f6f2452cb77df4d8bd7a356dbea2c8aafc 100644 (file)
@@ -214,7 +214,7 @@ sizebitvec(BITVECP sign)
                i;
 
    LOOPBYTE(
-       size += number_of_ones[(unsigned char) sign[i]];
+            size += number_of_ones[(unsigned char) sign[i]];
    );
    return size;
 }
@@ -227,8 +227,8 @@ hemdistsign(BITVECP a, BITVECP b)
                dist = 0;
 
    LOOPBYTE(
-       diff = (unsigned char) (a[i] ^ b[i]);
-       dist += number_of_ones[diff];
+            diff = (unsigned char) (a[i] ^ b[i]);
+   dist += number_of_ones[diff];
    );
    return dist;
 }
@@ -318,7 +318,7 @@ typedef struct
 {
    OffsetNumber pos;
    int4        cost;
-} SPLITCOST;
+}  SPLITCOST;
 
 static int
 comparecost(const void *a, const void *b)
@@ -506,16 +506,17 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
 
    if (strategy == BooleanSearchStrategy)
    {
-       retval =signconsistent((QUERYTYPE *) query,
-                                     GETSIGN(DatumGetPointer(entry->key)),
-                                     false);
-       PG_FREE_IF_COPY( query, 1 );
+       retval = signconsistent((QUERYTYPE *) query,
+                               GETSIGN(DatumGetPointer(entry->key)),
+                               false);
+       PG_FREE_IF_COPY(query, 1);
        PG_RETURN_BOOL(retval);
    }
 
    CHECKARRVALID(query);
-   if (ARRISVOID(query)) {
-       PG_FREE_IF_COPY( query, 1 );
+   if (ARRISVOID(query))
+   {
+       PG_FREE_IF_COPY(query, 1);
        PG_RETURN_BOOL(FALSE);
    }
 
@@ -602,6 +603,6 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
        default:
            retval = FALSE;
    }
-   PG_FREE_IF_COPY( query, 1 );
+   PG_FREE_IF_COPY(query, 1);
    PG_RETURN_BOOL(retval);
 }
index 43886c2d6848e67883091c1ff84be93cdb287fc6..87b611a5424bf2be0bce3dd2122182f990dbd7ce 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * EAN13.h
  *   PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
  *
  * http://www.gs1.org/productssolutions/idkeys/support/prefix_list.html
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/contrib/isn/EAN13.h,v 1.1 2006/09/09 04:07:52 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/isn/EAN13.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
  *
  */
 
 /* where the digit set begins, and how many of them are in the table */
 const unsigned EAN13_index[10][2] = {
-   {0,     6},
-   {6,     1},
-   {7,     1},
-   {8,     5},
-   {13,    20},
-   {33,    15},
-   {48,    19},
-   {67,    23},
-   {90,    17},
-   {107,   12},
+   {0, 6},
+   {6, 1},
+   {7, 1},
+   {8, 5},
+   {13, 20},
+   {33, 15},
+   {48, 19},
+   {67, 23},
+   {90, 17},
+   {107, 12},
 };
 const char *EAN13_range[][2] = {
-   {"000", "019"}, /* GS1 US */
-   {"020", "029"}, /* Restricted distribution (MO defined) */
-   {"030", "039"}, /* GS1 US */
-   {"040", "049"}, /* Restricted distribution (MO defined) */
-   {"050", "059"}, /* Coupons */
-   {"060", "099"}, /* GS1 US */
-   {"100", "139"}, /* GS1 US */
-   {"200", "299"}, /* Restricted distribution (MO defined) */
-   {"300", "379"}, /* GS1 France */
-   {"380", "380"}, /* GS1 Bulgaria */
-   {"383", "383"}, /* GS1 Slovenija */
-   {"385", "385"}, /* GS1 Croatia */
-   {"387", "387"}, /* GS1 BIH (Bosnia-Herzegovina) */
-   {"400", "440"}, /* GS1 Germany */
-   {"450", "459"}, /* GS1 Japan */
-   {"460", "469"}, /* GS1 Russia */
-   {"470", "470"}, /* GS1 Kyrgyzstan */
-   {"471", "471"}, /* GS1 Taiwan */
-   {"474", "474"}, /* GS1 Estonia */
-   {"475", "475"}, /* GS1 Latvia */
-   {"476", "476"}, /* GS1 Azerbaijan */
-   {"477", "477"}, /* GS1 Lithuania */
-   {"478", "478"}, /* GS1 Uzbekistan */
-   {"479", "479"}, /* GS1 Sri Lanka */
-   {"480", "480"}, /* GS1 Philippines */
-   {"481", "481"}, /* GS1 Belarus */
-   {"482", "482"}, /* GS1 Ukraine */
-   {"484", "484"}, /* GS1 Moldova */
-   {"485", "485"}, /* GS1 Armenia */
-   {"486", "486"}, /* GS1 Georgia */
-   {"487", "487"}, /* GS1 Kazakstan */
-   {"489", "489"}, /* GS1 Hong Kong */
-   {"490", "499"}, /* GS1 Japan */
-   {"500", "509"}, /* GS1 UK */
-   {"520", "520"}, /* GS1 Greece */
-   {"528", "528"}, /* GS1 Lebanon */
-   {"529", "529"}, /* GS1 Cyprus */
-   {"530", "530"}, /* GS1 Albania */
-   {"531", "531"}, /* GS1 MAC (FYR Macedonia) */
-   {"535", "535"}, /* GS1 Malta */
-   {"539", "539"}, /* GS1 Ireland */
-   {"540", "549"}, /* GS1 Belgium & Luxembourg */
-   {"560", "560"}, /* GS1 Portugal */
-   {"569", "569"}, /* GS1 Iceland */
-   {"570", "579"}, /* GS1 Denmark */
-   {"590", "590"}, /* GS1 Poland */
-   {"594", "594"}, /* GS1 Romania */
-   {"599", "599"}, /* GS1 Hungary */
-   {"600", "601"}, /* GS1 South Africa */
-   {"603", "603"}, /* GS1 Ghana */
-   {"608", "608"}, /* GS1 Bahrain */
-   {"609", "609"}, /* GS1 Mauritius */
-   {"611", "611"}, /* GS1 Morocco */
-   {"613", "613"}, /* GS1 Algeria */
-   {"616", "616"}, /* GS1 Kenya */
-   {"618", "618"}, /* GS1 Ivory Coast */
-   {"619", "619"}, /* GS1 Tunisia */
-   {"621", "621"}, /* GS1 Syria */
-   {"622", "622"}, /* GS1 Egypt */
-   {"624", "624"}, /* GS1 Libya */
-   {"625", "625"}, /* GS1 Jordan */
-   {"626", "626"}, /* GS1 Iran */
-   {"627", "627"}, /* GS1 Kuwait */
-   {"628", "628"}, /* GS1 Saudi Arabia */
-   {"629", "629"}, /* GS1 Emirates */
-   {"640", "649"}, /* GS1 Finland */
-   {"690", "695"}, /* GS1 China */
-   {"700", "709"}, /* GS1 Norway */
-   {"729", "729"}, /* GS1 Israel */
-   {"730", "739"}, /* GS1 Sweden */
-   {"740", "740"}, /* GS1 Guatemala */
-   {"741", "741"}, /* GS1 El Salvador */
-   {"742", "742"}, /* GS1 Honduras */
-   {"743", "743"}, /* GS1 Nicaragua */
-   {"744", "744"}, /* GS1 Costa Rica */
-   {"745", "745"}, /* GS1 Panama */
-   {"746", "746"}, /* GS1 Republica Dominicana */
-   {"750", "750"}, /* GS1 Mexico */
-   {"754", "755"}, /* GS1 Canada */
-   {"759", "759"}, /* GS1 Venezuela */
-   {"760", "769"}, /* GS1 Schweiz, Suisse, Svizzera */
-   {"770", "770"}, /* GS1 Colombia */
-   {"773", "773"}, /* GS1 Uruguay */
-   {"775", "775"}, /* GS1 Peru */
-   {"777", "777"}, /* GS1 Bolivia */
-   {"779", "779"}, /* GS1 Argentina */
-   {"780", "780"}, /* GS1 Chile */
-   {"784", "784"}, /* GS1 Paraguay */
-   {"786", "786"}, /* GS1 Ecuador */
-   {"789", "790"}, /* GS1 Brasil */
-   {"800", "839"}, /* GS1 Italy */
-   {"840", "849"}, /* GS1 Spain */
-   {"850", "850"}, /* GS1 Cuba */
-   {"858", "858"}, /* GS1 Slovakia */
-   {"859", "859"}, /* GS1 Czech */
-   {"860", "860"}, /* GS1 YU (Serbia & Montenegro) */
-   {"865", "865"}, /* GS1 Mongolia */
-   {"867", "867"}, /* GS1 North Korea */
-   {"869", "869"}, /* GS1 Turkey */
-   {"870", "879"}, /* GS1 Netherlands */
-   {"880", "880"}, /* GS1 South Korea */
-   {"884", "884"}, /* GS1 Cambodia */
-   {"885", "885"}, /* GS1 Thailand */
-   {"888", "888"}, /* GS1 Singapore */
-   {"890", "890"}, /* GS1 India */
-   {"893", "893"}, /* GS1 Vietnam */
-   {"899", "899"}, /* GS1 Indonesia */
-   {"900", "919"}, /* GS1 Austria */
-   {"930", "939"}, /* GS1 Australia */
-   {"940", "949"}, /* GS1 New Zealand */
-   {"950", "950"}, /* GS1 Head Office */
-   {"955", "955"}, /* GS1 Malaysia */
-   {"958", "958"}, /* GS1 Macau */
-   {"977", "977"}, /* Serial publications (ISSN) */
-   {"978", "978"}, /* Bookland (ISBN) */
-   {"979", "979"}, /* International Standard Music Number (ISMN) and ISBN contingent */
-   {"980", "980"}, /* Refund receipts */
-   {"981", "982"}, /* Common Currency Coupons */
-   {"990", "999"}, /* Coupons */
+   {"000", "019"},             /* GS1 US */
+   {"020", "029"},             /* Restricted distribution (MO defined) */
+   {"030", "039"},             /* GS1 US */
+   {"040", "049"},             /* Restricted distribution (MO defined) */
+   {"050", "059"},             /* Coupons */
+   {"060", "099"},             /* GS1 US */
+   {"100", "139"},             /* GS1 US */
+   {"200", "299"},             /* Restricted distribution (MO defined) */
+   {"300", "379"},             /* GS1 France */
+   {"380", "380"},             /* GS1 Bulgaria */
+   {"383", "383"},             /* GS1 Slovenija */
+   {"385", "385"},             /* GS1 Croatia */
+   {"387", "387"},             /* GS1 BIH (Bosnia-Herzegovina) */
+   {"400", "440"},             /* GS1 Germany */
+   {"450", "459"},             /* GS1 Japan */
+   {"460", "469"},             /* GS1 Russia */
+   {"470", "470"},             /* GS1 Kyrgyzstan */
+   {"471", "471"},             /* GS1 Taiwan */
+   {"474", "474"},             /* GS1 Estonia */
+   {"475", "475"},             /* GS1 Latvia */
+   {"476", "476"},             /* GS1 Azerbaijan */
+   {"477", "477"},             /* GS1 Lithuania */
+   {"478", "478"},             /* GS1 Uzbekistan */
+   {"479", "479"},             /* GS1 Sri Lanka */
+   {"480", "480"},             /* GS1 Philippines */
+   {"481", "481"},             /* GS1 Belarus */
+   {"482", "482"},             /* GS1 Ukraine */
+   {"484", "484"},             /* GS1 Moldova */
+   {"485", "485"},             /* GS1 Armenia */
+   {"486", "486"},             /* GS1 Georgia */
+   {"487", "487"},             /* GS1 Kazakstan */
+   {"489", "489"},             /* GS1 Hong Kong */
+   {"490", "499"},             /* GS1 Japan */
+   {"500", "509"},             /* GS1 UK */
+   {"520", "520"},             /* GS1 Greece */
+   {"528", "528"},             /* GS1 Lebanon */
+   {"529", "529"},             /* GS1 Cyprus */
+   {"530", "530"},             /* GS1 Albania */
+   {"531", "531"},             /* GS1 MAC (FYR Macedonia) */
+   {"535", "535"},             /* GS1 Malta */
+   {"539", "539"},             /* GS1 Ireland */
+   {"540", "549"},             /* GS1 Belgium & Luxembourg */
+   {"560", "560"},             /* GS1 Portugal */
+   {"569", "569"},             /* GS1 Iceland */
+   {"570", "579"},             /* GS1 Denmark */
+   {"590", "590"},             /* GS1 Poland */
+   {"594", "594"},             /* GS1 Romania */
+   {"599", "599"},             /* GS1 Hungary */
+   {"600", "601"},             /* GS1 South Africa */
+   {"603", "603"},             /* GS1 Ghana */
+   {"608", "608"},             /* GS1 Bahrain */
+   {"609", "609"},             /* GS1 Mauritius */
+   {"611", "611"},             /* GS1 Morocco */
+   {"613", "613"},             /* GS1 Algeria */
+   {"616", "616"},             /* GS1 Kenya */
+   {"618", "618"},             /* GS1 Ivory Coast */
+   {"619", "619"},             /* GS1 Tunisia */
+   {"621", "621"},             /* GS1 Syria */
+   {"622", "622"},             /* GS1 Egypt */
+   {"624", "624"},             /* GS1 Libya */
+   {"625", "625"},             /* GS1 Jordan */
+   {"626", "626"},             /* GS1 Iran */
+   {"627", "627"},             /* GS1 Kuwait */
+   {"628", "628"},             /* GS1 Saudi Arabia */
+   {"629", "629"},             /* GS1 Emirates */
+   {"640", "649"},             /* GS1 Finland */
+   {"690", "695"},             /* GS1 China */
+   {"700", "709"},             /* GS1 Norway */
+   {"729", "729"},             /* GS1 Israel */
+   {"730", "739"},             /* GS1 Sweden */
+   {"740", "740"},             /* GS1 Guatemala */
+   {"741", "741"},             /* GS1 El Salvador */
+   {"742", "742"},             /* GS1 Honduras */
+   {"743", "743"},             /* GS1 Nicaragua */
+   {"744", "744"},             /* GS1 Costa Rica */
+   {"745", "745"},             /* GS1 Panama */
+   {"746", "746"},             /* GS1 Republica Dominicana */
+   {"750", "750"},             /* GS1 Mexico */
+   {"754", "755"},             /* GS1 Canada */
+   {"759", "759"},             /* GS1 Venezuela */
+   {"760", "769"},             /* GS1 Schweiz, Suisse, Svizzera */
+   {"770", "770"},             /* GS1 Colombia */
+   {"773", "773"},             /* GS1 Uruguay */
+   {"775", "775"},             /* GS1 Peru */
+   {"777", "777"},             /* GS1 Bolivia */
+   {"779", "779"},             /* GS1 Argentina */
+   {"780", "780"},             /* GS1 Chile */
+   {"784", "784"},             /* GS1 Paraguay */
+   {"786", "786"},             /* GS1 Ecuador */
+   {"789", "790"},             /* GS1 Brasil */
+   {"800", "839"},             /* GS1 Italy */
+   {"840", "849"},             /* GS1 Spain */
+   {"850", "850"},             /* GS1 Cuba */
+   {"858", "858"},             /* GS1 Slovakia */
+   {"859", "859"},             /* GS1 Czech */
+   {"860", "860"},             /* GS1 YU (Serbia & Montenegro) */
+   {"865", "865"},             /* GS1 Mongolia */
+   {"867", "867"},             /* GS1 North Korea */
+   {"869", "869"},             /* GS1 Turkey */
+   {"870", "879"},             /* GS1 Netherlands */
+   {"880", "880"},             /* GS1 South Korea */
+   {"884", "884"},             /* GS1 Cambodia */
+   {"885", "885"},             /* GS1 Thailand */
+   {"888", "888"},             /* GS1 Singapore */
+   {"890", "890"},             /* GS1 India */
+   {"893", "893"},             /* GS1 Vietnam */
+   {"899", "899"},             /* GS1 Indonesia */
+   {"900", "919"},             /* GS1 Austria */
+   {"930", "939"},             /* GS1 Australia */
+   {"940", "949"},             /* GS1 New Zealand */
+   {"950", "950"},             /* GS1 Head Office */
+   {"955", "955"},             /* GS1 Malaysia */
+   {"958", "958"},             /* GS1 Macau */
+   {"977", "977"},             /* Serial publications (ISSN) */
+   {"978", "978"},             /* Bookland (ISBN) */
+   {"979", "979"},             /* International Standard Music Number (ISMN)
+                                * and ISBN contingent */
+   {"980", "980"},             /* Refund receipts */
+   {"981", "982"},             /* Common Currency Coupons */
+   {"990", "999"},             /* Coupons */
    {NULL, NULL}
 };
index 0b23a95ccfbabe9b71ba3e206b2fee4159e12d15..26c84afe8013f432cce0cf8ef97c3e80ea612b05 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * ISBN.h
  *   PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
  *
@@ -7,39 +7,39 @@
  * http://www.isbn.org/
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/contrib/isn/ISBN.h,v 1.1 2006/09/09 04:07:52 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/isn/ISBN.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
  *
  * 0-393-04002-X => 039304002(X) <=> 039304002 <=> (978)039304002 <=> 978039304002(9) <=> 978-0-393-04002-9
  *
  *
- * ISBN         0   3    9    3    0   4    0   0   2
- * Weight       10  9    8    7    6   5    4   3   2
- * Product      0 + 27 + 72 + 21 + 0 + 20 + 0 + 0 + 4 = 144
- *              144 / 11 = 13 remainder 1
- * Check digit  11 - 1 = 10 = X
+ * ISBN            0   3    9    3    0   4    0   0   2
+ * Weight      10  9    8    7    6   5    4   3   2
+ * Product     0 + 27 + 72 + 21 + 0 + 20 + 0 + 0 + 4 = 144
+ *             144 / 11 = 13 remainder 1
+ * Check digit 11 - 1 = 10 = X
  * => 0-393-04002-X
  *
- * ISBN         9   7    8   0   3   9    3   0   4   0   0   2
- * Weight       1   3    1   3   1   3    1   3   1   3   1   3
- * Product      9 + 21 + 8 + 0 + 3 + 27 + 3 + 0 + 4 + 0 + 0 + 6 = 81
- *              81 / 10 = 8 remainder 1
- * Check digit  10 - 1 = 9
+ * ISBN            9   7    8   0   3   9    3   0   4   0   0   2
+ * Weight      1   3    1   3   1   3    1   3   1   3   1   3
+ * Product     9 + 21 + 8 + 0 + 3 + 27 + 3 + 0 + 4 + 0 + 0 + 6 = 81
+ *             81 / 10 = 8 remainder 1
+ * Check digit 10 - 1 = 9
  * => 978-0-393-04002-9
  *
  */
 
 /* where the digit set begins, and how many of them are in the table */
 const unsigned ISBN_index[10][2] = {
-   {0,     6},
-   {6,     6},
-   {12,    8},
-   {20,    10},
-   {30,    6},
-   {36,    12},
-   {48,    0},
-   {48,    5},
-   {53,    59},
-   {112,   573},
+   {0, 6},
+   {6, 6},
+   {12, 8},
+   {20, 10},
+   {30, 6},
+   {36, 12},
+   {48, 0},
+   {48, 5},
+   {53, 59},
+   {112, 573},
 };
 
 const char *ISBN_range[][2] = {
index 0451d1942c740ced7b3230dfc4d29c6050aacadd..1d7b2af8fd7ab4052cdc873beab40be3e7c00b95 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * ISMN.h
  *   PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
  *
@@ -6,23 +6,23 @@
  * http://www.ismn-international.org
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/contrib/isn/ISMN.h,v 1.1 2006/09/09 04:07:52 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/isn/ISMN.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
  *
  * M-3452-4680-5 <=> (0)-3452-4680-5 <=> 0345246805 <=> 9790345246805 <=> 979-0-3452-4680-5
  *
- *             (M counts as 3)
- * ISMN         M   3   4    5   2   4   6    8   0
- * Weight       3   1   3    1   3   1   3    1   3
- * Product      9 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 65
- *              65 / 10 = 6 remainder 5
- * Check digit  10 - 5 = 5 
+ *            (M counts as 3)
+ * ISMN            M   3   4    5   2   4   6    8   0
+ * Weight      3   1   3    1   3   1   3    1   3
+ * Product     9 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 65
+ *             65 / 10 = 6 remainder 5
+ * Check digit 10 - 5 = 5
  * => M-3452-4680-5
  *
- * ISMN         9   7    9   0   3   4    5   2   4   6    8   0
- * Weight       1   3    1   3   1   3    1   3   1   3    1   3
- * Product      9 + 21 + 9 + 0 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 95
- *              95 / 10 = 9 remainder 5
- * Check digit  10 - 5 = 5 
+ * ISMN            9   7    9   0   3   4    5   2   4   6    8   0
+ * Weight      1   3    1   3   1   3    1   3   1   3    1   3
+ * Product     9 + 21 + 9 + 0 + 3 + 12 + 5 + 6 + 4 + 18 + 8 + 0 = 95
+ *             95 / 10 = 9 remainder 5
+ * Check digit 10 - 5 = 5
  * => 979-0-3452-4680-5
  *
  * Since mod10(9*1 + 7*3 + 9*1 + 0*3) = mod10(M*3) = mod10(3*3) = 9; the check digit remains the same.
 
 /* where the digit set begins, and how many of them are in the table */
 const unsigned ISMN_index[10][2] = {
-   {0,     5},
-   {5,     0},
-   {5,     0},
-   {5,     0},
-   {5,     0},
-   {5,     0},
-   {5,     0},
-   {5,     0},
-   {5,     0},
-   {5,     0},
+   {0, 5},
+   {5, 0},
+   {5, 0},
+   {5, 0},
+   {5, 0},
+   {5, 0},
+   {5, 0},
+   {5, 0},
+   {5, 0},
+   {5, 0},
 };
 const char *ISMN_range[][2] = {
    {"0-000", "0-099"},
index aeafb0c3c7dceebd1fc83ffdf561d9dc421a6e4e..063a5d97f13394d9984eb882a751243ca68e1843 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * ISSN.h
  *   PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
  *
@@ -6,25 +6,25 @@
  * http://www.issn.org/
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/contrib/isn/ISSN.h,v 1.1 2006/09/09 04:07:52 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/isn/ISSN.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
  *
  * 1144-875X <=> 1144875(X) <=> 1144875 <=> (977)1144875 <=> 9771144875(00) <=> 977114487500(7) <=> 977-1144-875-00-7
  *
- * 
- * ISSN         1   1   4    4    8    7    5
- * Weight       8   7   6    5    4    3    2 
- * Product      8 + 7 + 24 + 20 + 32 + 21 + 10 = 122
- *              122 / 11 = 11 remainder 1
- * Check digit  11 - 1 = 10 = X
+ *
+ * ISSN            1   1   4    4    8    7    5
+ * Weight      8   7   6    5    4    3    2
+ * Product     8 + 7 + 24 + 20 + 32 + 21 + 10 = 122
+ *             122 / 11 = 11 remainder 1
+ * Check digit 11 - 1 = 10 = X
  * => 1144-875X
- * 
- * ISSN         9   7    7   1   1   4    4   8    7   5    0   0
- * Weight       1   3    1   3   1   3    1   3    1   3    1   3
- * Product      9 + 21 + 7 + 3 + 1 + 12 + 4 + 24 + 7 + 15 + 0 + 0 = 103
- *              103 / 10 = 10 remainder 3
- * Check digit  10 - 3 = 7
+ *
+ * ISSN            9   7    7   1   1   4    4   8    7   5    0   0
+ * Weight      1   3    1   3   1   3    1   3    1   3    1   3
+ * Product     9 + 21 + 7 + 3 + 1 + 12 + 4 + 24 + 7 + 15 + 0 + 0 = 103
+ *             103 / 10 = 10 remainder 3
+ * Check digit 10 - 3 = 7
  * => 977-1144875-00-7 ??  <- suplemental number (number of the week, month, etc.)
- *                ^^ 00 for non-daily publications (01=Monday, 02=Tuesday, ...)
+ *               ^^ 00 for non-daily publications (01=Monday, 02=Tuesday, ...)
  *
  * The hyphenation is always in after the four digits of the ISSN code.
  *
 
 /* where the digit set begins, and how many of them are in the table */
 const unsigned ISSN_index[10][2] = {
-   {0,     1},
-   {0,     1},
-   {0,     1},
-   {0,     1},
-   {0,     1},
-   {0,     1},
-   {0,     1},
-   {0,     1},
-   {0,     1},
-   {0,     1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
+   {0, 1},
 };
 const char *ISSN_range[][2] = {
    {"0000-000", "9999-999"},
index 2491fa3ee22801d26a5721d4f806abb07d38bf51..2b58a6b5660954353ba0306a63e0f67b55eb81de 100644 (file)
@@ -1,27 +1,27 @@
-/* 
+/*
  * ISSN.h
  *   PostgreSQL type definitions for ISNs (ISBN, ISMN, ISSN, EAN13, UPC)
  *
  * No information available for UPC prefixes
- * 
+ *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/contrib/isn/UPC.h,v 1.1 2006/09/09 04:07:52 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/isn/UPC.h,v 1.2 2006/10/04 00:29:45 momjian Exp $
  *
  */
 
 /* where the digit set begins, and how many of them are in the table */
 const unsigned UPC_index[10][2] = {
-   {0,     0},
-   {0,     0},
-   {0,     0},
-   {0,     0},
-   {0,     0},
-   {0,     0},
-   {0,     0},
-   {0,     0},
-   {0,     0},
-   {0,     0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
+   {0, 0},
 };
 const char *UPC_range[][2] = {
    {NULL, NULL}
index 53e23228c9228a8728df54726ee5c745e163feba..cd4fd6c84ae29d6957e6adf24aed3d7dee4503f6 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.3 2006/09/22 21:39:57 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.4 2006/10/04 00:29:45 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,9 +29,12 @@ PG_MODULE_MAGIC;
 
 #define MAXEAN13LEN 18
 
-enum isn_type { INVALID, ANY, EAN13, ISBN, ISMN, ISSN, UPC };
+enum isn_type
+{
+   INVALID, ANY, EAN13, ISBN, ISMN, ISSN, UPC
+};
 
-static const char *isn_names[] = { "EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN", "ISMN", "ISSN", "UPC" };
+static const char *isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN", "ISMN", "ISSN", "UPC"};
 
 static bool g_weak = false;
 static bool g_initialized = false;
@@ -46,8 +49,8 @@ static bool g_initialized = false;
  **        Routines for EAN13/UPC/ISxNs.
  **
  ** Note:
- **  In this code, a normalized string is one that is known to be a valid 
- **  ISxN number containing only digits and hyphens and with enough space 
+ **  In this code, a normalized string is one that is known to be a valid
+ **  ISxN number containing only digits and hyphens and with enough space
  **  to hold the full 13 digits plus the maximum of four hyphens.
  ***********************************************************************/
 
@@ -60,14 +63,25 @@ static bool g_initialized = false;
  */
 #ifdef ISN_DEBUG
 static
-bool check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
+bool
+check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
 {
-   const char *aux1, *aux2;
-   int a, b, x=0, y=-1, i=0, j, cnt=0, init=0;
-   
-   if(TABLE == NULL || TABLE_index == NULL) return true;
-
-   while(TABLE[i][0] && TABLE[i][1]) {
+   const char *aux1,
+              *aux2;
+   int         a,
+               b,
+               x = 0,
+               y = -1,
+               i = 0,
+               j,
+               cnt = 0,
+               init = 0;
+
+   if (TABLE == NULL || TABLE_index == NULL)
+       return true;
+
+   while (TABLE[i][0] && TABLE[i][1])
+   {
        aux1 = TABLE[i][0];
        aux2 = TABLE[i][1];
 
@@ -78,30 +92,37 @@ bool check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
        b = *aux2 - '0';
 
        /* must always have the same format and length: */
-       while(*aux1 && *aux2) {
+       while (*aux1 && *aux2)
+       {
            if (!(isdigit((unsigned char) *aux1) &&
                  isdigit((unsigned char) *aux2)) &&
-               (*aux1 != *aux2 || *aux1 != '-')) 
+               (*aux1 != *aux2 || *aux1 != '-'))
                goto invalidtable;
            aux1++;
            aux2++;
        }
-       if(*aux1!=*aux2) goto invalidtable;
+       if (*aux1 != *aux2)
+           goto invalidtable;
 
        /* found a new range */
-       if(a>y) {
+       if (a > y)
+       {
            /* check current range in the index: */
-           for(j=x;j<=y;j++) {
-               if(TABLE_index[j][0] != init) goto invalidindex;
-               if(TABLE_index[j][1] != i-init) goto invalidindex;
+           for (j = x; j <= y; j++)
+           {
+               if (TABLE_index[j][0] != init)
+                   goto invalidindex;
+               if (TABLE_index[j][1] != i - init)
+                   goto invalidindex;
            }
            init = i;
            x = a;
-       } 
+       }
 
        /* Always get the new limit */
        y = b;
-       if(y
+       if (y < x)
+           goto invalidtable;
        i++;
    }
 
@@ -116,18 +137,22 @@ invalidindex:
    elog(DEBUG1, "index %d is invalid", j);
    return false;
 }
-#endif /* ISN_DEBUG */
+#endif   /* ISN_DEBUG */
 
 /*----------------------------------------------------------
  * Formatting and conversion routines.
  *---------------------------------------------------------*/
 
 static
-unsigned dehyphenate(char *bufO, char *bufI)
+unsigned
+dehyphenate(char *bufO, char *bufI)
 {
-   unsigned ret = 0;
-   while(*bufI) {
-       if(isdigit((unsigned char) *bufI)) {
+   unsigned    ret = 0;
+
+   while (*bufI)
+   {
+       if (isdigit((unsigned char) *bufI))
+       {
            *bufO++ = *bufI;
            ret++;
        }
@@ -138,29 +163,40 @@ unsigned dehyphenate(char *bufO, char *bufI)
 }
 
 /*
- * hyphenate --- Try to hyphenate, in-place, the string starting at bufI 
- *                into bufO using the given hyphenation range TABLE.
- *                Assumes the input string to be used is of only digits.
+ * hyphenate --- Try to hyphenate, in-place, the string starting at bufI
+ *               into bufO using the given hyphenation range TABLE.
+ *               Assumes the input string to be used is of only digits.
  *
  * Returns the number of characters acctually hyphenated.
  */
 static
-unsigned hyphenate(char *bufO, char *bufI, const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
+unsigned
+hyphenate(char *bufO, char *bufI, const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
 {
-   unsigned ret = 0;
-   const char *ean_aux1, *ean_aux2, *ean_p;
-   char *firstdig, *aux1, *aux2;
-   unsigned search, upper, lower, step;
-   bool ean_in1, ean_in2;
+   unsigned    ret = 0;
+   const char *ean_aux1,
+              *ean_aux2,
+              *ean_p;
+   char       *firstdig,
+              *aux1,
+              *aux2;
+   unsigned    search,
+               upper,
+               lower,
+               step;
+   bool        ean_in1,
+               ean_in2;
 
    /* just compress the string if no further hyphenation is required */
-   if(TABLE == NULL || TABLE_index == NULL) {
-       while(*bufI) {
+   if (TABLE == NULL || TABLE_index == NULL)
+   {
+       while (*bufI)
+       {
            *bufO++ = *bufI++;
            ret++;
        }
        *bufO = '\0';
-       return (ret+1);
+       return (ret + 1);
    }
 
    /* add remaining hyphenations */
@@ -171,26 +207,41 @@ unsigned hyphenate(char *bufO, char *bufI, const char *(*TABLE)[2], const unsign
    lower--;
 
    step = (upper - lower) / 2;
-   if(step == 0) return 0;
+   if (step == 0)
+       return 0;
    search = lower + step;
 
    firstdig = bufI;
    ean_in1 = ean_in2 = false;
    ean_aux1 = TABLE[search][0];
    ean_aux2 = TABLE[search][1];
-   do {
-       if((ean_in1 || *firstdig>=*ean_aux1) && (ean_in2 || *firstdig<=*ean_aux2)) {
-           if(*firstdig > *ean_aux1) ean_in1 = true;
-           if(*firstdig < *ean_aux2) ean_in2 = true;
-           if(ean_in1 && ean_in2) break;
+   do
+   {
+       if ((ean_in1 || *firstdig >= *ean_aux1) && (ean_in2 || *firstdig <= *ean_aux2))
+       {
+           if (*firstdig > *ean_aux1)
+               ean_in1 = true;
+           if (*firstdig < *ean_aux2)
+               ean_in2 = true;
+           if (ean_in1 && ean_in2)
+               break;
 
            firstdig++, ean_aux1++, ean_aux2++;
-           if(!(*ean_aux1 && *ean_aux2 && *firstdig)) break;
-           if(!isdigit((unsigned char) *ean_aux1)) ean_aux1++, ean_aux2++;
-       } else {
-           /* check in what direction we should go and move the pointer accordingly */
-           if(*firstdig < *ean_aux1 && !ean_in1) upper = search;
-           else lower = search;
+           if (!(*ean_aux1 && *ean_aux2 && *firstdig))
+               break;
+           if (!isdigit((unsigned char) *ean_aux1))
+               ean_aux1++, ean_aux2++;
+       }
+       else
+       {
+           /*
+            * check in what direction we should go and move the pointer
+            * accordingly
+            */
+           if (*firstdig < *ean_aux1 && !ean_in1)
+               upper = search;
+           else
+               lower = search;
 
            step = (upper - lower) / 2;
            search = lower + step;
@@ -201,150 +252,189 @@ unsigned hyphenate(char *bufO, char *bufI, const char *(*TABLE)[2], const unsign
            ean_aux1 = TABLE[search][0];
            ean_aux2 = TABLE[search][1];
        }
-   } while(step);
-   
-   if(step) {
+   } while (step);
+
+   if (step)
+   {
        aux1 = bufO;
        aux2 = bufI;
        ean_p = TABLE[search][0];
-       while(*ean_p && *aux2) {
-           if(*ean_p++!='-') *aux1++ = *aux2++;
-           else *aux1++ = '-';
+       while (*ean_p && *aux2)
+       {
+           if (*ean_p++ != '-')
+               *aux1++ = *aux2++;
+           else
+               *aux1++ = '-';
            ret++;
        }
-       *aux1++='-';
-       *aux1 = *aux2; /* add a lookahead char */
-       return (ret+1);
+       *aux1++ = '-';
+       *aux1 = *aux2;          /* add a lookahead char */
+       return (ret + 1);
    }
    return ret;
 }
 
 /*
- * weight_checkdig -- Receives a buffer with a normalized ISxN string number, 
- *                     and the length to weight.
+ * weight_checkdig -- Receives a buffer with a normalized ISxN string number,
+ *                    and the length to weight.
  *
  * Returns the weight of the number (the check digit value, 0-10)
  */
 static
-unsigned weight_checkdig(char *isn, unsigned size)
+unsigned
+weight_checkdig(char *isn, unsigned size)
 {
-   unsigned weight = 0;
-   while(*isn && size>1) {
-       if(isdigit((unsigned char) *isn)) {
+   unsigned    weight = 0;
+
+   while (*isn && size > 1)
+   {
+       if (isdigit((unsigned char) *isn))
+       {
            weight += size-- * (*isn - '0');
        }
        isn++;
    }
    weight = weight % 11;
-   if(weight != 0) weight = 11 - weight;
+   if (weight != 0)
+       weight = 11 - weight;
    return weight;
 }
 
 
 /*
- * checkdig --- Receives a buffer with a normalized ISxN string number, 
- *               and the length to check.
+ * checkdig --- Receives a buffer with a normalized ISxN string number,
+ *              and the length to check.
  *
  * Returns the check digit value (0-9)
  */
 static
-unsigned checkdig(char *num, unsigned size)
+unsigned
+checkdig(char *num, unsigned size)
 {
-   unsigned check=0, check3=0;
-   unsigned pos = 0;
-   if(*num == 'M') { /* ISMN start with 'M' */
+   unsigned    check = 0,
+               check3 = 0;
+   unsigned    pos = 0;
+
+   if (*num == 'M')
+   {                           /* ISMN start with 'M' */
        check3 = 3;
        pos = 1;
    }
-   while(*num && size>1) {
-       if(isdigit((unsigned char) *num)) {
-           if(pos++%2) check3 += *num - '0';
-           else check += *num - '0';
+   while (*num && size > 1)
+   {
+       if (isdigit((unsigned char) *num))
+       {
+           if (pos++ % 2)
+               check3 += *num - '0';
+           else
+               check += *num - '0';
            size--;
        }
        num++;
    }
-   check = (check + 3*check3) % 10;
-   if(check != 0) check = 10 - check;
+   check = (check + 3 * check3) % 10;
+   if (check != 0)
+       check = 10 - check;
    return check;
 }
 
 /*
  * ean2isn --- Try to convert an ean13 number to a UPC/ISxN number.
- *             This doesn't verify for a valid check digit.
+ *            This doesn't verify for a valid check digit.
  *
  * If errorOK is false, ereport a useful error message if the ean13 is bad.
  * If errorOK is true, just return "false" for bad input.
  */
 static
-bool ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
+bool
+ean2isn(ean13 ean, bool errorOK, ean13 * result, enum isn_type accept)
 {
    enum isn_type type = INVALID;
 
-   char buf[MAXEAN13LEN + 1];
-   char *firstdig, *aux;
-   unsigned digval;
-   unsigned search;
-   ean13 ret = ean;
-   
+   char        buf[MAXEAN13LEN + 1];
+   char       *firstdig,
+              *aux;
+   unsigned    digval;
+   unsigned    search;
+   ean13       ret = ean;
+
    ean >>= 1;
    /* verify it's in the EAN13 range */
-   if(ean > UINT64CONST(9999999999999))
+   if (ean > UINT64CONST(9999999999999))
        goto eantoobig;
 
    /* convert the number */
    search = 0;
    firstdig = aux = buf + 13;
-   *aux = '\0';        /* terminate string; aux points to last digit */
-   do {
-       digval = (unsigned)(ean % 10);      /* get the decimal value */ 
-       ean /= 10;                                              /* get next digit */
-       *--aux = (char)(digval + '0');          /* convert to ascii and store */
-   } while(ean && search++<12);
-   while(search++<12) *--aux = '0';            /* fill the remaining EAN13 with '0' */
-   
+   *aux = '\0';                /* terminate string; aux points to last digit */
+   do
+   {
+       digval = (unsigned) (ean % 10); /* get the decimal value */
+       ean /= 10;              /* get next digit */
+       *--aux = (char) (digval + '0'); /* convert to ascii and store */
+   } while (ean && search++ < 12);
+   while (search++ < 12)
+       *--aux = '0';           /* fill the remaining EAN13 with '0' */
+
    /* find out the data type: */
-   if(!strncmp("978", buf, 3)) { /* ISBN */
+   if (!strncmp("978", buf, 3))
+   {                           /* ISBN */
        type = ISBN;
-   } else if(!strncmp("977", buf, 3)) { /* ISSN */
+   }
+   else if (!strncmp("977", buf, 3))
+   {                           /* ISSN */
        type = ISSN;
-   } else if(!strncmp("9790", buf, 4)) { /* ISMN */
+   }
+   else if (!strncmp("9790", buf, 4))
+   {                           /* ISMN */
        type = ISMN;
-   } else if(!strncmp("979", buf, 3)) { /* ISBN-13 */
+   }
+   else if (!strncmp("979", buf, 3))
+   {                           /* ISBN-13 */
        type = ISBN;
-   } else if(*buf == '0') { /* UPC */
+   }
+   else if (*buf == '0')
+   {                           /* UPC */
        type = UPC;
-   } else {
+   }
+   else
+   {
        type = EAN13;
    }
-   if(accept != ANY && accept != EAN13 && accept != type) goto eanwrongtype;
+   if (accept != ANY && accept != EAN13 && accept != type)
+       goto eanwrongtype;
 
    *result = ret;
    return true;
-   
+
 eanwrongtype:
-   if(!errorOK) {
-       if(type!=EAN13) {
+   if (!errorOK)
+   {
+       if (type != EAN13)
+       {
            ereport(ERROR,
-               (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
-                errmsg("cannot cast EAN13(%s) to %s for number: \"%s\"",
-                       isn_names[type], isn_names[accept], buf)));
-       } else {
+                   (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+                    errmsg("cannot cast EAN13(%s) to %s for number: \"%s\"",
+                           isn_names[type], isn_names[accept], buf)));
+       }
+       else
+       {
            ereport(ERROR,
-               (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
-                errmsg("cannot cast %s to %s for number: \"%s\"",
-                       isn_names[type], isn_names[accept], buf)));
+                   (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
+                    errmsg("cannot cast %s to %s for number: \"%s\"",
+                           isn_names[type], isn_names[accept], buf)));
        }
    }
    return false;
 
 eantoobig:
-   if(!errorOK) {
-       char    eanbuf[64];
+   if (!errorOK)
+   {
+       char        eanbuf[64];
 
        /*
-        * Format the number separately to keep the machine-dependent
-        * format code out of the translatable message text
+        * Format the number separately to keep the machine-dependent format
+        * code out of the translatable message text
         */
        snprintf(eanbuf, sizeof(eanbuf), EAN13_FORMAT, ean);
        ereport(ERROR,
@@ -356,144 +446,176 @@ eantoobig:
 }
 
 /*
- * ean2UPC/ISxN --- Convert in-place a normalized EAN13 string to the corresponding 
- *                  UPC/ISxN string number. Assumes the input string is normalized.
+ * ean2UPC/ISxN --- Convert in-place a normalized EAN13 string to the corresponding
+ *                 UPC/ISxN string number. Assumes the input string is normalized.
  */
 static inline
-void ean2ISBN(char *isn)
+void
+ean2ISBN(char *isn)
 {
-   char *aux;
-   unsigned check;
+   char       *aux;
+   unsigned    check;
+
    /* the number should come in this format: 978-0-000-00000-0 */
    /* Strip the first part and calculate the new check digit */
-   hyphenate(isn, isn+4, NULL, NULL);
+   hyphenate(isn, isn + 4, NULL, NULL);
    check = weight_checkdig(isn, 10);
    aux = strchr(isn, '\0');
-   while(!isdigit((unsigned char) *--aux));
-   if(check == 10) *aux = 'X';
-   else *aux = check + '0';
+   while (!isdigit((unsigned char) *--aux));
+   if (check == 10)
+       *aux = 'X';
+   else
+       *aux = check + '0';
 }
 static inline
-void ean2ISMN(char *isn)
+void
+ean2ISMN(char *isn)
 {
    /* the number should come in this format: 979-0-000-00000-0 */
    /* Just strip the first part and change the first digit ('0') to 'M' */
-   hyphenate(isn, isn+4, NULL, NULL);
+   hyphenate(isn, isn + 4, NULL, NULL);
    isn[0] = 'M';
 }
 static inline
-void ean2ISSN(char *isn)
+void
+ean2ISSN(char *isn)
 {
-   unsigned check;
+   unsigned    check;
+
    /* the number should come in this format: 977-0000-000-00-0 */
    /* Strip the first part, crop, and calculate the new check digit */
-   hyphenate(isn, isn+4, NULL, NULL);
+   hyphenate(isn, isn + 4, NULL, NULL);
    check = weight_checkdig(isn, 8);
-   if(check == 10) isn[8] = 'X';
-   else isn[8] = check + '0';
+   if (check == 10)
+       isn[8] = 'X';
+   else
+       isn[8] = check + '0';
    isn[9] = '\0';
 }
 static inline
-void ean2UPC(char *isn)
+void
+ean2UPC(char *isn)
 {
    /* the number should come in this format: 000-000000000-0 */
    /* Strip the first part, crop, and dehyphenate */
-   dehyphenate(isn, isn+1);
+   dehyphenate(isn, isn + 1);
    isn[12] = '\0';
 }
 
 /*
  * ean2* --- Converts a string of digits into an ean13 number.
- *            Assumes the input string is a string with only digits 
- *            on it, and that it's within the range of ean13.
+ *           Assumes the input string is a string with only digits
+ *           on it, and that it's within the range of ean13.
  *
  * Returns the ean13 value of the string.
  */
 static
-ean13 str2ean(const char *num) 
+ean13
+str2ean(const char *num)
 {
-   ean13 ean = 0;  /* current ean */
-   while(*num) {
-       if(isdigit((unsigned char) *num)) ean = 10 * ean + (*num - '0');
+   ean13       ean = 0;        /* current ean */
+
+   while (*num)
+   {
+       if (isdigit((unsigned char) *num))
+           ean = 10 * ean + (*num - '0');
        num++;
    }
-    return (ean<<1); /* also give room to a flag */
+   return (ean << 1);          /* also give room to a flag */
 }
 
 /*
  * ean2string --- Try to convert an ean13 number to an hyphenated string.
- *                Assumes there's enough space in result to hold
- *                the string (maximum MAXEAN13LEN+1 bytes)
- *                This doesn't verify for a valid check digit.
+ *               Assumes there's enough space in result to hold
+ *               the string (maximum MAXEAN13LEN+1 bytes)
+ *               This doesn't verify for a valid check digit.
  *
  * If shortType is true, the returned string is in the old ISxN short format.
  * If errorOK is false, ereport a useful error message if the string is bad.
  * If errorOK is true, just return "false" for bad input.
  */
 static
-bool ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
+bool
+ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
 {
    const char *(*TABLE)[2];
    const unsigned (*TABLE_index)[2];
    enum isn_type type = INVALID;
 
-   char *firstdig, *aux;
-   unsigned digval;
-   unsigned search;
-   char valid = '\0';              /* was the number initially written with a valid check digit? */
+   char       *firstdig,
+              *aux;
+   unsigned    digval;
+   unsigned    search;
+   char        valid = '\0';   /* was the number initially written with a
+                                * valid check digit? */
 
    TABLE_index = ISBN_index;
 
-   if((ean & 1)!=0) valid = '!';
+   if ((ean & 1) != 0)
+       valid = '!';
    ean >>= 1;
    /* verify it's in the EAN13 range */
-   if(ean > UINT64CONST(9999999999999))
+   if (ean > UINT64CONST(9999999999999))
        goto eantoobig;
 
    /* convert the number */
    search = 0;
    firstdig = aux = result + MAXEAN13LEN;
-   *aux = '\0';        /* terminate string; aux points to last digit */
-   *--aux = valid;     /* append '!' for numbers with invalid but corrected check digit */
-   do {
-       digval = (unsigned)(ean % 10);      /* get the decimal value */ 
-       ean /= 10;                                              /* get next digit */
-       *--aux = (char)(digval + '0');          /* convert to ascii and store */
-       if(search == 0) *--aux = '-';           /* the check digit is always there */
-   } while(ean && search++<13);
-   while(search++<13) *--aux = '0';            /* fill the remaining EAN13 with '0' */
+   *aux = '\0';                /* terminate string; aux points to last digit */
+   *--aux = valid;             /* append '!' for numbers with invalid but
+                                * corrected check digit */
+   do
+   {
+       digval = (unsigned) (ean % 10); /* get the decimal value */
+       ean /= 10;              /* get next digit */
+       *--aux = (char) (digval + '0'); /* convert to ascii and store */
+       if (search == 0)
+           *--aux = '-';       /* the check digit is always there */
+   } while (ean && search++ < 13);
+   while (search++ < 13)
+       *--aux = '0';           /* fill the remaining EAN13 with '0' */
 
    /* The string should be in this form: ???DDDDDDDDDDDD-D" */
-   search = hyphenate(result, result+3, EAN13_range, EAN13_index);
-   
+   search = hyphenate(result, result + 3, EAN13_range, EAN13_index);
+
    /* verify it's a logically valid EAN13 */
-   if(search == 0) {
-       search = hyphenate(result, result+3, NULL, NULL);
+   if (search == 0)
+   {
+       search = hyphenate(result, result + 3, NULL, NULL);
        goto okay;
    }
 
    /* find out what type of hyphenation is needed: */
-   if(!strncmp("978-", result, search)) { /* ISBN */
+   if (!strncmp("978-", result, search))
+   {                           /* ISBN */
        /* The string should be in this form: 978-??000000000-0" */
        type = ISBN;
        TABLE = ISBN_range;
        TABLE_index = ISBN_index;
-   } else if(!strncmp("977-", result, search)) { /* ISSN */
+   }
+   else if (!strncmp("977-", result, search))
+   {                           /* ISSN */
        /* The string should be in this form: 977-??000000000-0" */
        type = ISSN;
        TABLE = ISSN_range;
        TABLE_index = ISSN_index;
-   } else if(!strncmp("979-0", result, search+1)) { /* ISMN */
+   }
+   else if (!strncmp("979-0", result, search + 1))
+   {                           /* ISMN */
        /* The string should be in this form: 979-0?000000000-0" */
        type = ISMN;
        TABLE = ISMN_range;
        TABLE_index = ISMN_index;
-   } else if(*result == '0') { /* UPC */
+   }
+   else if (*result == '0')
+   {                           /* UPC */
        /* The string should be in this form: 000-00000000000-0" */
        type = UPC;
        TABLE = UPC_range;
        TABLE_index = UPC_index;
-   } else {
+   }
+   else
+   {
        type = EAN13;
        TABLE = NULL;
        TABLE_index = NULL;
@@ -501,18 +623,20 @@ bool ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
 
    /* verify it's a logically valid EAN13/UPC/ISxN */
    digval = search;
-   search = hyphenate(result+digval, result+digval+2, TABLE, TABLE_index);
+   search = hyphenate(result + digval, result + digval + 2, TABLE, TABLE_index);
 
    /* verify it's a valid EAN13 */
-   if(search == 0) {
-       search = hyphenate(result+digval, result+digval+2, NULL, NULL);
+   if (search == 0)
+   {
+       search = hyphenate(result + digval, result + digval + 2, NULL, NULL);
        goto okay;
    }
 
 okay:
    /* convert to the old short type: */
-   if(shortType) 
-       switch(type) {
+   if (shortType)
+       switch (type)
+       {
            case ISBN:
                ean2ISBN(result);
                break;
@@ -531,13 +655,13 @@ okay:
    return true;
 
 eantoobig:
-   if(!errorOK)
+   if (!errorOK)
    {
-       char    eanbuf[64];
+       char        eanbuf[64];
 
        /*
-        * Format the number separately to keep the machine-dependent
-        * format code out of the translatable message text
+        * Format the number separately to keep the machine-dependent format
+        * code out of the translatable message text
         */
        snprintf(eanbuf, sizeof(eanbuf), EAN13_FORMAT, ean);
        ereport(ERROR,
@@ -558,157 +682,222 @@ eantoobig:
  * (even if the check digit is valid)
  */
 static
-bool string2ean(const char *str, bool errorOK, ean13 *result,
-               enum isn_type accept)
+bool
+string2ean(const char *str, bool errorOK, ean13 * result,
+          enum isn_type accept)
 {
-   bool digit, last;
-   char buf[17] = "                ";
-   char *aux1 = buf + 3; /* leave space for the first part, in case it's needed */
+   bool        digit,
+               last;
+   char        buf[17] = "                ";
+   char       *aux1 = buf + 3; /* leave space for the first part, in case
+                                * it's needed */
    const char *aux2 = str;
    enum isn_type type = INVALID;
-   unsigned check = 0, rcheck = (unsigned)-1;
-   unsigned length = 0;
-   bool magic = false, valid = true;
+   unsigned    check = 0,
+               rcheck = (unsigned) -1;
+   unsigned    length = 0;
+   bool        magic = false,
+               valid = true;
 
    /* recognize and validate the number: */
-   while(*aux2 && length <= 13) {
-       last = (*(aux2+1) == '!' || *(aux2+1) == '\0'); /* is the last character */
-       digit = (isdigit((unsigned char) *aux2)!=0); /* is current character a digit? */
-       if(*aux2=='?' && last) /* automagically calculate check digit if it's '?' */
+   while (*aux2 && length <= 13)
+   {
+       last = (*(aux2 + 1) == '!' || *(aux2 + 1) == '\0');     /* is the last character */
+       digit = (isdigit((unsigned char) *aux2) != 0);  /* is current character
+                                                        * a digit? */
+       if (*aux2 == '?' && last)       /* automagically calculate check digit
+                                        * if it's '?' */
            magic = digit = true;
-       if(length == 0 &&  (*aux2=='M' || *aux2=='m')) {
+       if (length == 0 && (*aux2 == 'M' || *aux2 == 'm'))
+       {
            /* only ISMN can be here */
-           if(type != INVALID) goto eaninvalid;
+           if (type != INVALID)
+               goto eaninvalid;
            type = ISMN;
            *aux1++ = 'M';
            length++;
-       } else if(length == 7 && (digit || *aux2=='X' || *aux2=='x') && last) {
+       }
+       else if (length == 7 && (digit || *aux2 == 'X' || *aux2 == 'x') && last)
+       {
            /* only ISSN can be here */
-           if(type != INVALID) goto eaninvalid;
+           if (type != INVALID)
+               goto eaninvalid;
            type = ISSN;
            *aux1++ = toupper((unsigned char) *aux2);
            length++;
-       } else if(length == 9 && (digit || *aux2=='X' || *aux2=='x') && last) {
+       }
+       else if (length == 9 && (digit || *aux2 == 'X' || *aux2 == 'x') && last)
+       {
            /* only ISBN and ISMN can be here */
-           if(type != INVALID && type != ISMN) goto eaninvalid;
-           if(type == INVALID) type = ISBN; /* ISMN must start with 'M' */
+           if (type != INVALID && type != ISMN)
+               goto eaninvalid;
+           if (type == INVALID)
+               type = ISBN;    /* ISMN must start with 'M' */
            *aux1++ = toupper((unsigned char) *aux2);
            length++;
-       } else if(length == 11 && digit && last) {
+       }
+       else if (length == 11 && digit && last)
+       {
            /* only UPC can be here */
-           if(type != INVALID) goto eaninvalid;
+           if (type != INVALID)
+               goto eaninvalid;
            type = UPC;
            *aux1++ = *aux2;
            length++;
-       } else if(*aux2 == '-' || *aux2 == ' ') {
+       }
+       else if (*aux2 == '-' || *aux2 == ' ')
+       {
            /* skip, we could validate but I think it's worthless */
-       } else if(*aux2 == '!' && *(aux2+1) == '\0') {
+       }
+       else if (*aux2 == '!' && *(aux2 + 1) == '\0')
+       {
            /* the invalid check digit sufix was found, set it */
-           if(!magic) valid = false;
+           if (!magic)
+               valid = false;
            magic = true;
-       } else if(!digit) {
+       }
+       else if (!digit)
+       {
            goto eaninvalid;
-       } else {
+       }
+       else
+       {
            *aux1++ = *aux2;
-           if(++length > 13) goto eantoobig;
+           if (++length > 13)
+               goto eantoobig;
        }
        aux2++;
    }
-   *aux1 = '\0'; /* terminate the string */
+   *aux1 = '\0';               /* terminate the string */
 
    /* find the current check digit value */
-   if(length == 13) {
+   if (length == 13)
+   {
        /* only EAN13 can be here */
-       if(type != INVALID) goto eaninvalid;
+       if (type != INVALID)
+           goto eaninvalid;
        type = EAN13;
-       check = buf[15]-'0';
-   } else if(length == 12) {
+       check = buf[15] - '0';
+   }
+   else if (length == 12)
+   {
        /* only UPC can be here */
-       if(type != UPC) goto eaninvalid;
-       check = buf[14]-'0';
-   } else if(length == 10) {
-       if(type != ISBN && type != ISMN) goto eaninvalid;
-       if(buf[12] == 'X') check = 10;
-       else check = buf[12]-'0';
-   } else if(length == 8) {
-       if(type != INVALID && type != ISSN) goto eaninvalid;
+       if (type != UPC)
+           goto eaninvalid;
+       check = buf[14] - '0';
+   }
+   else if (length == 10)
+   {
+       if (type != ISBN && type != ISMN)
+           goto eaninvalid;
+       if (buf[12] == 'X')
+           check = 10;
+       else
+           check = buf[12] - '0';
+   }
+   else if (length == 8)
+   {
+       if (type != INVALID && type != ISSN)
+           goto eaninvalid;
        type = ISSN;
-       if(buf[10] == 'X') check = 10;
-       else check = buf[10]-'0';
-   } else goto eaninvalid;
-
-   if(type == INVALID) goto eaninvalid;
-
-   /* obtain the real check digit value, validate, and convert to ean13: */ 
-   if(accept == EAN13 && type != accept) goto eanwrongtype;
-   if(accept != ANY && type != EAN13 && type != accept) goto eanwrongtype;
-   switch(type) {
+       if (buf[10] == 'X')
+           check = 10;
+       else
+           check = buf[10] - '0';
+   }
+   else
+       goto eaninvalid;
+
+   if (type == INVALID)
+       goto eaninvalid;
+
+   /* obtain the real check digit value, validate, and convert to ean13: */
+   if (accept == EAN13 && type != accept)
+       goto eanwrongtype;
+   if (accept != ANY && type != EAN13 && type != accept)
+       goto eanwrongtype;
+   switch (type)
+   {
        case EAN13:
-           valid = (valid && ((rcheck=checkdig(buf+3, 13)) == check || magic));
+           valid = (valid && ((rcheck = checkdig(buf + 3, 13)) == check || magic));
            /* now get the subtype of EAN13: */
-           if(buf[3] == '0') type = UPC;
-           else if(!strncmp("977", buf+3, 3)) type = ISSN;
-           else if(!strncmp("978", buf+3, 3)) type = ISBN;
-           else if(!strncmp("9790", buf+3, 4)) type = ISMN;
-           else if(!strncmp("979", buf+3, 3)) type = ISBN;
-           if(accept != EAN13 && accept != ANY && type != accept) goto eanwrongtype;
+           if (buf[3] == '0')
+               type = UPC;
+           else if (!strncmp("977", buf + 3, 3))
+               type = ISSN;
+           else if (!strncmp("978", buf + 3, 3))
+               type = ISBN;
+           else if (!strncmp("9790", buf + 3, 4))
+               type = ISMN;
+           else if (!strncmp("979", buf + 3, 3))
+               type = ISBN;
+           if (accept != EAN13 && accept != ANY && type != accept)
+               goto eanwrongtype;
            break;
        case ISMN:
-           strncpy(buf, "9790", 4);  /* this isn't for sure yet, for now ISMN it's only 9790 */
-           valid = (valid && ((rcheck=checkdig(buf+3, 10)) == check || magic));
+           strncpy(buf, "9790", 4);    /* this isn't for sure yet, for now
+                                        * ISMN it's only 9790 */
+           valid = (valid && ((rcheck = checkdig(buf + 3, 10)) == check || magic));
            break;
        case ISBN:
            strncpy(buf, "978", 3);
-           valid = (valid && ((rcheck=weight_checkdig(buf+3, 10)) == check || magic));
+           valid = (valid && ((rcheck = weight_checkdig(buf + 3, 10)) == check || magic));
            break;
        case ISSN:
-           strncpy(buf+10, "00", 2); /* append 00 as the normal issue publication code */
+           strncpy(buf + 10, "00", 2); /* append 00 as the normal issue
+                                        * publication code */
            strncpy(buf, "977", 3);
-           valid = (valid && ((rcheck=weight_checkdig(buf+3, 8)) == check || magic));
+           valid = (valid && ((rcheck = weight_checkdig(buf + 3, 8)) == check || magic));
            break;
        case UPC:
            buf[2] = '0';
-           valid = (valid && ((rcheck=checkdig(buf+2, 13)) == check || magic));
+           valid = (valid && ((rcheck = checkdig(buf + 2, 13)) == check || magic));
        default:
            break;
    }
 
-  /* fix the check digit: */
-   for(aux1 = buf; *aux1 && *aux1 <= ' '; aux1++);
+   /* fix the check digit: */
+   for (aux1 = buf; *aux1 && *aux1 <= ' '; aux1++);
    aux1[12] = checkdig(aux1, 13) + '0';
    aux1[13] = '\0';
-   
-   if(!valid && !magic) goto eanbadcheck;
+
+   if (!valid && !magic)
+       goto eanbadcheck;
 
    *result = str2ean(aux1);
-   *result |= valid?0:1;
+   *result |= valid ? 0 : 1;
    return true;
 
-eanbadcheck: 
-   if(g_weak) { /* weak input mode is activated: */
-     /* set the "invalid-check-digit-on-input" flag */ 
+eanbadcheck:
+   if (g_weak)
+   {                           /* weak input mode is activated: */
+       /* set the "invalid-check-digit-on-input" flag */
        *result = str2ean(aux1);
        *result |= 1;
-   return true;
+       return true;
    }
 
-       if(!errorOK) {
-           if(rcheck == (unsigned)-1) {
-               ereport(ERROR,
+   if (!errorOK)
+   {
+       if (rcheck == (unsigned) -1)
+       {
+           ereport(ERROR,
                    (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
-                   errmsg("invalid %s number: \"%s\"",
+                    errmsg("invalid %s number: \"%s\"",
                            isn_names[accept], str)));
-           } else {
-               ereport(ERROR,
+       }
+       else
+       {
+           ereport(ERROR,
                    (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
-                   errmsg("invalid check digit for %s number: \"%s\", should be %c",
-                           isn_names[accept], str, (rcheck==10)?('X'):(rcheck+'0'))));
-           }
+           errmsg("invalid check digit for %s number: \"%s\", should be %c",
+                  isn_names[accept], str, (rcheck == 10) ? ('X') : (rcheck + '0'))));
        }
-       return false;
+   }
+   return false;
 
 eaninvalid:
-   if(!errorOK)
+   if (!errorOK)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                 errmsg("invalid input syntax for %s number: \"%s\"",
@@ -716,7 +905,7 @@ eaninvalid:
    return false;
 
 eanwrongtype:
-   if(!errorOK)
+   if (!errorOK)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                 errmsg("cannot cast %s to %s for number: \"%s\"",
@@ -724,11 +913,11 @@ eanwrongtype:
    return false;
 
 eantoobig:
-   if(!errorOK)
+   if (!errorOK)
        ereport(ERROR,
-           (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-            errmsg("value \"%s\" is out of range for %s type",
-                   str, isn_names[accept])));
+               (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+                errmsg("value \"%s\" is out of range for %s type",
+                       str, isn_names[accept])));
    return false;
 }
 
@@ -736,18 +925,19 @@ eantoobig:
  * Exported routines.
  *---------------------------------------------------------*/
 
-void initialize(void)
+void
+initialize(void)
 {
 #ifdef ISN_DEBUG
-   if(!check_table(EAN13, EAN13_index))
+   if (!check_table(EAN13, EAN13_index))
        elog(LOG, "EAN13 failed check");
-   if(!check_table(ISBN, ISBN_index))
+   if (!check_table(ISBN, ISBN_index))
        elog(LOG, "ISBN failed check");
-   if(!check_table(ISMN, ISMN_index))
+   if (!check_table(ISMN, ISMN_index))
        elog(LOG, "ISMN failed check");
-   if(!check_table(ISSN, ISSN_index))
+   if (!check_table(ISSN, ISSN_index))
        elog(LOG, "ISSN failed check");
-   if(!check_table(UPC, UPC_index))
+   if (!check_table(UPC, UPC_index))
        elog(LOG, "UPC failed check");
 #endif
    g_initialized = true;
@@ -791,7 +981,7 @@ PG_FUNCTION_INFO_V1(ean13_in);
 Datum
 ean13_in(PG_FUNCTION_ARGS)
 {
-   const char  *str = PG_GETARG_CSTRING(0);
+   const char *str = PG_GETARG_CSTRING(0);
    ean13       result;
 
    (void) string2ean(str, false, &result, EAN13);
@@ -804,7 +994,7 @@ PG_FUNCTION_INFO_V1(isbn_in);
 Datum
 isbn_in(PG_FUNCTION_ARGS)
 {
-   const char  *str = PG_GETARG_CSTRING(0);
+   const char *str = PG_GETARG_CSTRING(0);
    ean13       result;
 
    (void) string2ean(str, false, &result, ISBN);
@@ -817,7 +1007,7 @@ PG_FUNCTION_INFO_V1(ismn_in);
 Datum
 ismn_in(PG_FUNCTION_ARGS)
 {
-   const char  *str = PG_GETARG_CSTRING(0);
+   const char *str = PG_GETARG_CSTRING(0);
    ean13       result;
 
    (void) string2ean(str, false, &result, ISMN);
@@ -830,7 +1020,7 @@ PG_FUNCTION_INFO_V1(issn_in);
 Datum
 issn_in(PG_FUNCTION_ARGS)
 {
-   const char  *str = PG_GETARG_CSTRING(0);
+   const char *str = PG_GETARG_CSTRING(0);
    ean13       result;
 
    (void) string2ean(str, false, &result, ISSN);
@@ -843,7 +1033,7 @@ PG_FUNCTION_INFO_V1(upc_in);
 Datum
 upc_in(PG_FUNCTION_ARGS)
 {
-   const char  *str = PG_GETARG_CSTRING(0);
+   const char *str = PG_GETARG_CSTRING(0);
    ean13       result;
 
    (void) string2ean(str, false, &result, UPC);
@@ -861,7 +1051,7 @@ ean13_cast_to_text(PG_FUNCTION_ARGS)
 
    (void) ean2string(val, false, buf, false);
 
-    PG_RETURN_TEXT_P(GET_TEXT(buf));
+   PG_RETURN_TEXT_P(GET_TEXT(buf));
 }
 
 PG_FUNCTION_INFO_V1(isn_cast_to_text);
@@ -873,7 +1063,7 @@ isn_cast_to_text(PG_FUNCTION_ARGS)
 
    (void) ean2string(val, false, buf, true);
 
-    PG_RETURN_TEXT_P(GET_TEXT(buf));
+   PG_RETURN_TEXT_P(GET_TEXT(buf));
 }
 
 PG_FUNCTION_INFO_V1(isbn_cast_from_ean13);
@@ -929,7 +1119,7 @@ PG_FUNCTION_INFO_V1(ean13_cast_from_text);
 Datum
 ean13_cast_from_text(PG_FUNCTION_ARGS)
 {
-   const char  *str = GET_STR(PG_GETARG_TEXT_P(0));
+   const char *str = GET_STR(PG_GETARG_TEXT_P(0));
    ean13       result;
 
    (void) string2ean(str, false, &result, EAN13);
@@ -940,7 +1130,7 @@ PG_FUNCTION_INFO_V1(isbn_cast_from_text);
 Datum
 isbn_cast_from_text(PG_FUNCTION_ARGS)
 {
-   const char  *str = GET_STR(PG_GETARG_TEXT_P(0));
+   const char *str = GET_STR(PG_GETARG_TEXT_P(0));
    ean13       result;
 
    (void) string2ean(str, false, &result, ISBN);
@@ -951,7 +1141,7 @@ PG_FUNCTION_INFO_V1(ismn_cast_from_text);
 Datum
 ismn_cast_from_text(PG_FUNCTION_ARGS)
 {
-   const char  *str = GET_STR(PG_GETARG_TEXT_P(0));
+   const char *str = GET_STR(PG_GETARG_TEXT_P(0));
    ean13       result;
 
    (void) string2ean(str, false, &result, ISMN);
@@ -962,7 +1152,7 @@ PG_FUNCTION_INFO_V1(issn_cast_from_text);
 Datum
 issn_cast_from_text(PG_FUNCTION_ARGS)
 {
-   const char  *str = GET_STR(PG_GETARG_TEXT_P(0));
+   const char *str = GET_STR(PG_GETARG_TEXT_P(0));
    ean13       result;
 
    (void) string2ean(str, false, &result, ISSN);
@@ -973,7 +1163,7 @@ PG_FUNCTION_INFO_V1(upc_cast_from_text);
 Datum
 upc_cast_from_text(PG_FUNCTION_ARGS)
 {
-   const char  *str = GET_STR(PG_GETARG_TEXT_P(0));
+   const char *str = GET_STR(PG_GETARG_TEXT_P(0));
    ean13       result;
 
    (void) string2ean(str, false, &result, UPC);
@@ -986,7 +1176,8 @@ PG_FUNCTION_INFO_V1(is_valid);
 Datum
 is_valid(PG_FUNCTION_ARGS)
 {
-   ean13 val = PG_GETARG_EAN13(0);
+   ean13       val = PG_GETARG_EAN13(0);
+
    PG_RETURN_BOOL((val & 1) == 0);
 }
 
@@ -996,13 +1187,14 @@ PG_FUNCTION_INFO_V1(make_valid);
 Datum
 make_valid(PG_FUNCTION_ARGS)
 {
-   ean13 val = PG_GETARG_EAN13(0);
+   ean13       val = PG_GETARG_EAN13(0);
+
    val &= ~((ean13) 1);
    PG_RETURN_EAN13(val);
 }
 
 #ifdef ISN_WEAK_MODE
-/* this function temporarily sets weak input flag 
+/* this function temporarily sets weak input flag
  * (to lose the strictness of check digit acceptance)
  * It's a helper function, not intended to be used!!
  */
@@ -1021,7 +1213,7 @@ accept_weak_input(PG_FUNCTION_ARGS)
    /* function has no effect */
    PG_RETURN_BOOL(false);
 }
-#endif /* ISN_WEAK_MODE */
+#endif   /* ISN_WEAK_MODE */
 
 PG_FUNCTION_INFO_V1(weak_input_status);
 Datum
index 30bf2e029644a1056743bd1444bf37ebfab833f1..0bac6475478dc9b34e72ad901ff5d8be6463bab5 100644 (file)
@@ -219,7 +219,7 @@ sizebitvec(BITVECP sign)
                i;
 
    ALOOPBYTE(
-       size += number_of_ones[(unsigned char) sign[i]];
+             size += number_of_ones[(unsigned char) sign[i]];
    );
    return size;
 }
@@ -232,8 +232,8 @@ hemdistsign(BITVECP a, BITVECP b)
                dist = 0;
 
    ALOOPBYTE(
-       diff = (unsigned char) (a[i] ^ b[i]);
-       dist += number_of_ones[diff];
+             diff = (unsigned char) (a[i] ^ b[i]);
+   dist += number_of_ones[diff];
    );
    return dist;
 }
@@ -270,7 +270,7 @@ typedef struct
 {
    OffsetNumber pos;
    int4        cost;
-} SPLITCOST;
+}  SPLITCOST;
 
 static int
 comparecost(const void *a, const void *b)
@@ -580,6 +580,6 @@ _ltree_consistent(PG_FUNCTION_ARGS)
            /* internal error */
            elog(ERROR, "unrecognized StrategyNumber: %d", strategy);
    }
-   PG_FREE_IF_COPY(query,1);
+   PG_FREE_IF_COPY(query, 1);
    PG_RETURN_BOOL(res);
 }
index 07269ceaee6f3baf46e696f48abac07e8907ee46..8522c5e0538a0404842f8cd9c15e6057c6ce4c09 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * op function for ltree and lquery
  * Teodor Sigaev 
- * $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.10 2006/03/11 04:38:29 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.11 2006/10/04 00:29:45 momjian Exp $
  */
 
 #include "ltree.h"
@@ -46,7 +46,7 @@ getlexeme(char *start, char *end, int *len)
 }
 
 bool
-compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend)
+           compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend)
 {
    char       *endt = t->name + t->len;
    char       *endq = qn + len;
index b9058d5edff5687840adeb8ea34775cf330edaf6..1ff5707fb13a23ba3c7fd607f7dbc82cca221108 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.16 2006/07/11 16:00:44 teodor Exp $ */
+/* $PostgreSQL: pgsql/contrib/ltree/ltree.h,v 1.17 2006/10/04 00:29:45 momjian Exp $ */
 
 #ifndef __LTREE_H__
 #define __LTREE_H__
@@ -163,7 +163,7 @@ bool compare_subnode(ltree_level * t, char *q, int len,
 ltree     *lca_inner(ltree ** a, int len);
 
 #define PG_GETARG_LTREE(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
-#define PG_GETARG_LTREE_COPY(x)    ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
+#define PG_GETARG_LTREE_COPY(x) ((ltree*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
 #define PG_GETARG_LQUERY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
 #define PG_GETARG_LQUERY_COPY(x) ((lquery*)DatumGetPointer(PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(x))))
 #define PG_GETARG_LTXTQUERY(x) ((ltxtquery*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(x))))
index 5cfddd7634059f7a396d61792a36e537439b5a87..0239c5fe991c183444c51d3a04e16cdd6031f200 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * GiST support for ltree
  * Teodor Sigaev 
- * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.18 2006/08/08 15:45:18 teodor Exp $
+ * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.19 2006/10/04 00:29:45 momjian Exp $
  */
 
 #include "ltree.h"
@@ -457,8 +457,10 @@ gist_isparent(ltree_gist * key, ltree * query)
 }
 
 static ltree *
-copy_ltree( ltree *src ) {
-   ltree *dst = (ltree*)palloc(src->len);
+copy_ltree(ltree * src)
+{
+   ltree      *dst = (ltree *) palloc(src->len);
+
    memcpy(dst, src, src->len);
    return dst;
 }
@@ -466,9 +468,9 @@ copy_ltree( ltree *src ) {
 static bool
 gist_ischild(ltree_gist * key, ltree * query)
 {
-   ltree      *left = copy_ltree(LTG_GETLNODE(key));
-   ltree      *right = copy_ltree(LTG_GETRNODE(key));
-   bool            res = true;
+   ltree      *left = copy_ltree(LTG_GETLNODE(key));
+   ltree      *right = copy_ltree(LTG_GETRNODE(key));
+   bool        res = true;
 
    if (left->numlevel > query->numlevel)
        left->numlevel = query->numlevel;
@@ -711,6 +713,6 @@ ltree_consistent(PG_FUNCTION_ARGS)
            elog(ERROR, "unrecognized StrategyNumber: %d", strategy);
    }
 
-   PG_FREE_IF_COPY(query,1);
+   PG_FREE_IF_COPY(query, 1);
    PG_RETURN_BOOL(res);
 }
index f4348e0161fe01472e39eaba8c720f84345a7875..9b8a360ca897e2d56490009f5d6de860fd381727 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * op function for ltree
  * Teodor Sigaev 
- * $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.13 2006/09/20 19:50:21 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/ltree/ltree_op.c,v 1.14 2006/10/04 00:29:45 momjian Exp $
  */
 
 #include "ltree.h"
@@ -620,8 +620,8 @@ ltreeparentsel(PG_FUNCTION_ARGS)
        /*
         * If the histogram is large enough, see what fraction of it the
         * constant is "<@" to, and assume that's representative of the
-        * non-MCV population.  Otherwise use the default selectivity for
-        * the non-MCV population.
+        * non-MCV population.  Otherwise use the default selectivity for the
+        * non-MCV population.
         */
        selec = histogram_selectivity(&vardata, &contproc,
                                      constval, varonleft,
index 2d7392884eb068ca9daf6f7a48f51829ba5b43be..3c8af235d1020cd64df255dd897cda923328794d 100644 (file)
@@ -3,7 +3,7 @@
  * pg_buffercache_pages.c
  *   display some contents of the buffer cache
  *
- *   $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.8 2006/07/23 03:07:57 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.9 2006/10/04 00:29:45 momjian Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
@@ -74,7 +74,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
 
    if (SRF_IS_FIRSTCALL())
    {
-       int     i;
+       int         i;
        volatile BufferDesc *bufHdr;
 
        funcctx = SRF_FIRSTCALL_INIT();
@@ -123,9 +123,9 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
        MemoryContextSwitchTo(oldcontext);
 
        /*
-        * To get a consistent picture of the buffer state, we must lock
-        * all partitions of the buffer map.  Needless to say, this is
-        * horrible for concurrency...
+        * To get a consistent picture of the buffer state, we must lock all
+        * partitions of the buffer map.  Needless to say, this is horrible
+        * for concurrency...
         */
        for (i = 0; i < NUM_BUFFER_PARTITIONS; i++)
            LWLockAcquire(FirstBufMappingLock + i, LW_SHARED);
index 9ce8422157f50c2e7faf74fd39afba2bde506bb5..5486a98d486ab87fea66fefc8cd36c5d25a4a67a 100644 (file)
@@ -3,7 +3,7 @@
  * pg_freespacemap.c
  *   display some contents of the free space relation and page maps.
  *
- *   $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.7 2006/09/21 20:31:21 tgl Exp $
+ *   $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.8 2006/10/04 00:29:45 momjian Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
 #include "storage/freespace.h"
 
 
-#define        NUM_FREESPACE_PAGES_ELEM    5
-#define        NUM_FREESPACE_RELATIONS_ELEM    7
+#define        NUM_FREESPACE_PAGES_ELEM    5
+#define        NUM_FREESPACE_RELATIONS_ELEM    7
 
 #if defined(WIN32) || defined(__CYGWIN__)
 /* Need DLLIMPORT for some things that are not so marked in main headers */
-extern DLLIMPORT int   MaxFSMPages;
-extern DLLIMPORT int   MaxFSMRelations;
+extern DLLIMPORT int MaxFSMPages;
+extern DLLIMPORT int MaxFSMRelations;
 extern DLLIMPORT volatile uint32 InterruptHoldoffCount;
 #endif
 
@@ -35,12 +35,12 @@ Datum       pg_freespacemap_relations(PG_FUNCTION_ARGS);
  */
 typedef struct
 {
-   Oid             reltablespace;
-   Oid             reldatabase;
-   Oid             relfilenode;
-   BlockNumber     relblocknumber;
-   Size            bytes;
-   bool            isindex;
+   Oid         reltablespace;
+   Oid         reldatabase;
+   Oid         relfilenode;
+   BlockNumber relblocknumber;
+   Size        bytes;
+   bool        isindex;
 }  FreeSpacePagesRec;
 
 
@@ -49,14 +49,14 @@ typedef struct
  */
 typedef struct
 {
-   Oid             reltablespace;
-   Oid             reldatabase;
-   Oid             relfilenode;
-   Size            avgrequest;
-   BlockNumber     interestingpages;
-   int             storedpages;
-   int             nextpage;
-   bool            isindex;
+   Oid         reltablespace;
+   Oid         reldatabase;
+   Oid         relfilenode;
+   Size        avgrequest;
+   BlockNumber interestingpages;
+   int         storedpages;
+   int         nextpage;
+   bool        isindex;
 }  FreeSpaceRelationsRec;
 
 
@@ -66,8 +66,8 @@ typedef struct
  */
 typedef struct
 {
-   TupleDesc           tupdesc;
-   FreeSpacePagesRec   *record;
+   TupleDesc   tupdesc;
+   FreeSpacePagesRec *record;
 }  FreeSpacePagesContext;
 
 
@@ -76,8 +76,8 @@ typedef struct
  */
 typedef struct
 {
-   TupleDesc           tupdesc;
-   FreeSpaceRelationsRec   *record;
+   TupleDesc   tupdesc;
+   FreeSpaceRelationsRec *record;
 }  FreeSpaceRelationsContext;
 
 
@@ -89,21 +89,21 @@ PG_FUNCTION_INFO_V1(pg_freespacemap_pages);
 Datum
 pg_freespacemap_pages(PG_FUNCTION_ARGS)
 {
-   FuncCallContext         *funcctx;
-   Datum                   result;
-   MemoryContext           oldcontext;
-   FreeSpacePagesContext   *fctx;              /* User function context. */
-   TupleDesc               tupledesc;
-   HeapTuple               tuple;
-   FSMHeader               *FreeSpaceMap;      /* FSM main structure. */
-   FSMRelation             *fsmrel;            /* Individual relation. */
+   FuncCallContext *funcctx;
+   Datum       result;
+   MemoryContext oldcontext;
+   FreeSpacePagesContext *fctx;    /* User function context. */
+   TupleDesc   tupledesc;
+   HeapTuple   tuple;
+   FSMHeader  *FreeSpaceMap;   /* FSM main structure. */
+   FSMRelation *fsmrel;        /* Individual relation. */
 
    if (SRF_IS_FIRSTCALL())
    {
-       int             i;
-       int             numPages;   /* Max possible no. of pages in map. */
-       int             nPages;     /* Mapped pages for a relation. */
-       
+       int         i;
+       int         numPages;   /* Max possible no. of pages in map. */
+       int         nPages;     /* Mapped pages for a relation. */
+
        /*
         * Get the free space map data structure.
         */
@@ -138,8 +138,8 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
        fctx->tupdesc = BlessTupleDesc(tupledesc);
 
        /*
-        * Allocate numPages worth of FreeSpacePagesRec records, this is
-        * an upper bound.
+        * Allocate numPages worth of FreeSpacePagesRec records, this is an
+        * upper bound.
         */
        fctx->record = (FreeSpacePagesRec *) palloc(sizeof(FreeSpacePagesRec) * numPages);
 
@@ -147,16 +147,16 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
        MemoryContextSwitchTo(oldcontext);
 
        /*
-        * Lock free space map and scan though all the relations.
-        * For each relation, gets all its mapped pages.
+        * Lock free space map and scan though all the relations. For each
+        * relation, gets all its mapped pages.
         */
        LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
 
        i = 0;
 
-       for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage) 
+       for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage)
        {
-           if (fsmrel->isIndex)    
+           if (fsmrel->isIndex)
            {
                /* Index relation. */
                IndexFSMPageData *page;
@@ -169,9 +169,9 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
                    fctx->record[i].reltablespace = fsmrel->key.spcNode;
                    fctx->record[i].reldatabase = fsmrel->key.dbNode;
                    fctx->record[i].relfilenode = fsmrel->key.relNode;
-                   fctx->record[i].relblocknumber = IndexFSMPageGetPageNum(page);  
-                   fctx->record[i].bytes = 0;  
-                   fctx->record[i].isindex = true; 
+                   fctx->record[i].relblocknumber = IndexFSMPageGetPageNum(page);
+                   fctx->record[i].bytes = 0;
+                   fctx->record[i].isindex = true;
 
                    page++;
                    i++;
@@ -191,9 +191,9 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
                    fctx->record[i].reldatabase = fsmrel->key.dbNode;
                    fctx->record[i].relfilenode = fsmrel->key.relNode;
                    fctx->record[i].relblocknumber = FSMPageGetPageNum(page);
-                   fctx->record[i].bytes = FSMPageGetSpace(page);  
-                   fctx->record[i].isindex = false;    
-                   
+                   fctx->record[i].bytes = FSMPageGetSpace(page);
+                   fctx->record[i].isindex = false;
+
                    page++;
                    i++;
                }
@@ -216,7 +216,7 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
    if (funcctx->call_cntr < funcctx->max_calls)
    {
        int         i = funcctx->call_cntr;
-       FreeSpacePagesRec   *record = &fctx->record[i];
+       FreeSpacePagesRec *record = &fctx->record[i];
        Datum       values[NUM_FREESPACE_PAGES_ELEM];
        bool        nulls[NUM_FREESPACE_PAGES_ELEM];
 
@@ -261,20 +261,20 @@ PG_FUNCTION_INFO_V1(pg_freespacemap_relations);
 Datum
 pg_freespacemap_relations(PG_FUNCTION_ARGS)
 {
-   FuncCallContext         *funcctx;
-   Datum                   result;
-   MemoryContext           oldcontext;
-   FreeSpaceRelationsContext   *fctx;          /* User function context. */
-   TupleDesc               tupledesc;
-   HeapTuple               tuple;
-   FSMHeader               *FreeSpaceMap;      /* FSM main structure. */
-   FSMRelation             *fsmrel;            /* Individual relation. */
+   FuncCallContext *funcctx;
+   Datum       result;
+   MemoryContext oldcontext;
+   FreeSpaceRelationsContext *fctx;    /* User function context. */
+   TupleDesc   tupledesc;
+   HeapTuple   tuple;
+   FSMHeader  *FreeSpaceMap;   /* FSM main structure. */
+   FSMRelation *fsmrel;        /* Individual relation. */
 
    if (SRF_IS_FIRSTCALL())
    {
-       int             i;
-       int             numRelations;   /* Max no. of Relations in map. */
-       
+       int         i;
+       int         numRelations;       /* Max no. of Relations in map. */
+
        /*
         * Get the free space map data structure.
         */
@@ -313,8 +313,8 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
        fctx->tupdesc = BlessTupleDesc(tupledesc);
 
        /*
-        * Allocate numRelations worth of FreeSpaceRelationsRec records, 
-        * this is also an upper bound.
+        * Allocate numRelations worth of FreeSpaceRelationsRec records, this
+        * is also an upper bound.
         */
        fctx->record = (FreeSpaceRelationsRec *) palloc(sizeof(FreeSpaceRelationsRec) * numRelations);
 
@@ -328,12 +328,12 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
 
        i = 0;
 
-       for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage) 
+       for (fsmrel = FreeSpaceMap->usageList; fsmrel; fsmrel = fsmrel->nextUsage)
        {
            fctx->record[i].reltablespace = fsmrel->key.spcNode;
            fctx->record[i].reldatabase = fsmrel->key.dbNode;
            fctx->record[i].relfilenode = fsmrel->key.relNode;
-           fctx->record[i].avgrequest = (int64)fsmrel->avgRequest;
+           fctx->record[i].avgrequest = (int64) fsmrel->avgRequest;
            fctx->record[i].interestingpages = fsmrel->interestingPages;
            fctx->record[i].storedpages = fsmrel->storedPages;
            fctx->record[i].nextpage = fsmrel->nextPage;
@@ -358,7 +358,7 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
    if (funcctx->call_cntr < funcctx->max_calls)
    {
        int         i = funcctx->call_cntr;
-       FreeSpaceRelationsRec   *record = &fctx->record[i];
+       FreeSpaceRelationsRec *record = &fctx->record[i];
        Datum       values[NUM_FREESPACE_RELATIONS_ELEM];
        bool        nulls[NUM_FREESPACE_RELATIONS_ELEM];
 
@@ -368,6 +368,7 @@ pg_freespacemap_relations(PG_FUNCTION_ARGS)
        nulls[1] = false;
        values[2] = ObjectIdGetDatum(record->relfilenode);
        nulls[2] = false;
+
        /*
         * avgrequest isn't meaningful for an index
         */
index bfb92336d7d09f7ff16a9ece91c5c63b3c17d046..41a827ae0c3357a157a57983abb02745968a9097 100644 (file)
@@ -307,7 +307,7 @@ sizebitvec(BITVECP sign)
                i;
 
    LOOPBYTE(
-       size += number_of_ones[(unsigned char) sign[i]];
+            size += number_of_ones[(unsigned char) sign[i]];
    );
    return size;
 }
@@ -320,8 +320,8 @@ hemdistsign(BITVECP a, BITVECP b)
                dist = 0;
 
    LOOPBYTE(
-       diff = (unsigned char) (a[i] ^ b[i]);
-       dist += number_of_ones[diff];
+            diff = (unsigned char) (a[i] ^ b[i]);
+   dist += number_of_ones[diff];
    );
    return dist;
 }
@@ -393,7 +393,7 @@ typedef struct
 {
    OffsetNumber pos;
    int4        cost;
-} SPLITCOST;
+}  SPLITCOST;
 
 static int
 comparecost(const void *a, const void *b)
index 702bee80ba2c694a55c7bba54eafc57d466726c2..447e8487b0aab58e64cf2a1ee567cbe56782e7a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.55 2006/09/16 13:31:40 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.56 2006/10/04 00:29:45 momjian Exp $
  *
  * pgbench: a simple benchmark program for PostgreSQL
  * written by Tatsuo Ishii
@@ -136,7 +136,7 @@ int         num_files;          /* its number */
 static char *tpc_b = {
    "\\set nbranches :scale\n"
    "\\set ntellers 10 * :scale\n"
-    "\\set naccounts 100000 * :scale\n"
+   "\\set naccounts 100000 * :scale\n"
    "\\setrandom aid 1 :naccounts\n"
    "\\setrandom bid 1 :nbranches\n"
    "\\setrandom tid 1 :ntellers\n"
@@ -154,7 +154,7 @@ static char *tpc_b = {
 static char *simple_update = {
    "\\set nbranches :scale\n"
    "\\set ntellers 10 * :scale\n"
-    "\\set naccounts 100000 * :scale\n"
+   "\\set naccounts 100000 * :scale\n"
    "\\setrandom aid 1 :naccounts\n"
    "\\setrandom bid 1 :nbranches\n"
    "\\setrandom tid 1 :ntellers\n"
@@ -168,7 +168,7 @@ static char *simple_update = {
 
 /* -S case */
 static char *select_only = {
-    "\\set naccounts 100000 * :scale\n"
+   "\\set naccounts 100000 * :scale\n"
    "\\setrandom aid 1 :naccounts\n"
    "SELECT abalance FROM accounts WHERE aid = :aid;\n"
 };
@@ -338,7 +338,7 @@ putVariable(CState * st, char *name, char *value)
    }
    else
    {
-       char *val;
+       char       *val;
 
        if ((val = strdup(value)) == NULL)
            return false;
@@ -1009,14 +1009,16 @@ process_file(char *filename)
        while (isspace((unsigned char) buf[i]))
            i++;
 
-       if (buf[i] != '\0' && strncmp(&buf[i], "--", 2) != 0) {
+       if (buf[i] != '\0' && strncmp(&buf[i], "--", 2) != 0)
+       {
            commands = process_commands(&buf[i]);
            if (commands == NULL)
            {
                fclose(fd);
                return false;
            }
-       } else
+       }
+       else
            continue;
 
        my_commands[lineno] = commands;
@@ -1530,7 +1532,7 @@ main(int argc, char **argv)
        if (state[i].ecnt > prev_ecnt && commands[state[i].state]->type == META_COMMAND)
        {
            fprintf(stderr, "Client %d aborted in state %d. Execution meta-command failed.\n", i, state[i].state);
-           remains--;              /* I've aborted */
+           remains--;          /* I've aborted */
            PQfinish(state[i].con);
            state[i].con = NULL;
        }
@@ -1610,7 +1612,7 @@ main(int argc, char **argv)
            if (state[i].ecnt > prev_ecnt && commands[state[i].state]->type == META_COMMAND)
            {
                fprintf(stderr, "Client %d aborted in state %d. Execution meta-command failed.\n", i, state[i].state);
-               remains--;              /* I've aborted */
+               remains--;      /* I've aborted */
                PQfinish(state[i].con);
                state[i].con = NULL;
            }
index 30a35b1796b6e4172b29a5fee47317caeb308cab..c3ec01b9002661d91a4a53a9bef30579da6b6911 100644 (file)
@@ -2,7 +2,7 @@
  * Written by Solar Designer and placed in the public domain.
  * See crypt_blowfish.c for more information.
  *
- * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-gensalt.c,v 1.9 2006/07/13 04:15:24 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-gensalt.c,v 1.10 2006/10/04 00:29:46 momjian Exp $
  *
  * This file contains salt generation functions for the traditional and
  * other common crypt(3) algorithms, except for bcrypt which is defined
@@ -64,9 +64,9 @@ _crypt_gensalt_extended_rn(unsigned long count,
    output[2] = _crypt_itoa64[(count >> 6) & 0x3f];
    output[3] = _crypt_itoa64[(count >> 12) & 0x3f];
    output[4] = _crypt_itoa64[(count >> 18) & 0x3f];
-   value = (unsigned long)(unsigned char) input[0] |
-       ((unsigned long)(unsigned char) input[1] << 8) |
-       ((unsigned long)(unsigned char) input[2] << 16);
+   value = (unsigned long) (unsigned char) input[0] |
+       ((unsigned long) (unsigned char) input[1] << 8) |
+       ((unsigned long) (unsigned char) input[2] << 16);
    output[5] = _crypt_itoa64[value & 0x3f];
    output[6] = _crypt_itoa64[(value >> 6) & 0x3f];
    output[7] = _crypt_itoa64[(value >> 12) & 0x3f];
@@ -92,9 +92,9 @@ _crypt_gensalt_md5_rn(unsigned long count,
    output[0] = '$';
    output[1] = '1';
    output[2] = '$';
-   value = (unsigned long)(unsigned char) input[0] |
-       ((unsigned long)(unsigned char) input[1] << 8) |
-       ((unsigned long)(unsigned char) input[2] << 16);
+   value = (unsigned long) (unsigned char) input[0] |
+       ((unsigned long) (unsigned char) input[1] << 8) |
+       ((unsigned long) (unsigned char) input[2] << 16);
    output[3] = _crypt_itoa64[value & 0x3f];
    output[4] = _crypt_itoa64[(value >> 6) & 0x3f];
    output[5] = _crypt_itoa64[(value >> 12) & 0x3f];
@@ -103,9 +103,9 @@ _crypt_gensalt_md5_rn(unsigned long count,
 
    if (size >= 6 && output_size >= 3 + 4 + 4 + 1)
    {
-       value = (unsigned long)(unsigned char) input[3] |
-           ((unsigned long)(unsigned char) input[4] << 8) |
-           ((unsigned long)(unsigned char) input[5] << 16);
+       value = (unsigned long) (unsigned char) input[3] |
+           ((unsigned long) (unsigned char) input[4] << 8) |
+           ((unsigned long) (unsigned char) input[5] << 16);
        output[7] = _crypt_itoa64[value & 0x3f];
        output[8] = _crypt_itoa64[(value >> 6) & 0x3f];
        output[9] = _crypt_itoa64[(value >> 12) & 0x3f];
index 556a0e9e8e82d58d3f49f18df08dadc0ca70f97b..c05e334a998becb55291006344afc90713cd27f3 100644 (file)
@@ -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.7 2006/07/13 04:15:24 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/crypt-md5.c,v 1.8 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
@@ -24,7 +24,7 @@ static const char _crypt_a64[] =
 static void
 _crypt_to64(char *s, unsigned long v, int n)
 {
-       while (--n >= 0)
+   while (--n >= 0)
    {
        *s++ = _crypt_a64[v & 0x3f];
        v >>= 6;
index cd08fd2bc68def66e3caf696fe5722cfb0be6fa7..5a2596fe786cf25ef898da403f4709561cf02999 100644 (file)
@@ -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.7 2006/07/13 04:15:24 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/fortuna.c,v 1.8 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
@@ -365,8 +365,8 @@ rekey(FState * st)
 static void
 startup_tricks(FState * st)
 {
-   int i;
-   uint8 buf[BLOCK];
+   int         i;
+   uint8       buf[BLOCK];
 
    /* Use next block as counter. */
    encrypt_counter(st, st->counter);
index 6375fd7a889c0d54ac779ec6e09183a5053ad9de..197e24f74b7690a297b880fee2436da63e1281b2 100644 (file)
@@ -1,9 +1,9 @@
 /* imath version 1.3 */
 /*
-  Name:     imath.c
-  Purpose:  Arbitrary precision integer arithmetic routines.
-  Author:   M. J. Fromberger 
-  Info:     Id: imath.c 21 2006-04-02 18:58:36Z sting
+  Name:        imath.c
+  Purpose: Arbitrary precision integer arithmetic routines.
+  Author:  M. J. Fromberger 
+  Info:        Id: imath.c 21 2006-04-02 18:58:36Z sting
 
   Copyright (C) 2002 Michael J. Fromberger, All Rights Reserved.
 
   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-  NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   SOFTWARE.
  */
-/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.c,v 1.5 2006/09/22 21:39:57 tgl Exp $ */
+/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.c,v 1.6 2006/10/04 00:29:46 momjian Exp $ */
 
 #include "postgres.h"
 #include "px.h"
 
 /* {{{ Constants */
 
-const mp_result MP_OK     = 0;  /* no error, all is well  */
-const mp_result MP_FALSE  = 0;  /* boolean false          */
-const mp_result MP_TRUE   = -1; /* boolean true           */
-const mp_result MP_MEMORY = -2; /* out of memory          */
-const mp_result MP_RANGE  = -3; /* argument out of range  */
-const mp_result MP_UNDEF  = -4; /* result undefined       */
-const mp_result MP_TRUNC  = -5; /* output truncated       */
+const mp_result MP_OK = 0;     /* no error, all is well  */
+const mp_result MP_FALSE = 0;  /* boolean false          */
+const mp_result MP_TRUE = -1;  /* boolean true           */
+const mp_result MP_MEMORY = -2; /* out of memory         */
+const mp_result MP_RANGE = -3; /* argument out of range  */
+const mp_result MP_UNDEF = -4; /* result undefined       */
+const mp_result MP_TRUNC = -5; /* output truncated       */
 const mp_result MP_BADARG = -6; /* invalid null argument  */
 
-const mp_sign   MP_NEG  = 1;    /* value is strictly negative */
-const mp_sign   MP_ZPOS = 0;    /* value is non-negative      */
+const mp_sign MP_NEG = 1;      /* value is strictly negative */
+const mp_sign MP_ZPOS = 0;     /* value is non-negative      */
 
 static const char *s_unknown_err = "unknown result code";
 static const char *s_error_msg[] = {
-  "error code 0",
-  "boolean true",
-  "out of memory",
-  "argument out of range",
-  "result undefined",
-  "output truncated",
-  "invalid null argument",
-  NULL
+   "error code 0",
+   "boolean true",
+   "out of memory",
+   "argument out of range",
+   "result undefined",
+   "output truncated",
+   "invalid null argument",
+   NULL
 };
 
 /* }}} */
 
 /* Optional library flags */
-#define MP_CAP_DIGITS   1  /* flag bit to capitalize letter digits */
+#define MP_CAP_DIGITS  1       /* flag bit to capitalize letter digits */
 
-/* Argument checking macros 
+/* Argument checking macros
    Use CHECK() where a return value is required; NRCHECK() elsewhere */
 #define CHECK(TEST)   assert(TEST)
 #define NRCHECK(TEST) assert(TEST)
@@ -83,23 +83,23 @@ static const char *s_error_msg[] = {
    can compute log_i(n) = lg(n) * log_i(2).
  */
 static const double s_log2[] = {
-   0.000000000, 0.000000000, 1.000000000, 0.630929754,     /*  0  1  2  3 */
-   0.500000000, 0.430676558, 0.386852807, 0.356207187,     /*  4  5  6  7 */
-   0.333333333, 0.315464877, 0.301029996, 0.289064826,     /*  8  9 10 11 */
-   0.278942946, 0.270238154, 0.262649535, 0.255958025,     /* 12 13 14 15 */
-   0.250000000, 0.244650542, 0.239812467, 0.235408913,     /* 16 17 18 19 */
-   0.231378213, 0.227670249, 0.224243824, 0.221064729,     /* 20 21 22 23 */
-   0.218104292, 0.215338279, 0.212746054, 0.210309918,     /* 24 25 26 27 */
-   0.208014598, 0.205846832, 0.203795047, 0.201849087,     /* 28 29 30 31 */
-   0.200000000, 0.198239863, 0.196561632, 0.194959022,     /* 32 33 34 35 */
-   0.193426404, 0.191958720, 0.190551412, 0.189200360,     /* 36 37 38 39 */
-   0.187901825, 0.186652411, 0.185449023, 0.184288833,     /* 40 41 42 43 */
-   0.183169251, 0.182087900, 0.181042597, 0.180031327,     /* 44 45 46 47 */
-   0.179052232, 0.178103594, 0.177183820, 0.176291434,     /* 48 49 50 51 */
-   0.175425064, 0.174583430, 0.173765343, 0.172969690,     /* 52 53 54 55 */
-   0.172195434, 0.171441601, 0.170707280, 0.169991616,     /* 56 57 58 59 */
-   0.169293808, 0.168613099, 0.167948779, 0.167300179,     /* 60 61 62 63 */
-   0.166666667
+   0.000000000, 0.000000000, 1.000000000, 0.630929754, /* 0  1  2  3 */
+   0.500000000, 0.430676558, 0.386852807, 0.356207187, /* 4  5  6  7 */
+   0.333333333, 0.315464877, 0.301029996, 0.289064826, /* 8  9 10 11 */
+   0.278942946, 0.270238154, 0.262649535, 0.255958025, /* 12 13 14 15 */
+   0.250000000, 0.244650542, 0.239812467, 0.235408913, /* 16 17 18 19 */
+   0.231378213, 0.227670249, 0.224243824, 0.221064729, /* 20 21 22 23 */
+   0.218104292, 0.215338279, 0.212746054, 0.210309918, /* 24 25 26 27 */
+   0.208014598, 0.205846832, 0.203795047, 0.201849087, /* 28 29 30 31 */
+   0.200000000, 0.198239863, 0.196561632, 0.194959022, /* 32 33 34 35 */
+   0.193426404, 0.191958720, 0.190551412, 0.189200360, /* 36 37 38 39 */
+   0.187901825, 0.186652411, 0.185449023, 0.184288833, /* 40 41 42 43 */
+   0.183169251, 0.182087900, 0.181042597, 0.180031327, /* 44 45 46 47 */
+   0.179052232, 0.178103594, 0.177183820, 0.176291434, /* 48 49 50 51 */
+   0.175425064, 0.174583430, 0.173765343, 0.172969690, /* 52 53 54 55 */
+   0.172195434, 0.171441601, 0.170707280, 0.169991616, /* 56 57 58 59 */
+   0.169293808, 0.168613099, 0.167948779, 0.167300179, /* 60 61 62 63 */
+   0.166666667
 };
 
 /* }}} */
@@ -156,9 +156,9 @@ MP_USED(Z)=o_;CLAMP(Z);}while(0)
 do{mp_size ua_=MP_USED(X),o_=ua_+ua_;ZERO(MP_DIGITS(Z),o_);\
 (void) s_ksqr(MP_DIGITS(X),MP_DIGITS(Z),ua_);MP_USED(Z)=o_;CLAMP(Z);}while(0)
 
-#define UPPER_HALF(W)           ((mp_word)((W) >> MP_DIGIT_BIT))
-#define LOWER_HALF(W)           ((mp_digit)(W))
-#define HIGH_BIT_SET(W)         ((W) >> (MP_WORD_BIT - 1))
+#define UPPER_HALF(W)          ((mp_word)((W) >> MP_DIGIT_BIT))
+#define LOWER_HALF(W)          ((mp_digit)(W))
+#define HIGH_BIT_SET(W)            ((W) >> (MP_WORD_BIT - 1))
 #define ADD_WILL_OVERFLOW(W, V) ((MP_WORD_MAX - (V)) < (W))
 
 /* }}} */
@@ -175,6 +175,7 @@ static mp_word mp_flags = MP_CAP_DIGITS;
 /* Allocate a buffer of (at least) num digits, or return
    NULL if that couldn't be done.  */
 static mp_digit *s_alloc(mp_size num);
+
 #if TRACEABLE_FREE
 static void s_free(void *ptr);
 #else
@@ -183,97 +184,97 @@ static void s_free(void *ptr);
 
 /* Insure that z has at least min digits allocated, resizing if
    necessary.  Returns true if successful, false if out of memory. */
-static int       s_pad(mp_int z, mp_size min);
+static int s_pad(mp_int z, mp_size min);
 
 /* Normalize by removing leading zeroes (except when z = 0) */
 #if TRACEABLE_CLAMP
-static void      s_clamp(mp_int z);
+static void s_clamp(mp_int z);
 #endif
 
 /* Fill in a "fake" mp_int on the stack with a given value */
-static void      s_fake(mp_int z, int value, mp_digit vbuf[]);
+static void s_fake(mp_int z, int value, mp_digit vbuf[]);
 
 /* Compare two runs of digits of given length, returns <0, 0, >0 */
-static int       s_cdig(mp_digit *da, mp_digit *db, mp_size len);
+static int s_cdig(mp_digit * da, mp_digit * db, mp_size len);
 
 /* Pack the unsigned digits of v into array t */
-static int       s_vpack(int v, mp_digit t[]);
+static int s_vpack(int v, mp_digit t[]);
 
 /* Compare magnitudes of a and b, returns <0, 0, >0 */
-static int       s_ucmp(mp_int a, mp_int b);
+static int s_ucmp(mp_int a, mp_int b);
 
 /* Compare magnitudes of a and v, returns <0, 0, >0 */
-static int       s_vcmp(mp_int a, int v);
+static int s_vcmp(mp_int a, int v);
 
 /* Unsigned magnitude addition; assumes dc is big enough.
    Carry out is returned (no memory allocated). */
-static mp_digit  s_uadd(mp_digit *da, mp_digit *db, mp_digit *dc, 
-               mp_size size_a, mp_size size_b);
+static mp_digit s_uadd(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b);
 
-/* Unsigned magnitude subtraction.  Assumes dc is big enough. */
-static void      s_usub(mp_digit *da, mp_digit *db, mp_digit *dc,
-               mp_size size_a, mp_size size_b);
+/* Unsigned magnitude subtraction. Assumes dc is big enough. */
+static void s_usub(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b);
 
 /* Unsigned recursive multiplication.  Assumes dc is big enough. */
-static int       s_kmul(mp_digit *da, mp_digit *db, mp_digit *dc,
-           mp_size size_a, mp_size size_b);
+static int s_kmul(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b);
 
 /* Unsigned magnitude multiplication.  Assumes dc is big enough. */
-static void      s_umul(mp_digit *da, mp_digit *db, mp_digit *dc,
-           mp_size size_a, mp_size size_b);
+static void s_umul(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b);
 
 /* Unsigned recursive squaring.  Assumes dc is big enough. */
-static int       s_ksqr(mp_digit *da, mp_digit *dc, mp_size size_a);
+static int s_ksqr(mp_digit * da, mp_digit * dc, mp_size size_a);
 
 /* Unsigned magnitude squaring.  Assumes dc is big enough. */
-static void      s_usqr(mp_digit *da, mp_digit *dc, mp_size size_a);
+static void s_usqr(mp_digit * da, mp_digit * dc, mp_size size_a);
 
 /* Single digit addition.  Assumes a is big enough. */
-static void      s_dadd(mp_int a, mp_digit b);
+static void s_dadd(mp_int a, mp_digit b);
 
 /* Single digit multiplication.  Assumes a is big enough. */
-static void      s_dmul(mp_int a, mp_digit b);
+static void s_dmul(mp_int a, mp_digit b);
 
 /* Single digit multiplication on buffers; assumes dc is big enough. */
-static void      s_dbmul(mp_digit *da, mp_digit b, mp_digit *dc,
-            mp_size size_a);
+static void s_dbmul(mp_digit * da, mp_digit b, mp_digit * dc,
+       mp_size size_a);
 
-/* Single digit division.  Replaces a with the quotient, 
+/* Single digit division.  Replaces a with the quotient,
    returns the remainder.  */
-static mp_digit  s_ddiv(mp_int a, mp_digit b);
+static mp_digit s_ddiv(mp_int a, mp_digit b);
 
 /* Quick division by a power of 2, replaces z (no allocation) */
-static void      s_qdiv(mp_int z, mp_size p2);
+static void s_qdiv(mp_int z, mp_size p2);
 
 /* Quick remainder by a power of 2, replaces z (no allocation) */
-static void      s_qmod(mp_int z, mp_size p2);
+static void s_qmod(mp_int z, mp_size p2);
 
-/* Quick multiplication by a power of 2, replaces z. 
+/* Quick multiplication by a power of 2, replaces z.
    Allocates if necessary; returns false in case this fails. */
-static int       s_qmul(mp_int z, mp_size p2);
+static int s_qmul(mp_int z, mp_size p2);
 
 /* Quick subtraction from a power of 2, replaces z.
    Allocates if necessary; returns false in case this fails. */
-static int       s_qsub(mp_int z, mp_size p2);
+static int s_qsub(mp_int z, mp_size p2);
 
 /* Return maximum k such that 2^k divides z. */
-static int       s_dp2k(mp_int z);
+static int s_dp2k(mp_int z);
 
 /* Return k >= 0 such that z = 2^k, or -1 if there is no such k. */
-static int       s_isp2(mp_int z);
+static int s_isp2(mp_int z);
 
 /* Set z to 2^k.  May allocate; returns false in case this fails. */
-static int       s_2expt(mp_int z, int k);
+static int s_2expt(mp_int z, int k);
 
 /* Normalize a and b for division, returns normalization constant */
-static int       s_norm(mp_int a, mp_int b);
+static int s_norm(mp_int a, mp_int b);
 
 /* Compute constant mu for Barrett reduction, given modulus m, result
    replaces z, m is untouched. */
 static mp_result s_brmu(mp_int z, mp_int m);
 
 /* Reduce a modulo m, using Barrett's algorithm. */
-static int       s_reduce(mp_int x, mp_int m, mp_int mu, mp_int q1, mp_int q2);
+static int s_reduce(mp_int x, mp_int m, mp_int mu, mp_int q1, mp_int q2);
 
 /* Modular exponentiation, using Barrett reduction */
 static mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c);
@@ -284,22 +285,22 @@ static mp_result s_udiv(mp_int a, mp_int b);
 
 /* Compute the number of digits in radix r required to represent the
    given value.  Does not account for sign flags, terminators, etc. */
-static int       s_outlen(mp_int z, mp_size r);
+static int s_outlen(mp_int z, mp_size r);
 
 /* Guess how many digits of precision will be needed to represent a
    radix r value of the specified number of digits.  Returns a value
    guaranteed to be no smaller than the actual number required. */
-static mp_size   s_inlen(int len, mp_size r);
+static mp_size s_inlen(int len, mp_size r);
 
-/* Convert a character to a digit value in radix r, or 
+/* Convert a character to a digit value in radix r, or
    -1 if out of range */
-static int       s_ch2val(char c, int r);
+static int s_ch2val(char c, int r);
 
 /* Convert a digit value to a character */
-static char      s_val2ch(int v, int caps);
+static char s_val2ch(int v, int caps);
 
 /* Take 2's complement of a buffer in place */
-static void      s_2comp(unsigned char *buf, int len);
+static void s_2comp(unsigned char *buf, int len);
 
 /* Convert a value to binary, ignoring sign.  On input, *limpos is the
    bound on how many bytes should be written to buf; on output, *limpos
@@ -308,698 +309,804 @@ static mp_result s_tobin(mp_int z, unsigned char *buf, int *limpos, int pad);
 
 #if 0
 /* Dump a representation of the mp_int to standard output */
-void      s_print(char *tag, mp_int z);
-void      s_print_buf(char *tag, mp_digit *buf, mp_size num);
+void       s_print(char *tag, mp_int z);
+void       s_print_buf(char *tag, mp_digit * buf, mp_size num);
 #endif
 
 /* {{{ get_default_precision() */
 
-mp_size   mp_get_default_precision(void)
-{ 
-  return default_precision; 
+mp_size
+mp_get_default_precision(void)
+{
+   return default_precision;
 }
 
 /* }}} */
 
 /* {{{ mp_set_default_precision(s) */
 
-void      mp_set_default_precision(mp_size s)
-{ 
-  NRCHECK(s > 0);
+void
+mp_set_default_precision(mp_size s)
+{
+   NRCHECK(s > 0);
 
-  default_precision = (mp_size) ROUND_PREC(s);
+   default_precision = (mp_size) ROUND_PREC(s);
 }
 
 /* }}} */
 
 /* {{{ mp_get_multiply_threshold() */
 
-mp_size   mp_get_multiply_threshold(void)
+mp_size
+mp_get_multiply_threshold(void)
 {
-  return multiply_threshold;
+   return multiply_threshold;
 }
 
 /* }}} */
 
 /* {{{ mp_set_multiply_threshold(s) */
 
-void      mp_set_multiply_threshold(mp_size s)
+void
+mp_set_multiply_threshold(mp_size s)
 {
-  multiply_threshold = s;
+   multiply_threshold = s;
 }
 
 /* }}} */
 
 /* {{{ mp_int_init(z) */
 
-mp_result mp_int_init(mp_int z)
+mp_result
+mp_int_init(mp_int z)
 {
-  return mp_int_init_size(z, default_precision);
+   return mp_int_init_size(z, default_precision);
 }
 
 /* }}} */
 
 /* {{{ mp_int_alloc() */
 
-mp_int    mp_int_alloc(void)
+mp_int
+mp_int_alloc(void)
 {
-  mp_int out = px_alloc(sizeof(mpz_t));
+   mp_int      out = px_alloc(sizeof(mpz_t));
 
-  assert(out != NULL);
-  out->digits = NULL;
-  out->used   = 0;
-  out->alloc  = 0;
-  out->sign   = 0;
+   assert(out != NULL);
+   out->digits = NULL;
+   out->used = 0;
+   out->alloc = 0;
+   out->sign = 0;
 
-  return out;
+   return out;
 }
 
 /* }}} */
 
 /* {{{ mp_int_init_size(z, prec) */
 
-mp_result mp_int_init_size(mp_int z, mp_size prec)
+mp_result
+mp_int_init_size(mp_int z, mp_size prec)
 {
-  CHECK(z != NULL);
+   CHECK(z != NULL);
+
+   prec = (mp_size) ROUND_PREC(prec);
+   prec = MAX(prec, default_precision);
 
-  prec = (mp_size) ROUND_PREC(prec);
-  prec = MAX(prec, default_precision);
+   if ((MP_DIGITS(z) = s_alloc(prec)) == NULL)
+       return MP_MEMORY;
 
-  if((MP_DIGITS(z) = s_alloc(prec)) == NULL)
-    return MP_MEMORY;
+   z->digits[0] = 0;
+   MP_USED(z) = 1;
+   MP_ALLOC(z) = prec;
+   MP_SIGN(z) = MP_ZPOS;
 
-  z->digits[0] = 0;
-  MP_USED(z) = 1;
-  MP_ALLOC(z) = prec;
-  MP_SIGN(z) = MP_ZPOS;
-  
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_init_copy(z, old) */
 
-mp_result mp_int_init_copy(mp_int z, mp_int old)
+mp_result
+mp_int_init_copy(mp_int z, mp_int old)
 {
-  mp_result  res;
-  mp_size    uold, target;
+   mp_result   res;
+   mp_size     uold,
+               target;
 
-  CHECK(z != NULL && old != NULL);
+   CHECK(z != NULL && old != NULL);
 
-  uold = MP_USED(old);
-  target = MAX(uold, default_precision);
+   uold = MP_USED(old);
+   target = MAX(uold, default_precision);
 
-  if((res = mp_int_init_size(z, target)) != MP_OK)
-    return res;
+   if ((res = mp_int_init_size(z, target)) != MP_OK)
+       return res;
 
-  MP_USED(z) = uold;
-  MP_SIGN(z) = MP_SIGN(old);
-  COPY(MP_DIGITS(old), MP_DIGITS(z), uold);
+   MP_USED(z) = uold;
+   MP_SIGN(z) = MP_SIGN(old);
+   COPY(MP_DIGITS(old), MP_DIGITS(z), uold);
 
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_init_value(z, value) */
 
-mp_result mp_int_init_value(mp_int z, int value)
+mp_result
+mp_int_init_value(mp_int z, int value)
 {
-  mp_result res;
+   mp_result   res;
 
-  CHECK(z != NULL);
+   CHECK(z != NULL);
 
-  if((res = mp_int_init(z)) != MP_OK)
-    return res;
+   if ((res = mp_int_init(z)) != MP_OK)
+       return res;
 
-  return mp_int_set_value(z, value);
+   return mp_int_set_value(z, value);
 }
 
 /* }}} */
 
 /* {{{ mp_int_set_value(z, value) */
 
-mp_result  mp_int_set_value(mp_int z, int value)
+mp_result
+mp_int_set_value(mp_int z, int value)
 {
-  mp_size  ndig;
+   mp_size     ndig;
 
-  CHECK(z != NULL);
+   CHECK(z != NULL);
 
-  /* How many digits to copy */
-  ndig = (mp_size) MP_VALUE_DIGITS(value);
+   /* How many digits to copy */
+   ndig = (mp_size) MP_VALUE_DIGITS(value);
 
-  if(!s_pad(z, ndig))
-    return MP_MEMORY;
+   if (!s_pad(z, ndig))
+       return MP_MEMORY;
 
-  MP_USED(z) = (mp_size)s_vpack(value, MP_DIGITS(z));
-  MP_SIGN(z) = (value < 0) ? MP_NEG : MP_ZPOS;
+   MP_USED(z) = (mp_size) s_vpack(value, MP_DIGITS(z));
+   MP_SIGN(z) = (value < 0) ? MP_NEG : MP_ZPOS;
 
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_clear(z) */
 
-void      mp_int_clear(mp_int z)
+void
+mp_int_clear(mp_int z)
 {
-  if(z == NULL)
-    return;
+   if (z == NULL)
+       return;
 
-  if(MP_DIGITS(z) != NULL) {
-    s_free(MP_DIGITS(z));
-    MP_DIGITS(z) = NULL;
-  }
+   if (MP_DIGITS(z) != NULL)
+   {
+       s_free(MP_DIGITS(z));
+       MP_DIGITS(z) = NULL;
+   }
 }
 
 /* }}} */
 
 /* {{{ mp_int_free(z) */
 
-void      mp_int_free(mp_int z)
+void
+mp_int_free(mp_int z)
 {
-  NRCHECK(z != NULL);
+   NRCHECK(z != NULL);
 
-  if(z->digits != NULL)
-    mp_int_clear(z);
+   if (z->digits != NULL)
+       mp_int_clear(z);
 
-  px_free(z);
+   px_free(z);
 }
 
 /* }}} */
 
 /* {{{ mp_int_copy(a, c) */
 
-mp_result mp_int_copy(mp_int a, mp_int c)
+mp_result
+mp_int_copy(mp_int a, mp_int c)
 {
-  CHECK(a != NULL && c != NULL);
+   CHECK(a != NULL && c != NULL);
 
-  if(a != c) {
-    mp_size   ua = MP_USED(a);
-    mp_digit *da, *dc;
+   if (a != c)
+   {
+       mp_size     ua = MP_USED(a);
+       mp_digit   *da,
+                  *dc;
 
-    if(!s_pad(c, ua))
-      return MP_MEMORY;
+       if (!s_pad(c, ua))
+           return MP_MEMORY;
 
-    da = MP_DIGITS(a); dc = MP_DIGITS(c);
-    COPY(da, dc, ua);
+       da = MP_DIGITS(a);
+       dc = MP_DIGITS(c);
+       COPY(da, dc, ua);
 
-    MP_USED(c) = ua;
-    MP_SIGN(c) = MP_SIGN(a);
-  }
+       MP_USED(c) = ua;
+       MP_SIGN(c) = MP_SIGN(a);
+   }
 
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_swap(a, c) */
 
-void      mp_int_swap(mp_int a, mp_int c)
+void
+mp_int_swap(mp_int a, mp_int c)
 {
-  if(a != c) {
-    mpz_t tmp = *a;
+   if (a != c)
+   {
+       mpz_t       tmp = *a;
 
-    *a = *c;
-    *c = tmp;
-  }
+       *a = *c;
+       *c = tmp;
+   }
 }
 
 /* }}} */
 
 /* {{{ mp_int_zero(z) */
 
-void      mp_int_zero(mp_int z)
+void
+mp_int_zero(mp_int z)
 {
-  NRCHECK(z != NULL);
+   NRCHECK(z != NULL);
 
-  z->digits[0] = 0;
-  MP_USED(z) = 1;
-  MP_SIGN(z) = MP_ZPOS;
+   z->digits[0] = 0;
+   MP_USED(z) = 1;
+   MP_SIGN(z) = MP_ZPOS;
 }
 
 /* }}} */
 
 /* {{{ mp_int_abs(a, c) */
 
-mp_result mp_int_abs(mp_int a, mp_int c)
+mp_result
+mp_int_abs(mp_int a, mp_int c)
 {
-  mp_result res;
+   mp_result   res;
 
-  CHECK(a != NULL && c != NULL);
+   CHECK(a != NULL && c != NULL);
 
-  if((res = mp_int_copy(a, c)) != MP_OK)
-    return res;
+   if ((res = mp_int_copy(a, c)) != MP_OK)
+       return res;
 
-  MP_SIGN(c) = MP_ZPOS;
-  return MP_OK;
+   MP_SIGN(c) = MP_ZPOS;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_neg(a, c) */
 
-mp_result mp_int_neg(mp_int a, mp_int c)
+mp_result
+mp_int_neg(mp_int a, mp_int c)
 {
-  mp_result res;
+   mp_result   res;
 
-  CHECK(a != NULL && c != NULL);
+   CHECK(a != NULL && c != NULL);
 
-  if((res = mp_int_copy(a, c)) != MP_OK)
-    return res;
+   if ((res = mp_int_copy(a, c)) != MP_OK)
+       return res;
 
-  if(CMPZ(c) != 0)
-    MP_SIGN(c) = 1 - MP_SIGN(a);
+   if (CMPZ(c) != 0)
+       MP_SIGN(c) = 1 - MP_SIGN(a);
 
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_add(a, b, c) */
 
-mp_result mp_int_add(mp_int a, mp_int b, mp_int c)
-{ 
-  mp_size  ua, ub, uc, max;
-
-  CHECK(a != NULL && b != NULL && c != NULL);
-
-  ua = MP_USED(a); ub = MP_USED(b); uc = MP_USED(c);
-  max = MAX(ua, ub);
-
-  if(MP_SIGN(a) == MP_SIGN(b)) {
-    /* Same sign -- add magnitudes, preserve sign of addends */
-    mp_digit carry;
+mp_result
+mp_int_add(mp_int a, mp_int b, mp_int c)
+{
+   mp_size     ua,
+               ub,
+               uc,
+               max;
 
-    if(!s_pad(c, max))
-      return MP_MEMORY;
+   CHECK(a != NULL && b != NULL && c != NULL);
 
-    carry = s_uadd(MP_DIGITS(a), MP_DIGITS(b), MP_DIGITS(c), ua, ub);
-    uc = max;
+   ua = MP_USED(a);
+   ub = MP_USED(b);
+   uc = MP_USED(c);
+   max = MAX(ua, ub);
 
-    if(carry) {
-      if(!s_pad(c, max + 1))
-   return MP_MEMORY;
+   if (MP_SIGN(a) == MP_SIGN(b))
+   {
+       /* Same sign -- add magnitudes, preserve sign of addends */
+       mp_digit    carry;
 
-      c->digits[max] = carry;
-      ++uc;
-    }
+       if (!s_pad(c, max))
+           return MP_MEMORY;
 
-    MP_USED(c) = uc;
-    MP_SIGN(c) = MP_SIGN(a);
+       carry = s_uadd(MP_DIGITS(a), MP_DIGITS(b), MP_DIGITS(c), ua, ub);
+       uc = max;
 
-  } 
-  else {
-    /* Different signs -- subtract magnitudes, preserve sign of greater */
-    mp_int  x, y;
-    int     cmp = s_ucmp(a, b); /* magnitude comparision, sign ignored */
+       if (carry)
+       {
+           if (!s_pad(c, max + 1))
+               return MP_MEMORY;
 
-    /* Set x to max(a, b), y to min(a, b) to simplify later code */
-    if(cmp >= 0) {
-      x = a; y = b;
-    } 
-    else {
-      x = b; y = a; 
-    }
+           c->digits[max] = carry;
+           ++uc;
+       }
 
-    if(!s_pad(c, MP_USED(x)))
-      return MP_MEMORY;
+       MP_USED(c) = uc;
+       MP_SIGN(c) = MP_SIGN(a);
 
-    /* Subtract smaller from larger */
-    s_usub(MP_DIGITS(x), MP_DIGITS(y), MP_DIGITS(c), MP_USED(x), MP_USED(y));
-    MP_USED(c) = MP_USED(x);
-    CLAMP(c);
-    
-    /* Give result the sign of the larger */
-    MP_SIGN(c) = MP_SIGN(x);
-  }
+   }
+   else
+   {
+       /* Different signs -- subtract magnitudes, preserve sign of greater */
+       mp_int      x,
+                   y;
+       int         cmp = s_ucmp(a, b); /* magnitude comparision, sign ignored */
+
+       /* Set x to max(a, b), y to min(a, b) to simplify later code */
+       if (cmp >= 0)
+       {
+           x = a;
+           y = b;
+       }
+       else
+       {
+           x = b;
+           y = a;
+       }
+
+       if (!s_pad(c, MP_USED(x)))
+           return MP_MEMORY;
+
+       /* Subtract smaller from larger */
+       s_usub(MP_DIGITS(x), MP_DIGITS(y), MP_DIGITS(c), MP_USED(x), MP_USED(y));
+       MP_USED(c) = MP_USED(x);
+       CLAMP(c);
+
+       /* Give result the sign of the larger */
+       MP_SIGN(c) = MP_SIGN(x);
+   }
 
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_add_value(a, value, c) */
 
-mp_result mp_int_add_value(mp_int a, int value, mp_int c)
+mp_result
+mp_int_add_value(mp_int a, int value, mp_int c)
 {
-  mpz_t     vtmp;
-  mp_digit  vbuf[MP_VALUE_DIGITS(value)];
+   mpz_t       vtmp;
+   mp_digit    vbuf[MP_VALUE_DIGITS(value)];
 
-  s_fake(&vtmp, value, vbuf);
+   s_fake(&vtmp, value, vbuf);
 
-  return mp_int_add(a, &vtmp, c);
+   return mp_int_add(a, &vtmp, c);
 }
 
 /* }}} */
 
 /* {{{ mp_int_sub(a, b, c) */
 
-mp_result mp_int_sub(mp_int a, mp_int b, mp_int c)
+mp_result
+mp_int_sub(mp_int a, mp_int b, mp_int c)
 {
-  mp_size  ua, ub, uc, max;
+   mp_size     ua,
+               ub,
+               uc,
+               max;
 
-  CHECK(a != NULL && b != NULL && c != NULL);
+   CHECK(a != NULL && b != NULL && c != NULL);
 
-  ua = MP_USED(a); ub = MP_USED(b); uc = MP_USED(c);
-  max = MAX(ua, ub);
+   ua = MP_USED(a);
+   ub = MP_USED(b);
+   uc = MP_USED(c);
+   max = MAX(ua, ub);
 
-  if(MP_SIGN(a) != MP_SIGN(b)) {
-    /* Different signs -- add magnitudes and keep sign of a */
-    mp_digit carry;
+   if (MP_SIGN(a) != MP_SIGN(b))
+   {
+       /* Different signs -- add magnitudes and keep sign of a */
+       mp_digit    carry;
 
-    if(!s_pad(c, max))
-      return MP_MEMORY;
+       if (!s_pad(c, max))
+           return MP_MEMORY;
 
-    carry = s_uadd(MP_DIGITS(a), MP_DIGITS(b), MP_DIGITS(c), ua, ub);
-    uc = max;
+       carry = s_uadd(MP_DIGITS(a), MP_DIGITS(b), MP_DIGITS(c), ua, ub);
+       uc = max;
 
-    if(carry) {
-      if(!s_pad(c, max + 1))
-   return MP_MEMORY;
+       if (carry)
+       {
+           if (!s_pad(c, max + 1))
+               return MP_MEMORY;
 
-      c->digits[max] = carry;
-      ++uc;
-    }
+           c->digits[max] = carry;
+           ++uc;
+       }
 
-    MP_USED(c) = uc;
-    MP_SIGN(c) = MP_SIGN(a);
+       MP_USED(c) = uc;
+       MP_SIGN(c) = MP_SIGN(a);
 
-  } 
-  else {
-    /* Same signs -- subtract magnitudes */
-    mp_int  x, y;
-    mp_sign osign;
-    int     cmp = s_ucmp(a, b);
+   }
+   else
+   {
+       /* Same signs -- subtract magnitudes */
+       mp_int      x,
+                   y;
+       mp_sign     osign;
+       int         cmp = s_ucmp(a, b);
+
+       if (!s_pad(c, max))
+           return MP_MEMORY;
+
+       if (cmp >= 0)
+       {
+           x = a;
+           y = b;
+           osign = MP_ZPOS;
+       }
+       else
+       {
+           x = b;
+           y = a;
+           osign = MP_NEG;
+       }
+
+       if (MP_SIGN(a) == MP_NEG && cmp != 0)
+           osign = 1 - osign;
+
+       s_usub(MP_DIGITS(x), MP_DIGITS(y), MP_DIGITS(c), MP_USED(x), MP_USED(y));
+       MP_USED(c) = MP_USED(x);
+       CLAMP(c);
+
+       MP_SIGN(c) = osign;
+   }
 
-    if(!s_pad(c, max))
-      return MP_MEMORY;
+   return MP_OK;
+}
 
-    if(cmp >= 0) {
-      x = a; y = b; osign = MP_ZPOS;
-    } 
-    else {
-      x = b; y = a; osign = MP_NEG;
-    }
+/* }}} */
 
-    if(MP_SIGN(a) == MP_NEG && cmp != 0)
-      osign = 1 - osign;
+/* {{{ mp_int_sub_value(a, value, c) */
 
-    s_usub(MP_DIGITS(x), MP_DIGITS(y), MP_DIGITS(c), MP_USED(x), MP_USED(y));
-    MP_USED(c) = MP_USED(x);
-    CLAMP(c);
+mp_result
+mp_int_sub_value(mp_int a, int value, mp_int c)
+{
+   mpz_t       vtmp;
+   mp_digit    vbuf[MP_VALUE_DIGITS(value)];
 
-    MP_SIGN(c) = osign;
-  }
+   s_fake(&vtmp, value, vbuf);
 
-  return MP_OK;
+   return mp_int_sub(a, &vtmp, c);
 }
 
 /* }}} */
 
-/* {{{ mp_int_sub_value(a, value, c) */
+/* {{{ mp_int_mul(a, b, c) */
 
-mp_result mp_int_sub_value(mp_int a, int value, mp_int c)
+mp_result
+mp_int_mul(mp_int a, mp_int b, mp_int c)
 {
-  mpz_t     vtmp;
-  mp_digit  vbuf[MP_VALUE_DIGITS(value)];
+   mp_digit   *out;
+   mp_size     osize,
+               ua,
+               ub,
+               p = 0;
+   mp_sign     osign;
 
-  s_fake(&vtmp, value, vbuf);
+   CHECK(a != NULL && b != NULL && c != NULL);
 
-  return mp_int_sub(a, &vtmp, c);
-}
+   /* If either input is zero, we can shortcut multiplication */
+   if (mp_int_compare_zero(a) == 0 || mp_int_compare_zero(b) == 0)
+   {
+       mp_int_zero(c);
+       return MP_OK;
+   }
 
-/* }}} */
+   /* Output is positive if inputs have same sign, otherwise negative */
+   osign = (MP_SIGN(a) == MP_SIGN(b)) ? MP_ZPOS : MP_NEG;
 
-/* {{{ mp_int_mul(a, b, c) */
+   /*
+    * If the output is not equal to any of the inputs, we'll write the
+    * results there directly; otherwise, allocate a temporary space.
+    */
+   ua = MP_USED(a);
+   ub = MP_USED(b);
+   osize = ua + ub;
+
+   if (c == a || c == b)
+   {
+       p = ROUND_PREC(osize);
+       p = MAX(p, default_precision);
+
+       if ((out = s_alloc(p)) == NULL)
+           return MP_MEMORY;
+   }
+   else
+   {
+       if (!s_pad(c, osize))
+           return MP_MEMORY;
 
-mp_result mp_int_mul(mp_int a, mp_int b, mp_int c)
-{ 
-  mp_digit *out;
-  mp_size   osize, ua, ub, p = 0;
-  mp_sign   osign;
-
-  CHECK(a != NULL && b != NULL && c != NULL);
-
-  /* If either input is zero, we can shortcut multiplication */
-  if(mp_int_compare_zero(a) == 0 || mp_int_compare_zero(b) == 0) {
-    mp_int_zero(c);
-    return MP_OK;
-  }
-  
-  /* Output is positive if inputs have same sign, otherwise negative */
-  osign = (MP_SIGN(a) == MP_SIGN(b)) ? MP_ZPOS : MP_NEG;
-
-  /* If the output is not equal to any of the inputs, we'll write the
-     results there directly; otherwise, allocate a temporary space. */
-  ua = MP_USED(a); ub = MP_USED(b);
-  osize = ua + ub;
-
-  if(c == a || c == b) {
-    p = ROUND_PREC(osize);
-    p = MAX(p, default_precision);
-
-    if((out = s_alloc(p)) == NULL)
-      return MP_MEMORY;
-  } 
-  else {
-    if(!s_pad(c, osize))
-      return MP_MEMORY;
-    
-    out = MP_DIGITS(c);
-  }
-  ZERO(out, osize);
-
-  if(!s_kmul(MP_DIGITS(a), MP_DIGITS(b), out, ua, ub))
-    return MP_MEMORY;
-
-  /* If we allocated a new buffer, get rid of whatever memory c was
-     already using, and fix up its fields to reflect that.
-   */
-  if(out != MP_DIGITS(c)) {
-    s_free(MP_DIGITS(c));
-    MP_DIGITS(c) = out;
-    MP_ALLOC(c) = p;
-  }
-
-  MP_USED(c) = osize; /* might not be true, but we'll fix it ... */
-  CLAMP(c);           /* ... right here */
-  MP_SIGN(c) = osign;
-  
-  return MP_OK;
+       out = MP_DIGITS(c);
+   }
+   ZERO(out, osize);
+
+   if (!s_kmul(MP_DIGITS(a), MP_DIGITS(b), out, ua, ub))
+       return MP_MEMORY;
+
+   /*
+    * If we allocated a new buffer, get rid of whatever memory c was already
+    * using, and fix up its fields to reflect that.
+    */
+   if (out != MP_DIGITS(c))
+   {
+       s_free(MP_DIGITS(c));
+       MP_DIGITS(c) = out;
+       MP_ALLOC(c) = p;
+   }
+
+   MP_USED(c) = osize;         /* might not be true, but we'll fix it ... */
+   CLAMP(c);                   /* ... right here */
+   MP_SIGN(c) = osign;
+
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_mul_value(a, value, c) */
 
-mp_result mp_int_mul_value(mp_int a, int value, mp_int c)
+mp_result
+mp_int_mul_value(mp_int a, int value, mp_int c)
 {
-  mpz_t     vtmp;
-  mp_digit  vbuf[MP_VALUE_DIGITS(value)];
+   mpz_t       vtmp;
+   mp_digit    vbuf[MP_VALUE_DIGITS(value)];
 
-  s_fake(&vtmp, value, vbuf);
+   s_fake(&vtmp, value, vbuf);
 
-  return mp_int_mul(a, &vtmp, c);
+   return mp_int_mul(a, &vtmp, c);
 }
 
 /* }}} */
 
 /* {{{ mp_int_mul_pow2(a, p2, c) */
 
-mp_result mp_int_mul_pow2(mp_int a, int p2, mp_int c)
+mp_result
+mp_int_mul_pow2(mp_int a, int p2, mp_int c)
 {
-  mp_result res;
-  CHECK(a != NULL && c != NULL && p2 >= 0);
+   mp_result   res;
 
-  if((res = mp_int_copy(a, c)) != MP_OK)
-    return res;
+   CHECK(a != NULL && c != NULL && p2 >= 0);
 
-  if(s_qmul(c, (mp_size) p2))
-    return MP_OK;
-  else
-    return MP_MEMORY;
+   if ((res = mp_int_copy(a, c)) != MP_OK)
+       return res;
+
+   if (s_qmul(c, (mp_size) p2))
+       return MP_OK;
+   else
+       return MP_MEMORY;
 }
 
 /* }}} */
 
 /* {{{ mp_int_sqr(a, c) */
 
-mp_result mp_int_sqr(mp_int a, mp_int c)
-{ 
-  mp_digit *out;
-  mp_size   osize, p = 0;
+mp_result
+mp_int_sqr(mp_int a, mp_int c)
+{
+   mp_digit   *out;
+   mp_size     osize,
+               p = 0;
 
-  CHECK(a != NULL && c != NULL);
+   CHECK(a != NULL && c != NULL);
 
-  /* Get a temporary buffer big enough to hold the result */
-  osize = (mp_size) 2 * MP_USED(a);
-  if(a == c) {
-    p = ROUND_PREC(osize);
-    p = MAX(p, default_precision);
+   /* Get a temporary buffer big enough to hold the result */
+   osize = (mp_size) 2 *MP_USED(a);
 
-    if((out = s_alloc(p)) == NULL)
-      return MP_MEMORY;
-  } 
-  else {
-    if(!s_pad(c, osize)) 
-      return MP_MEMORY;
+   if (a == c)
+   {
+       p = ROUND_PREC(osize);
+       p = MAX(p, default_precision);
 
-    out = MP_DIGITS(c);
-  }
-  ZERO(out, osize);
+       if ((out = s_alloc(p)) == NULL)
+           return MP_MEMORY;
+   }
+   else
+   {
+       if (!s_pad(c, osize))
+           return MP_MEMORY;
 
-  s_ksqr(MP_DIGITS(a), out, MP_USED(a));
+       out = MP_DIGITS(c);
+   }
+   ZERO(out, osize);
+
+   s_ksqr(MP_DIGITS(a), out, MP_USED(a));
+
+   /*
+    * Get rid of whatever memory c was already using, and fix up its fields
+    * to reflect the new digit array it's using
+    */
+   if (out != MP_DIGITS(c))
+   {
+       s_free(MP_DIGITS(c));
+       MP_DIGITS(c) = out;
+       MP_ALLOC(c) = p;
+   }
 
-  /* Get rid of whatever memory c was already using, and fix up its
-     fields to reflect the new digit array it's using
-   */
-  if(out != MP_DIGITS(c)) {
-    s_free(MP_DIGITS(c));
-    MP_DIGITS(c) = out;
-    MP_ALLOC(c) = p;
-  }
+   MP_USED(c) = osize;         /* might not be true, but we'll fix it ... */
+   CLAMP(c);                   /* ... right here */
+   MP_SIGN(c) = MP_ZPOS;
 
-  MP_USED(c) = osize; /* might not be true, but we'll fix it ... */
-  CLAMP(c);           /* ... right here */
-  MP_SIGN(c) = MP_ZPOS;
-  
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_div(a, b, q, r) */
 
-mp_result mp_int_div(mp_int a, mp_int b, mp_int q, mp_int r)
-{
-  int       cmp, last = 0, lg;
-  mp_result res = MP_OK;
-  mpz_t     temp[2];
-  mp_int    qout, rout;
-  mp_sign   sa = MP_SIGN(a), sb = MP_SIGN(b);
-
-  CHECK(a != NULL && b != NULL && q != r);
-  
-  if(CMPZ(b) == 0)
-    return MP_UNDEF;
-  else if((cmp = s_ucmp(a, b)) < 0) {
-    /* If |a| < |b|, no division is required:
-       q = 0, r = a
-     */
-    if(r && (res = mp_int_copy(a, r)) != MP_OK)
-      return res;
-
-    if(q)
-      mp_int_zero(q);
-
-    return MP_OK;
-  } 
-  else if(cmp == 0) {
-    /* If |a| = |b|, no division is required:
-       q = 1 or -1, r = 0
-     */
-    if(r)
-      mp_int_zero(r);
-
-    if(q) {
-      mp_int_zero(q);
-      q->digits[0] = 1;
-
-      if(sa != sb)
-   MP_SIGN(q) = MP_NEG;
-    }
-
-    return MP_OK;
-  } 
-
-  /* When |a| > |b|, real division is required.  We need someplace to
-     store quotient and remainder, but q and r are allowed to be NULL
-     or to overlap with the inputs.
-   */
-  if((lg = s_isp2(b)) < 0) {
-    if(q && b != q && (res = mp_int_copy(a, q)) == MP_OK) {
-      qout = q;
-    } 
-    else {
-      qout = TEMP(last);
-      SETUP(mp_int_init_copy(TEMP(last), a), last);
-    }
-
-    if(r && a != r && (res = mp_int_copy(b, r)) == MP_OK) {
-      rout = r;
-    } 
-    else {
-      rout = TEMP(last);
-      SETUP(mp_int_init_copy(TEMP(last), b), last);
-    }
-
-    if((res = s_udiv(qout, rout)) != MP_OK) goto CLEANUP;
-  } 
-  else {
-    if(q && (res = mp_int_copy(a, q)) != MP_OK) goto CLEANUP;
-    if(r && (res = mp_int_copy(a, r)) != MP_OK) goto CLEANUP;
-
-    if(q) s_qdiv(q, (mp_size) lg); qout = q;
-    if(r) s_qmod(r, (mp_size) lg); rout = r;
-  }
-
-  /* Recompute signs for output */
-  if(rout) { 
-    MP_SIGN(rout) = sa;
-    if(CMPZ(rout) == 0)
-      MP_SIGN(rout) = MP_ZPOS;
-  }
-  if(qout) {
-    MP_SIGN(qout) = (sa == sb) ? MP_ZPOS : MP_NEG;
-    if(CMPZ(qout) == 0)
-      MP_SIGN(qout) = MP_ZPOS;
-  }
-
-  if(q && (res = mp_int_copy(qout, q)) != MP_OK) goto CLEANUP;
-  if(r && (res = mp_int_copy(rout, r)) != MP_OK) goto CLEANUP;
-
- CLEANUP:
-  while(--last >= 0)
-    mp_int_clear(TEMP(last));
-
-  return res;
+mp_result
+mp_int_div(mp_int a, mp_int b, mp_int q, mp_int r)
+{
+   int         cmp,
+               last = 0,
+               lg;
+   mp_result   res = MP_OK;
+   mpz_t       temp[2];
+   mp_int      qout,
+               rout;
+   mp_sign     sa = MP_SIGN(a),
+               sb = MP_SIGN(b);
+
+   CHECK(a != NULL && b != NULL && q != r);
+
+   if (CMPZ(b) == 0)
+       return MP_UNDEF;
+   else if ((cmp = s_ucmp(a, b)) < 0)
+   {
+       /*
+        * If |a| < |b|, no division is required: q = 0, r = a
+        */
+       if (r && (res = mp_int_copy(a, r)) != MP_OK)
+           return res;
+
+       if (q)
+           mp_int_zero(q);
+
+       return MP_OK;
+   }
+   else if (cmp == 0)
+   {
+       /*
+        * If |a| = |b|, no division is required: q = 1 or -1, r = 0
+        */
+       if (r)
+           mp_int_zero(r);
+
+       if (q)
+       {
+           mp_int_zero(q);
+           q->digits[0] = 1;
+
+           if (sa != sb)
+               MP_SIGN(q) = MP_NEG;
+       }
+
+       return MP_OK;
+   }
+
+   /*
+    * When |a| > |b|, real division is required.  We need someplace to store
+    * quotient and remainder, but q and r are allowed to be NULL or to
+    * overlap with the inputs.
+    */
+   if ((lg = s_isp2(b)) < 0)
+   {
+       if (q && b != q && (res = mp_int_copy(a, q)) == MP_OK)
+       {
+           qout = q;
+       }
+       else
+       {
+           qout = TEMP(last);
+           SETUP(mp_int_init_copy(TEMP(last), a), last);
+       }
+
+       if (r && a != r && (res = mp_int_copy(b, r)) == MP_OK)
+       {
+           rout = r;
+       }
+       else
+       {
+           rout = TEMP(last);
+           SETUP(mp_int_init_copy(TEMP(last), b), last);
+       }
+
+       if ((res = s_udiv(qout, rout)) != MP_OK)
+           goto CLEANUP;
+   }
+   else
+   {
+       if (q && (res = mp_int_copy(a, q)) != MP_OK)
+           goto CLEANUP;
+       if (r && (res = mp_int_copy(a, r)) != MP_OK)
+           goto CLEANUP;
+
+       if (q)
+           s_qdiv(q, (mp_size) lg);
+       qout = q;
+       if (r)
+           s_qmod(r, (mp_size) lg);
+       rout = r;
+   }
+
+   /* Recompute signs for output */
+   if (rout)
+   {
+       MP_SIGN(rout) = sa;
+       if (CMPZ(rout) == 0)
+           MP_SIGN(rout) = MP_ZPOS;
+   }
+   if (qout)
+   {
+       MP_SIGN(qout) = (sa == sb) ? MP_ZPOS : MP_NEG;
+       if (CMPZ(qout) == 0)
+           MP_SIGN(qout) = MP_ZPOS;
+   }
+
+   if (q && (res = mp_int_copy(qout, q)) != MP_OK)
+       goto CLEANUP;
+   if (r && (res = mp_int_copy(rout, r)) != MP_OK)
+       goto CLEANUP;
+
+CLEANUP:
+   while (--last >= 0)
+       mp_int_clear(TEMP(last));
+
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_mod(a, m, c) */
 
-mp_result mp_int_mod(mp_int a, mp_int m, mp_int c)
+mp_result
+mp_int_mod(mp_int a, mp_int m, mp_int c)
 {
-  mp_result res;
-  mpz_t     tmp;
-  mp_int    out;
+   mp_result   res;
+   mpz_t       tmp;
+   mp_int      out;
 
-  if(m == c) {
-    if((res = mp_int_init(&tmp)) != MP_OK)
-      return res;
+   if (m == c)
+   {
+       if ((res = mp_int_init(&tmp)) != MP_OK)
+           return res;
 
-    out = &tmp;
-  } 
-  else {
-    out = c;
-  }
+       out = &tmp;
+   }
+   else
+   {
+       out = c;
+   }
 
-  if((res = mp_int_div(a, m, NULL, out)) != MP_OK)
-    goto CLEANUP;
+   if ((res = mp_int_div(a, m, NULL, out)) != MP_OK)
+       goto CLEANUP;
 
-  if(CMPZ(out) < 0)
-    res = mp_int_add(out, m, c);
-  else
-    res = mp_int_copy(out, c);
+   if (CMPZ(out) < 0)
+       res = mp_int_add(out, m, c);
+   else
+       res = mp_int_copy(out, c);
 
- CLEANUP:
-  if(out != c)
-    mp_int_clear(&tmp);
+CLEANUP:
+   if (out != c)
+       mp_int_clear(&tmp);
 
-  return res;
+   return res;
 }
 
 /* }}} */
@@ -1007,379 +1114,416 @@ mp_result mp_int_mod(mp_int a, mp_int m, mp_int c)
 
 /* {{{ mp_int_div_value(a, value, q, r) */
 
-mp_result mp_int_div_value(mp_int a, int value, mp_int q, int *r)
+mp_result
+mp_int_div_value(mp_int a, int value, mp_int q, int *r)
 {
-  mpz_t     vtmp, rtmp;
-  mp_digit  vbuf[MP_VALUE_DIGITS(value)];
-  mp_result res;
+   mpz_t       vtmp,
+               rtmp;
+   mp_digit    vbuf[MP_VALUE_DIGITS(value)];
+   mp_result   res;
 
-  if((res = mp_int_init(&rtmp)) != MP_OK) return res;
-  s_fake(&vtmp, value, vbuf);
+   if ((res = mp_int_init(&rtmp)) != MP_OK)
+       return res;
+   s_fake(&vtmp, value, vbuf);
 
-  if((res = mp_int_div(a, &vtmp, q, &rtmp)) != MP_OK)
-    goto CLEANUP;
+   if ((res = mp_int_div(a, &vtmp, q, &rtmp)) != MP_OK)
+       goto CLEANUP;
 
-  if(r)
-    (void) mp_int_to_int(&rtmp, r); /* can't fail */
+   if (r)
+       (void) mp_int_to_int(&rtmp, r); /* can't fail */
 
- CLEANUP:
-  mp_int_clear(&rtmp);
-  return res;
+CLEANUP:
+   mp_int_clear(&rtmp);
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_div_pow2(a, p2, q, r) */
 
-mp_result mp_int_div_pow2(mp_int a, int p2, mp_int q, mp_int r)
+mp_result
+mp_int_div_pow2(mp_int a, int p2, mp_int q, mp_int r)
 {
-  mp_result res = MP_OK;
+   mp_result   res = MP_OK;
+
+   CHECK(a != NULL && p2 >= 0 && q != r);
 
-  CHECK(a != NULL && p2 >= 0 && q != r);
+   if (q != NULL && (res = mp_int_copy(a, q)) == MP_OK)
+       s_qdiv(q, (mp_size) p2);
 
-  if(q != NULL && (res = mp_int_copy(a, q)) == MP_OK)
-    s_qdiv(q, (mp_size) p2);
-  
-  if(res == MP_OK && r != NULL && (res = mp_int_copy(a, r)) == MP_OK)
-    s_qmod(r, (mp_size) p2);
+   if (res == MP_OK && r != NULL && (res = mp_int_copy(a, r)) == MP_OK)
+       s_qmod(r, (mp_size) p2);
 
-  return res;
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_expt(a, b, c) */
 
-mp_result mp_int_expt(mp_int a, int b, mp_int c)
+mp_result
+mp_int_expt(mp_int a, int b, mp_int c)
 {
-  mpz_t     t;
-  mp_result res;
-  unsigned int v = abs(b);
-  
-  CHECK(b >= 0 && c != NULL);
+   mpz_t       t;
+   mp_result   res;
+   unsigned int v = abs(b);
 
-  if((res = mp_int_init_copy(&t, a)) != MP_OK)
-    return res;
+   CHECK(b >= 0 && c != NULL);
 
-  (void) mp_int_set_value(c, 1);
-  while(v != 0) {
-    if(v & 1) {
-      if((res = mp_int_mul(c, &t, c)) != MP_OK)
-   goto CLEANUP;
-    }
+   if ((res = mp_int_init_copy(&t, a)) != MP_OK)
+       return res;
 
-    v >>= 1;
-    if(v == 0) break;
+   (void) mp_int_set_value(c, 1);
+   while (v != 0)
+   {
+       if (v & 1)
+       {
+           if ((res = mp_int_mul(c, &t, c)) != MP_OK)
+               goto CLEANUP;
+       }
 
-    if((res = mp_int_sqr(&t, &t)) != MP_OK)
-      goto CLEANUP;
-  }
-  
- CLEANUP:
-  mp_int_clear(&t);
-  return res;
+       v >>= 1;
+       if (v == 0)
+           break;
+
+       if ((res = mp_int_sqr(&t, &t)) != MP_OK)
+           goto CLEANUP;
+   }
+
+CLEANUP:
+   mp_int_clear(&t);
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_expt_value(a, b, c) */
 
-mp_result mp_int_expt_value(int a, int b, mp_int c)
+mp_result
+mp_int_expt_value(int a, int b, mp_int c)
 {
-  mpz_t     t;
-  mp_result res;
-  unsigned int v = abs(b);
-  
-  CHECK(b >= 0 && c != NULL);
+   mpz_t       t;
+   mp_result   res;
+   unsigned int v = abs(b);
+
+   CHECK(b >= 0 && c != NULL);
 
-  if((res = mp_int_init_value(&t, a)) != MP_OK)
-    return res;
+   if ((res = mp_int_init_value(&t, a)) != MP_OK)
+       return res;
 
-  (void) mp_int_set_value(c, 1);
-  while(v != 0) {
-    if(v & 1) {
-      if((res = mp_int_mul(c, &t, c)) != MP_OK)
-   goto CLEANUP;
-    }
+   (void) mp_int_set_value(c, 1);
+   while (v != 0)
+   {
+       if (v & 1)
+       {
+           if ((res = mp_int_mul(c, &t, c)) != MP_OK)
+               goto CLEANUP;
+       }
 
-    v >>= 1;
-    if(v == 0) break;
+       v >>= 1;
+       if (v == 0)
+           break;
 
-    if((res = mp_int_sqr(&t, &t)) != MP_OK)
-      goto CLEANUP;
-  }
-  
- CLEANUP:
-  mp_int_clear(&t);
-  return res;
+       if ((res = mp_int_sqr(&t, &t)) != MP_OK)
+           goto CLEANUP;
+   }
+
+CLEANUP:
+   mp_int_clear(&t);
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_compare(a, b) */
 
-int       mp_int_compare(mp_int a, mp_int b)
-{ 
-  mp_sign sa;
+int
+mp_int_compare(mp_int a, mp_int b)
+{
+   mp_sign     sa;
 
-  CHECK(a != NULL && b != NULL);
+   CHECK(a != NULL && b != NULL);
 
-  sa = MP_SIGN(a);
-  if(sa == MP_SIGN(b)) {
-    int cmp = s_ucmp(a, b);
+   sa = MP_SIGN(a);
+   if (sa == MP_SIGN(b))
+   {
+       int         cmp = s_ucmp(a, b);
 
-    /* If they're both zero or positive, the normal comparison
-       applies; if both negative, the sense is reversed. */
-    if(sa == MP_ZPOS) 
-      return cmp;
-    else
-      return -cmp;
+       /*
+        * If they're both zero or positive, the normal comparison applies; if
+        * both negative, the sense is reversed.
+        */
+       if (sa == MP_ZPOS)
+           return cmp;
+       else
+           return -cmp;
 
-  } 
-  else {
-    if(sa == MP_ZPOS)
-      return 1;
-    else
-      return -1;
-  }
+   }
+   else
+   {
+       if (sa == MP_ZPOS)
+           return 1;
+       else
+           return -1;
+   }
 }
 
 /* }}} */
 
 /* {{{ mp_int_compare_unsigned(a, b) */
 
-int       mp_int_compare_unsigned(mp_int a, mp_int b)
-{ 
-  NRCHECK(a != NULL && b != NULL);
+int
+mp_int_compare_unsigned(mp_int a, mp_int b)
+{
+   NRCHECK(a != NULL && b != NULL);
 
-  return s_ucmp(a, b);
+   return s_ucmp(a, b);
 }
 
 /* }}} */
 
 /* {{{ mp_int_compare_zero(z) */
 
-int       mp_int_compare_zero(mp_int z)
-{ 
-  NRCHECK(z != NULL);
+int
+mp_int_compare_zero(mp_int z)
+{
+   NRCHECK(z != NULL);
 
-  if(MP_USED(z) == 1 && z->digits[0] == 0)
-    return 0;
-  else if(MP_SIGN(z) == MP_ZPOS)
-    return 1;
-  else 
-    return -1;
+   if (MP_USED(z) == 1 && z->digits[0] == 0)
+       return 0;
+   else if (MP_SIGN(z) == MP_ZPOS)
+       return 1;
+   else
+       return -1;
 }
 
 /* }}} */
 
 /* {{{ mp_int_compare_value(z, value) */
 
-int       mp_int_compare_value(mp_int z, int value)
+int
+mp_int_compare_value(mp_int z, int value)
 {
-  mp_sign vsign = (value < 0) ? MP_NEG : MP_ZPOS;
-  int     cmp;
+   mp_sign     vsign = (value < 0) ? MP_NEG : MP_ZPOS;
+   int         cmp;
 
-  CHECK(z != NULL);
+   CHECK(z != NULL);
 
-  if(vsign == MP_SIGN(z)) {
-    cmp = s_vcmp(z, value);
+   if (vsign == MP_SIGN(z))
+   {
+       cmp = s_vcmp(z, value);
 
-    if(vsign == MP_ZPOS)
-      return cmp;
-    else
-      return -cmp;
-  } 
-  else {
-    if(value < 0)
-      return 1;
-    else
-      return -1;
-  }
+       if (vsign == MP_ZPOS)
+           return cmp;
+       else
+           return -cmp;
+   }
+   else
+   {
+       if (value < 0)
+           return 1;
+       else
+           return -1;
+   }
 }
 
 /* }}} */
 
 /* {{{ mp_int_exptmod(a, b, m, c) */
 
-mp_result mp_int_exptmod(mp_int a, mp_int b, mp_int m, mp_int c)
-{ 
-  mp_result res;
-  mp_size   um;
-  mpz_t     temp[3];
-  mp_int    s;
-  int       last = 0;
+mp_result
+mp_int_exptmod(mp_int a, mp_int b, mp_int m, mp_int c)
+{
+   mp_result   res;
+   mp_size     um;
+   mpz_t       temp[3];
+   mp_int      s;
+   int         last = 0;
 
-  CHECK(a != NULL && b != NULL && c != NULL && m != NULL);
+   CHECK(a != NULL && b != NULL && c != NULL && m != NULL);
 
-  /* Zero moduli and negative exponents are not considered. */
-  if(CMPZ(m) == 0)
-    return MP_UNDEF;
-  if(CMPZ(b) < 0)
-    return MP_RANGE;
+   /* Zero moduli and negative exponents are not considered. */
+   if (CMPZ(m) == 0)
+       return MP_UNDEF;
+   if (CMPZ(b) < 0)
+       return MP_RANGE;
 
-  um = MP_USED(m);
-  SETUP(mp_int_init_size(TEMP(0), 2 * um), last);
-  SETUP(mp_int_init_size(TEMP(1), 2 * um), last);
+   um = MP_USED(m);
+   SETUP(mp_int_init_size(TEMP(0), 2 * um), last);
+   SETUP(mp_int_init_size(TEMP(1), 2 * um), last);
 
-  if(c == b || c == m) {
-    SETUP(mp_int_init_size(TEMP(2), 2 * um), last);
-    s = TEMP(2);
-  } 
-  else {
-    s = c;
-  }
-  
-  if((res = mp_int_mod(a, m, TEMP(0))) != MP_OK) goto CLEANUP;
+   if (c == b || c == m)
+   {
+       SETUP(mp_int_init_size(TEMP(2), 2 * um), last);
+       s = TEMP(2);
+   }
+   else
+   {
+       s = c;
+   }
 
-  if((res = s_brmu(TEMP(1), m)) != MP_OK) goto CLEANUP;
+   if ((res = mp_int_mod(a, m, TEMP(0))) != MP_OK)
+       goto CLEANUP;
 
-  if((res = s_embar(TEMP(0), b, m, TEMP(1), s)) != MP_OK)
-    goto CLEANUP;
+   if ((res = s_brmu(TEMP(1), m)) != MP_OK)
+       goto CLEANUP;
 
-  res = mp_int_copy(s, c);
+   if ((res = s_embar(TEMP(0), b, m, TEMP(1), s)) != MP_OK)
+       goto CLEANUP;
 
- CLEANUP:
-  while(--last >= 0)
-    mp_int_clear(TEMP(last));
+   res = mp_int_copy(s, c);
 
-  return res;
+CLEANUP:
+   while (--last >= 0)
+       mp_int_clear(TEMP(last));
+
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_exptmod_evalue(a, value, m, c) */
 
-mp_result mp_int_exptmod_evalue(mp_int a, int value, mp_int m, mp_int c)
+mp_result
+mp_int_exptmod_evalue(mp_int a, int value, mp_int m, mp_int c)
 {
-  mpz_t    vtmp;
-  mp_digit vbuf[MP_VALUE_DIGITS(value)];
+   mpz_t       vtmp;
+   mp_digit    vbuf[MP_VALUE_DIGITS(value)];
 
-  s_fake(&vtmp, value, vbuf);
+   s_fake(&vtmp, value, vbuf);
 
-  return mp_int_exptmod(a, &vtmp, m, c);
+   return mp_int_exptmod(a, &vtmp, m, c);
 }
 
 /* }}} */
 
 /* {{{ mp_int_exptmod_bvalue(v, b, m, c) */
 
-mp_result mp_int_exptmod_bvalue(int value, mp_int b,
-               mp_int m, mp_int c)
+mp_result
+mp_int_exptmod_bvalue(int value, mp_int b,
+                     mp_int m, mp_int c)
 {
-  mpz_t    vtmp;
-  mp_digit vbuf[MP_VALUE_DIGITS(value)];
+   mpz_t       vtmp;
+   mp_digit    vbuf[MP_VALUE_DIGITS(value)];
 
-  s_fake(&vtmp, value, vbuf);
+   s_fake(&vtmp, value, vbuf);
 
-  return mp_int_exptmod(&vtmp, b, m, c);
+   return mp_int_exptmod(&vtmp, b, m, c);
 }
 
 /* }}} */
 
 /* {{{ mp_int_exptmod_known(a, b, m, mu, c) */
 
-mp_result mp_int_exptmod_known(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
+mp_result
+mp_int_exptmod_known(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
 {
-  mp_result res;
-  mp_size   um;
-  mpz_t     temp[2];
-  mp_int    s;
-  int       last = 0;
+   mp_result   res;
+   mp_size     um;
+   mpz_t       temp[2];
+   mp_int      s;
+   int         last = 0;
+
+   CHECK(a && b && m && c);
 
-  CHECK(a && b && m && c);
+   /* Zero moduli and negative exponents are not considered. */
+   if (CMPZ(m) == 0)
+       return MP_UNDEF;
+   if (CMPZ(b) < 0)
+       return MP_RANGE;
 
-  /* Zero moduli and negative exponents are not considered. */
-  if(CMPZ(m) == 0)
-    return MP_UNDEF;
-  if(CMPZ(b) < 0)
-    return MP_RANGE;
+   um = MP_USED(m);
+   SETUP(mp_int_init_size(TEMP(0), 2 * um), last);
 
-  um = MP_USED(m);
-  SETUP(mp_int_init_size(TEMP(0), 2 * um), last);
+   if (c == b || c == m)
+   {
+       SETUP(mp_int_init_size(TEMP(1), 2 * um), last);
+       s = TEMP(1);
+   }
+   else
+   {
+       s = c;
+   }
 
-  if(c == b || c == m) {
-    SETUP(mp_int_init_size(TEMP(1), 2 * um), last);
-    s = TEMP(1);
-  } 
-  else {
-    s = c;
-  }
-  
-  if((res = mp_int_mod(a, m, TEMP(0))) != MP_OK) goto CLEANUP;
+   if ((res = mp_int_mod(a, m, TEMP(0))) != MP_OK)
+       goto CLEANUP;
 
-  if((res = s_embar(TEMP(0), b, m, mu, s)) != MP_OK)
-    goto CLEANUP;
+   if ((res = s_embar(TEMP(0), b, m, mu, s)) != MP_OK)
+       goto CLEANUP;
 
-  res = mp_int_copy(s, c);
+   res = mp_int_copy(s, c);
 
- CLEANUP:
-  while(--last >= 0)
-    mp_int_clear(TEMP(last));
+CLEANUP:
+   while (--last >= 0)
+       mp_int_clear(TEMP(last));
 
-  return res;
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_redux_const(m, c) */
 
-mp_result mp_int_redux_const(mp_int m, mp_int c)
+mp_result
+mp_int_redux_const(mp_int m, mp_int c)
 {
-  CHECK(m != NULL && c != NULL && m != c);
+   CHECK(m != NULL && c != NULL && m != c);
 
-  return s_brmu(c, m);
+   return s_brmu(c, m);
 }
 
 /* }}} */
 
 /* {{{ mp_int_invmod(a, m, c) */
 
-mp_result mp_int_invmod(mp_int a, mp_int m, mp_int c)
+mp_result
+mp_int_invmod(mp_int a, mp_int m, mp_int c)
 {
-  mp_result res;
-  mp_sign   sa;
-  int       last = 0;
-  mpz_t     temp[2];
+   mp_result   res;
+   mp_sign     sa;
+   int         last = 0;
+   mpz_t       temp[2];
 
-  CHECK(a != NULL && m != NULL && c != NULL);
+   CHECK(a != NULL && m != NULL && c != NULL);
 
-  if(CMPZ(a) == 0 || CMPZ(m) <= 0)
-    return MP_RANGE;
+   if (CMPZ(a) == 0 || CMPZ(m) <= 0)
+       return MP_RANGE;
 
-  sa = MP_SIGN(a); /* need this for the result later */
+   sa = MP_SIGN(a);            /* need this for the result later */
 
-  for(last = 0; last < 2; ++last)
-    if((res = mp_int_init(TEMP(last))) != MP_OK)
-      goto CLEANUP;
+   for (last = 0; last < 2; ++last)
+       if ((res = mp_int_init(TEMP(last))) != MP_OK)
+           goto CLEANUP;
 
-  if((res = mp_int_egcd(a, m, TEMP(0), TEMP(1), NULL)) != MP_OK) 
-    goto CLEANUP;
+   if ((res = mp_int_egcd(a, m, TEMP(0), TEMP(1), NULL)) != MP_OK)
+       goto CLEANUP;
 
-  if(mp_int_compare_value(TEMP(0), 1) != 0) {
-    res = MP_UNDEF;
-    goto CLEANUP;
-  }
+   if (mp_int_compare_value(TEMP(0), 1) != 0)
+   {
+       res = MP_UNDEF;
+       goto CLEANUP;
+   }
 
-  /* It is first necessary to constrain the value to the proper range */
-  if((res = mp_int_mod(TEMP(1), m, TEMP(1))) != MP_OK)
-    goto CLEANUP;
+   /* It is first necessary to constrain the value to the proper range */
+   if ((res = mp_int_mod(TEMP(1), m, TEMP(1))) != MP_OK)
+       goto CLEANUP;
 
-  /* Now, if 'a' was originally negative, the value we have is
-     actually the magnitude of the negative representative; to get the
-     positive value we have to subtract from the modulus.  Otherwise,
-     the value is okay as it stands.
-   */
-  if(sa == MP_NEG)
-    res = mp_int_sub(m, TEMP(1), c);
-  else
-    res = mp_int_copy(TEMP(1), c);
+   /*
+    * Now, if 'a' was originally negative, the value we have is actually the
+    * magnitude of the negative representative; to get the positive value we
+    * have to subtract from the modulus.  Otherwise, the value is okay as it
+    * stands.
+    */
+   if (sa == MP_NEG)
+       res = mp_int_sub(m, TEMP(1), c);
+   else
+       res = mp_int_copy(TEMP(1), c);
 
- CLEANUP:
-  while(--last >= 0)
-    mp_int_clear(TEMP(last));
+CLEANUP:
+   while (--last >= 0)
+       mp_int_clear(TEMP(last));
 
-  return res;
+   return res;
 }
 
 /* }}} */
@@ -1387,79 +1531,91 @@ mp_result mp_int_invmod(mp_int a, mp_int m, mp_int c)
 /* {{{ mp_int_gcd(a, b, c) */
 
 /* Binary GCD algorithm due to Josef Stein, 1961 */
-mp_result mp_int_gcd(mp_int a, mp_int b, mp_int c)
-{ 
-  int       ca, cb, k = 0;
-  mpz_t     u, v, t;
-  mp_result res;
-
-  CHECK(a != NULL && b != NULL && c != NULL);
-
-  ca = CMPZ(a);
-  cb = CMPZ(b);
-  if(ca == 0 && cb == 0)
-    return MP_UNDEF;
-  else if(ca == 0) 
-    return mp_int_abs(b, c);
-  else if(cb == 0) 
-    return mp_int_abs(a, c);
-
-  if((res = mp_int_init(&t)) != MP_OK)
-    return res;
-  if((res = mp_int_init_copy(&u, a)) != MP_OK)
-    goto U;
-  if((res = mp_int_init_copy(&v, b)) != MP_OK)
-    goto V;
-
-  MP_SIGN(&u) = MP_ZPOS; MP_SIGN(&v) = MP_ZPOS;
-
-  { /* Divide out common factors of 2 from u and v */
-    int div2_u = s_dp2k(&u), div2_v = s_dp2k(&v);
-   
-    k = MIN(div2_u, div2_v);
-    s_qdiv(&u, (mp_size) k);
-    s_qdiv(&v, (mp_size) k);
-  }
-  
-  if(mp_int_is_odd(&u)) {
-    if((res = mp_int_neg(&v, &t)) != MP_OK)
-      goto CLEANUP;
-  } 
-  else {
-    if((res = mp_int_copy(&u, &t)) != MP_OK)
-      goto CLEANUP;
-  }
-
-  for(;;) {
-    s_qdiv(&t, s_dp2k(&t));
-
-    if(CMPZ(&t) > 0) {
-      if((res = mp_int_copy(&t, &u)) != MP_OK)
-   goto CLEANUP;
-    } 
-    else {
-      if((res = mp_int_neg(&t, &v)) != MP_OK)
-   goto CLEANUP;
-    }
-
-    if((res = mp_int_sub(&u, &v, &t)) != MP_OK)
-      goto CLEANUP;
-
-    if(CMPZ(&t) == 0)
-      break;
-  } 
-
-  if((res = mp_int_abs(&u, c)) != MP_OK)
-    goto CLEANUP;
-  if(!s_qmul(c, (mp_size) k))
-    res = MP_MEMORY;
-  
- CLEANUP:
-  mp_int_clear(&v);
- V: mp_int_clear(&u);
- U: mp_int_clear(&t);
-
-  return res;
+mp_result
+mp_int_gcd(mp_int a, mp_int b, mp_int c)
+{
+   int         ca,
+               cb,
+               k = 0;
+   mpz_t       u,
+               v,
+               t;
+   mp_result   res;
+
+   CHECK(a != NULL && b != NULL && c != NULL);
+
+   ca = CMPZ(a);
+   cb = CMPZ(b);
+   if (ca == 0 && cb == 0)
+       return MP_UNDEF;
+   else if (ca == 0)
+       return mp_int_abs(b, c);
+   else if (cb == 0)
+       return mp_int_abs(a, c);
+
+   if ((res = mp_int_init(&t)) != MP_OK)
+       return res;
+   if ((res = mp_int_init_copy(&u, a)) != MP_OK)
+       goto U;
+   if ((res = mp_int_init_copy(&v, b)) != MP_OK)
+       goto V;
+
+   MP_SIGN(&u) = MP_ZPOS;
+   MP_SIGN(&v) = MP_ZPOS;
+
+   {                           /* Divide out common factors of 2 from u and v */
+       int         div2_u = s_dp2k(&u),
+                   div2_v = s_dp2k(&v);
+
+       k = MIN(div2_u, div2_v);
+       s_qdiv(&u, (mp_size) k);
+       s_qdiv(&v, (mp_size) k);
+   }
+
+   if (mp_int_is_odd(&u))
+   {
+       if ((res = mp_int_neg(&v, &t)) != MP_OK)
+           goto CLEANUP;
+   }
+   else
+   {
+       if ((res = mp_int_copy(&u, &t)) != MP_OK)
+           goto CLEANUP;
+   }
+
+   for (;;)
+   {
+       s_qdiv(&t, s_dp2k(&t));
+
+       if (CMPZ(&t) > 0)
+       {
+           if ((res = mp_int_copy(&t, &u)) != MP_OK)
+               goto CLEANUP;
+       }
+       else
+       {
+           if ((res = mp_int_neg(&t, &v)) != MP_OK)
+               goto CLEANUP;
+       }
+
+       if ((res = mp_int_sub(&u, &v, &t)) != MP_OK)
+           goto CLEANUP;
+
+       if (CMPZ(&t) == 0)
+           break;
+   }
+
+   if ((res = mp_int_abs(&u, c)) != MP_OK)
+       goto CLEANUP;
+   if (!s_qmul(c, (mp_size) k))
+       res = MP_MEMORY;
+
+CLEANUP:
+   mp_int_clear(&v);
+V: mp_int_clear(&u);
+U: mp_int_clear(&t);
+
+   return res;
 }
 
 /* }}} */
@@ -1470,308 +1626,361 @@ mp_result mp_int_gcd(mp_int a, mp_int b, mp_int c)
    of the elementary matrix operations as we go, so we can get values
    x and y satisfying c = ax + by.
  */
-mp_result mp_int_egcd(mp_int a, mp_int b, mp_int c, 
-             mp_int x, mp_int y)
-{ 
-  int       k, last = 0, ca, cb;
-  mpz_t     temp[8];
-  mp_result res;
-  
-  CHECK(a != NULL && b != NULL && c != NULL && 
-   (x != NULL || y != NULL));
-
-  ca = CMPZ(a);
-  cb = CMPZ(b);
-  if(ca == 0 && cb == 0)
-    return MP_UNDEF;
-  else if(ca == 0) {
-    if((res = mp_int_abs(b, c)) != MP_OK) return res;
-    mp_int_zero(x); (void) mp_int_set_value(y, 1); return MP_OK;
-  } 
-  else if(cb == 0) {
-    if((res = mp_int_abs(a, c)) != MP_OK) return res;
-    (void) mp_int_set_value(x, 1); mp_int_zero(y); return MP_OK;
-  }
-
-  /* Initialize temporaries:
-     A:0, B:1, C:2, D:3, u:4, v:5, ou:6, ov:7 */
-  for(last = 0; last < 4; ++last) {
-    if((res = mp_int_init(TEMP(last))) != MP_OK)
-      goto CLEANUP;
-  }
-  TEMP(0)->digits[0] = 1;
-  TEMP(3)->digits[0] = 1;
-
-  SETUP(mp_int_init_copy(TEMP(4), a), last);
-  SETUP(mp_int_init_copy(TEMP(5), b), last);
-
-  /* We will work with absolute values here */
-  MP_SIGN(TEMP(4)) = MP_ZPOS;
-  MP_SIGN(TEMP(5)) = MP_ZPOS;
-
-  { /* Divide out common factors of 2 from u and v */
-    int  div2_u = s_dp2k(TEMP(4)), div2_v = s_dp2k(TEMP(5));
-    
-    k = MIN(div2_u, div2_v);
-    s_qdiv(TEMP(4), k);
-    s_qdiv(TEMP(5), k);
-  }
-
-  SETUP(mp_int_init_copy(TEMP(6), TEMP(4)), last);
-  SETUP(mp_int_init_copy(TEMP(7), TEMP(5)), last);
-
-  for(;;) {
-    while(mp_int_is_even(TEMP(4))) {
-      s_qdiv(TEMP(4), 1);
-      
-      if(mp_int_is_odd(TEMP(0)) || mp_int_is_odd(TEMP(1))) {
-   if((res = mp_int_add(TEMP(0), TEMP(7), TEMP(0))) != MP_OK) 
-     goto CLEANUP;
-   if((res = mp_int_sub(TEMP(1), TEMP(6), TEMP(1))) != MP_OK) 
-     goto CLEANUP;
-      }
-
-      s_qdiv(TEMP(0), 1);
-      s_qdiv(TEMP(1), 1);
-    }
-    
-    while(mp_int_is_even(TEMP(5))) {
-      s_qdiv(TEMP(5), 1);
-
-      if(mp_int_is_odd(TEMP(2)) || mp_int_is_odd(TEMP(3))) {
-   if((res = mp_int_add(TEMP(2), TEMP(7), TEMP(2))) != MP_OK) 
-     goto CLEANUP;
-   if((res = mp_int_sub(TEMP(3), TEMP(6), TEMP(3))) != MP_OK) 
-     goto CLEANUP;
-      }
-
-      s_qdiv(TEMP(2), 1);
-      s_qdiv(TEMP(3), 1);
-    }
-
-    if(mp_int_compare(TEMP(4), TEMP(5)) >= 0) {
-      if((res = mp_int_sub(TEMP(4), TEMP(5), TEMP(4))) != MP_OK) goto CLEANUP;
-      if((res = mp_int_sub(TEMP(0), TEMP(2), TEMP(0))) != MP_OK) goto CLEANUP;
-      if((res = mp_int_sub(TEMP(1), TEMP(3), TEMP(1))) != MP_OK) goto CLEANUP;
-    } 
-    else {
-      if((res = mp_int_sub(TEMP(5), TEMP(4), TEMP(5))) != MP_OK) goto CLEANUP;
-      if((res = mp_int_sub(TEMP(2), TEMP(0), TEMP(2))) != MP_OK) goto CLEANUP;
-      if((res = mp_int_sub(TEMP(3), TEMP(1), TEMP(3))) != MP_OK) goto CLEANUP;
-    }
-
-    if(CMPZ(TEMP(4)) == 0) {
-      if(x && (res = mp_int_copy(TEMP(2), x)) != MP_OK) goto CLEANUP;
-      if(y && (res = mp_int_copy(TEMP(3), y)) != MP_OK) goto CLEANUP;
-      if(c) {
-   if(!s_qmul(TEMP(5), k)) {
-     res = MP_MEMORY;
-     goto CLEANUP;
-   }
-    
-   res = mp_int_copy(TEMP(5), c);
-      }
-
-      break;
-    }
-  }
-
- CLEANUP:
-  while(--last >= 0)
-    mp_int_clear(TEMP(last));
-
-  return res;
+mp_result
+mp_int_egcd(mp_int a, mp_int b, mp_int c,
+           mp_int x, mp_int y)
+{
+   int         k,
+               last = 0,
+               ca,
+               cb;
+   mpz_t       temp[8];
+   mp_result   res;
+
+   CHECK(a != NULL && b != NULL && c != NULL &&
+         (x != NULL || y != NULL));
+
+   ca = CMPZ(a);
+   cb = CMPZ(b);
+   if (ca == 0 && cb == 0)
+       return MP_UNDEF;
+   else if (ca == 0)
+   {
+       if ((res = mp_int_abs(b, c)) != MP_OK)
+           return res;
+       mp_int_zero(x);
+       (void) mp_int_set_value(y, 1);
+       return MP_OK;
+   }
+   else if (cb == 0)
+   {
+       if ((res = mp_int_abs(a, c)) != MP_OK)
+           return res;
+       (void) mp_int_set_value(x, 1);
+       mp_int_zero(y);
+       return MP_OK;
+   }
+
+   /*
+    * Initialize temporaries: A:0, B:1, C:2, D:3, u:4, v:5, ou:6, ov:7
+    */
+   for (last = 0; last < 4; ++last)
+   {
+       if ((res = mp_int_init(TEMP(last))) != MP_OK)
+           goto CLEANUP;
+   }
+   TEMP(0)->digits[0] = 1;
+   TEMP(3)->digits[0] = 1;
+
+   SETUP(mp_int_init_copy(TEMP(4), a), last);
+   SETUP(mp_int_init_copy(TEMP(5), b), last);
+
+   /* We will work with absolute values here */
+   MP_SIGN(TEMP(4)) = MP_ZPOS;
+   MP_SIGN(TEMP(5)) = MP_ZPOS;
+
+   {                           /* Divide out common factors of 2 from u and v */
+       int         div2_u = s_dp2k(TEMP(4)),
+                   div2_v = s_dp2k(TEMP(5));
+
+       k = MIN(div2_u, div2_v);
+       s_qdiv(TEMP(4), k);
+       s_qdiv(TEMP(5), k);
+   }
+
+   SETUP(mp_int_init_copy(TEMP(6), TEMP(4)), last);
+   SETUP(mp_int_init_copy(TEMP(7), TEMP(5)), last);
+
+   for (;;)
+   {
+       while (mp_int_is_even(TEMP(4)))
+       {
+           s_qdiv(TEMP(4), 1);
+
+           if (mp_int_is_odd(TEMP(0)) || mp_int_is_odd(TEMP(1)))
+           {
+               if ((res = mp_int_add(TEMP(0), TEMP(7), TEMP(0))) != MP_OK)
+                   goto CLEANUP;
+               if ((res = mp_int_sub(TEMP(1), TEMP(6), TEMP(1))) != MP_OK)
+                   goto CLEANUP;
+           }
+
+           s_qdiv(TEMP(0), 1);
+           s_qdiv(TEMP(1), 1);
+       }
+
+       while (mp_int_is_even(TEMP(5)))
+       {
+           s_qdiv(TEMP(5), 1);
+
+           if (mp_int_is_odd(TEMP(2)) || mp_int_is_odd(TEMP(3)))
+           {
+               if ((res = mp_int_add(TEMP(2), TEMP(7), TEMP(2))) != MP_OK)
+                   goto CLEANUP;
+               if ((res = mp_int_sub(TEMP(3), TEMP(6), TEMP(3))) != MP_OK)
+                   goto CLEANUP;
+           }
+
+           s_qdiv(TEMP(2), 1);
+           s_qdiv(TEMP(3), 1);
+       }
+
+       if (mp_int_compare(TEMP(4), TEMP(5)) >= 0)
+       {
+           if ((res = mp_int_sub(TEMP(4), TEMP(5), TEMP(4))) != MP_OK)
+               goto CLEANUP;
+           if ((res = mp_int_sub(TEMP(0), TEMP(2), TEMP(0))) != MP_OK)
+               goto CLEANUP;
+           if ((res = mp_int_sub(TEMP(1), TEMP(3), TEMP(1))) != MP_OK)
+               goto CLEANUP;
+       }
+       else
+       {
+           if ((res = mp_int_sub(TEMP(5), TEMP(4), TEMP(5))) != MP_OK)
+               goto CLEANUP;
+           if ((res = mp_int_sub(TEMP(2), TEMP(0), TEMP(2))) != MP_OK)
+               goto CLEANUP;
+           if ((res = mp_int_sub(TEMP(3), TEMP(1), TEMP(3))) != MP_OK)
+               goto CLEANUP;
+       }
+
+       if (CMPZ(TEMP(4)) == 0)
+       {
+           if (x && (res = mp_int_copy(TEMP(2), x)) != MP_OK)
+               goto CLEANUP;
+           if (y && (res = mp_int_copy(TEMP(3), y)) != MP_OK)
+               goto CLEANUP;
+           if (c)
+           {
+               if (!s_qmul(TEMP(5), k))
+               {
+                   res = MP_MEMORY;
+                   goto CLEANUP;
+               }
+
+               res = mp_int_copy(TEMP(5), c);
+           }
+
+           break;
+       }
+   }
+
+CLEANUP:
+   while (--last >= 0)
+       mp_int_clear(TEMP(last));
+
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_divisible_value(a, v) */
 
-int       mp_int_divisible_value(mp_int a, int v)
+int
+mp_int_divisible_value(mp_int a, int v)
 {
-  int       rem = 0;
+   int         rem = 0;
 
-  if(mp_int_div_value(a, v, NULL, &rem) != MP_OK)
-    return 0;
+   if (mp_int_div_value(a, v, NULL, &rem) != MP_OK)
+       return 0;
 
-  return rem == 0;
+   return rem == 0;
 }
 
 /* }}} */
 
 /* {{{ mp_int_is_pow2(z) */
 
-int       mp_int_is_pow2(mp_int z)
+int
+mp_int_is_pow2(mp_int z)
 {
-  CHECK(z != NULL);
+   CHECK(z != NULL);
 
-  return s_isp2(z);
+   return s_isp2(z);
 }
 
 /* }}} */
 
 /* {{{ mp_int_sqrt(a, c) */
 
-mp_result mp_int_sqrt(mp_int a, mp_int c)
+mp_result
+mp_int_sqrt(mp_int a, mp_int c)
 {
-  mp_result  res = MP_OK;
-  mpz_t      temp[2];
-  int        last = 0;
+   mp_result   res = MP_OK;
+   mpz_t       temp[2];
+   int         last = 0;
 
-  CHECK(a != NULL && c != NULL);
+   CHECK(a != NULL && c != NULL);
 
-  /* The square root of a negative value does not exist in the integers. */
-  if(MP_SIGN(a) == MP_NEG)
-    return MP_UNDEF;
+   /* The square root of a negative value does not exist in the integers. */
+   if (MP_SIGN(a) == MP_NEG)
+       return MP_UNDEF;
 
-  SETUP(mp_int_init_copy(TEMP(last), a), last);
-  SETUP(mp_int_init(TEMP(last)), last);
+   SETUP(mp_int_init_copy(TEMP(last), a), last);
+   SETUP(mp_int_init(TEMP(last)), last);
 
-  for(;;) {
-    if((res = mp_int_sqr(TEMP(0), TEMP(1))) != MP_OK)
-      goto CLEANUP;
+   for (;;)
+   {
+       if ((res = mp_int_sqr(TEMP(0), TEMP(1))) != MP_OK)
+           goto CLEANUP;
 
-    if(mp_int_compare_unsigned(a, TEMP(1)) == 0) break;
+       if (mp_int_compare_unsigned(a, TEMP(1)) == 0)
+           break;
 
-    if((res = mp_int_copy(a, TEMP(1))) != MP_OK) 
-      goto CLEANUP;
-    if((res = mp_int_div(TEMP(1), TEMP(0), TEMP(1), NULL)) != MP_OK) 
-      goto CLEANUP;
-    if((res = mp_int_add(TEMP(0), TEMP(1), TEMP(1))) != MP_OK) 
-      goto CLEANUP;
-    if((res = mp_int_div_pow2(TEMP(1), 1, TEMP(1), NULL)) != MP_OK)
-      goto CLEANUP;
+       if ((res = mp_int_copy(a, TEMP(1))) != MP_OK)
+           goto CLEANUP;
+       if ((res = mp_int_div(TEMP(1), TEMP(0), TEMP(1), NULL)) != MP_OK)
+           goto CLEANUP;
+       if ((res = mp_int_add(TEMP(0), TEMP(1), TEMP(1))) != MP_OK)
+           goto CLEANUP;
+       if ((res = mp_int_div_pow2(TEMP(1), 1, TEMP(1), NULL)) != MP_OK)
+           goto CLEANUP;
 
-    if(mp_int_compare_unsigned(TEMP(0), TEMP(1)) == 0) break;
-    if((res = mp_int_sub_value(TEMP(0), 1, TEMP(0))) != MP_OK) goto CLEANUP;
-    if(mp_int_compare_unsigned(TEMP(0), TEMP(1)) == 0) break;
+       if (mp_int_compare_unsigned(TEMP(0), TEMP(1)) == 0)
+           break;
+       if ((res = mp_int_sub_value(TEMP(0), 1, TEMP(0))) != MP_OK)
+           goto CLEANUP;
+       if (mp_int_compare_unsigned(TEMP(0), TEMP(1)) == 0)
+           break;
 
-    if((res = mp_int_copy(TEMP(1), TEMP(0))) != MP_OK) goto CLEANUP;
-  }
-  
-  res = mp_int_copy(TEMP(0), c);
+       if ((res = mp_int_copy(TEMP(1), TEMP(0))) != MP_OK)
+           goto CLEANUP;
+   }
 
- CLEANUP:
-  while(--last >= 0)
-    mp_int_clear(TEMP(last));
-  
-  return res;
+   res = mp_int_copy(TEMP(0), c);
+
+CLEANUP:
+   while (--last >= 0)
+       mp_int_clear(TEMP(last));
+
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_to_int(z, out) */
 
-mp_result mp_int_to_int(mp_int z, int *out)
+mp_result
+mp_int_to_int(mp_int z, int *out)
 {
-  unsigned int uv = 0;
-  mp_size   uz;
-  mp_digit *dz;
-  mp_sign   sz;
+   unsigned int uv = 0;
+   mp_size     uz;
+   mp_digit   *dz;
+   mp_sign     sz;
 
-  CHECK(z != NULL);
+   CHECK(z != NULL);
 
-  /* Make sure the value is representable as an int */
-  sz = MP_SIGN(z);
-  if((sz == MP_ZPOS && mp_int_compare_value(z, INT_MAX) > 0) ||
-     mp_int_compare_value(z, INT_MIN) < 0)
-    return MP_RANGE;
-     
-  uz = MP_USED(z);
-  dz = MP_DIGITS(z) + uz - 1;
-  
-  while(uz > 0) {
-    uv <<= MP_DIGIT_BIT/2;
-    uv = (uv << (MP_DIGIT_BIT/2)) | *dz--;
-    --uz;
-  }
+   /* Make sure the value is representable as an int */
+   sz = MP_SIGN(z);
+   if ((sz == MP_ZPOS && mp_int_compare_value(z, INT_MAX) > 0) ||
+       mp_int_compare_value(z, INT_MIN) < 0)
+       return MP_RANGE;
 
-  if(out)
-    *out = (sz == MP_NEG) ? -(int)uv : (int)uv;
+   uz = MP_USED(z);
+   dz = MP_DIGITS(z) + uz - 1;
 
-  return MP_OK;
+   while (uz > 0)
+   {
+       uv <<= MP_DIGIT_BIT / 2;
+       uv = (uv << (MP_DIGIT_BIT / 2)) | *dz--;
+       --uz;
+   }
+
+   if (out)
+       *out = (sz == MP_NEG) ? -(int) uv : (int) uv;
+
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_to_string(z, radix, str, limit) */
 
-mp_result mp_int_to_string(mp_int z, mp_size radix, 
-              char *str, int limit)
+mp_result
+mp_int_to_string(mp_int z, mp_size radix,
+                char *str, int limit)
 {
-  mp_result res;
-  int       cmp = 0;
-
-  CHECK(z != NULL && str != NULL && limit >= 2);
-
-  if(radix < MP_MIN_RADIX || radix > MP_MAX_RADIX)
-    return MP_RANGE;
-
-  if(CMPZ(z) == 0) {
-    *str++ = s_val2ch(0, mp_flags & MP_CAP_DIGITS);
-  } 
-  else {
-    mpz_t tmp;
-    char  *h, *t;
-
-    if((res = mp_int_init_copy(&tmp, z)) != MP_OK)
-      return res;
-
-    if(MP_SIGN(z) == MP_NEG) {
-      *str++ = '-';
-      --limit;
-    }
-    h = str;
+   mp_result   res;
+   int         cmp = 0;
 
-    /* Generate digits in reverse order until finished or limit reached */
-    for(/* */; limit > 0; --limit) {
-      mp_digit d;
+   CHECK(z != NULL && str != NULL && limit >= 2);
 
-      if((cmp = CMPZ(&tmp)) == 0)
-   break;
+   if (radix < MP_MIN_RADIX || radix > MP_MAX_RADIX)
+       return MP_RANGE;
 
-      d = s_ddiv(&tmp, (mp_digit)radix);
-      *str++ = s_val2ch(d, mp_flags & MP_CAP_DIGITS);
-    }
-    t = str - 1;
-
-    /* Put digits back in correct output order */
-    while(h < t) {
-      char tc = *h;
-      *h++ = *t;
-      *t-- = tc;
-    }
-
-    mp_int_clear(&tmp);
-  }
+   if (CMPZ(z) == 0)
+   {
+       *str++ = s_val2ch(0, mp_flags & MP_CAP_DIGITS);
+   }
+   else
+   {
+       mpz_t       tmp;
+       char       *h,
+                  *t;
+
+       if ((res = mp_int_init_copy(&tmp, z)) != MP_OK)
+           return res;
+
+       if (MP_SIGN(z) == MP_NEG)
+       {
+           *str++ = '-';
+           --limit;
+       }
+       h = str;
+
+       /* Generate digits in reverse order until finished or limit reached */
+       for ( /* */ ; limit > 0; --limit)
+       {
+           mp_digit    d;
+
+           if ((cmp = CMPZ(&tmp)) == 0)
+               break;
+
+           d = s_ddiv(&tmp, (mp_digit) radix);
+           *str++ = s_val2ch(d, mp_flags & MP_CAP_DIGITS);
+       }
+       t = str - 1;
+
+       /* Put digits back in correct output order */
+       while (h < t)
+       {
+           char        tc = *h;
+
+           *h++ = *t;
+           *t-- = tc;
+       }
+
+       mp_int_clear(&tmp);
+   }
 
-  *str = '\0';
-  if(cmp == 0)
-    return MP_OK;
-  else
-    return MP_TRUNC;
+   *str = '\0';
+   if (cmp == 0)
+       return MP_OK;
+   else
+       return MP_TRUNC;
 }
 
 /* }}} */
 
 /* {{{ mp_int_string_len(z, radix) */
 
-mp_result mp_int_string_len(mp_int z, mp_size radix)
-{ 
-  int  len;
+mp_result
+mp_int_string_len(mp_int z, mp_size radix)
+{
+   int         len;
 
-  CHECK(z != NULL);
+   CHECK(z != NULL);
 
-  if(radix < MP_MIN_RADIX || radix > MP_MAX_RADIX)
-    return MP_RANGE;
+   if (radix < MP_MIN_RADIX || radix > MP_MAX_RADIX)
+       return MP_RANGE;
 
-  len = s_outlen(z, radix) + 1; /* for terminator */
+   len = s_outlen(z, radix) + 1;       /* for terminator */
 
-  /* Allow for sign marker on negatives */
-  if(MP_SIGN(z) == MP_NEG)
-    len += 1;
+   /* Allow for sign marker on negatives */
+   if (MP_SIGN(z) == MP_NEG)
+       len += 1;
 
-  return len;
+   return len;
 }
 
 /* }}} */
@@ -1779,9 +1988,10 @@ mp_result mp_int_string_len(mp_int z, mp_size radix)
 /* {{{ mp_int_read_string(z, radix, *str) */
 
 /* Read zero-terminated string into z */
-mp_result mp_int_read_string(mp_int z, mp_size radix, const char *str)
+mp_result
+mp_int_read_string(mp_int z, mp_size radix, const char *str)
 {
-  return mp_int_read_cstring(z, radix, str, NULL);
+   return mp_int_read_cstring(z, radix, str, NULL);
 
 }
 
@@ -1789,281 +1999,308 @@ mp_result mp_int_read_string(mp_int z, mp_size radix, const char *str)
 
 /* {{{ mp_int_read_cstring(z, radix, *str, **end) */
 
-mp_result mp_int_read_cstring(mp_int z, mp_size radix, const char *str, char **end)
-{ 
-  int       ch;
+mp_result
+mp_int_read_cstring(mp_int z, mp_size radix, const char *str, char **end)
+{
+   int         ch;
 
-  CHECK(z != NULL && str != NULL);
+   CHECK(z != NULL && str != NULL);
 
-  if(radix < MP_MIN_RADIX || radix > MP_MAX_RADIX)
-    return MP_RANGE;
+   if (radix < MP_MIN_RADIX || radix > MP_MAX_RADIX)
+       return MP_RANGE;
 
-  /* Skip leading whitespace */
-  while(isspace((unsigned char) *str))
-    ++str;
+   /* Skip leading whitespace */
+   while (isspace((unsigned char) *str))
+       ++str;
 
-  /* Handle leading sign tag (+/-, positive default) */
-  switch(*str) {
-  case '-':
-    MP_SIGN(z) = MP_NEG;
-    ++str;
-    break;
-  case '+':
-    ++str; /* fallthrough */
-  default:
-    MP_SIGN(z) = MP_ZPOS;
-    break;
-  }
+   /* Handle leading sign tag (+/-, positive default) */
+   switch (*str)
+   {
+       case '-':
+           MP_SIGN(z) = MP_NEG;
+           ++str;
+           break;
+       case '+':
+           ++str;              /* fallthrough */
+       default:
+           MP_SIGN(z) = MP_ZPOS;
+           break;
+   }
+
+   /* Skip leading zeroes */
+   while ((ch = s_ch2val(*str, radix)) == 0)
+       ++str;
 
-  /* Skip leading zeroes */
-  while((ch = s_ch2val(*str, radix)) == 0) 
-    ++str;
+   /* Make sure there is enough space for the value */
+   if (!s_pad(z, s_inlen(strlen(str), radix)))
+       return MP_MEMORY;
 
-  /* Make sure there is enough space for the value */
-  if(!s_pad(z, s_inlen(strlen(str), radix)))
-    return MP_MEMORY;
+   MP_USED(z) = 1;
+   z->digits[0] = 0;
+
+   while (*str != '\0' && ((ch = s_ch2val(*str, radix)) >= 0))
+   {
+       s_dmul(z, (mp_digit) radix);
+       s_dadd(z, (mp_digit) ch);
+       ++str;
+   }
 
-  MP_USED(z) = 1; z->digits[0] = 0;
+   CLAMP(z);
 
-  while(*str != '\0' && ((ch = s_ch2val(*str, radix)) >= 0)) {
-    s_dmul(z, (mp_digit)radix);
-    s_dadd(z, (mp_digit)ch);
-    ++str;
-  }
-  
-  CLAMP(z);
+   /* Override sign for zero, even if negative specified. */
+   if (CMPZ(z) == 0)
+       MP_SIGN(z) = MP_ZPOS;
 
-  /* Override sign for zero, even if negative specified. */
-  if(CMPZ(z) == 0)
-    MP_SIGN(z) = MP_ZPOS;
-  
-  if(end != NULL)
-    *end = (char *)str;
+   if (end != NULL)
+       *end = (char *) str;
 
-  /* Return a truncation error if the string has unprocessed
-     characters remaining, so the caller can tell if the whole string
-     was done */
-  if(*str != '\0') 
-    return MP_TRUNC;
-  else
-    return MP_OK;
+   /*
+    * Return a truncation error if the string has unprocessed characters
+    * remaining, so the caller can tell if the whole string was done
+    */
+   if (*str != '\0')
+       return MP_TRUNC;
+   else
+       return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_count_bits(z) */
 
-mp_result mp_int_count_bits(mp_int z)
+mp_result
+mp_int_count_bits(mp_int z)
 {
-  mp_size  nbits = 0, uz;
-  mp_digit d;
+   mp_size     nbits = 0,
+               uz;
+   mp_digit    d;
 
-  CHECK(z != NULL);
+   CHECK(z != NULL);
 
-  uz = MP_USED(z);
-  if(uz == 1 && z->digits[0] == 0)
-    return 1;
+   uz = MP_USED(z);
+   if (uz == 1 && z->digits[0] == 0)
+       return 1;
 
-  --uz;
-  nbits = uz * MP_DIGIT_BIT;
-  d = z->digits[uz];
+   --uz;
+   nbits = uz * MP_DIGIT_BIT;
+   d = z->digits[uz];
 
-  while(d != 0) {
-    d >>= 1;
-    ++nbits;
-  }
+   while (d != 0)
+   {
+       d >>= 1;
+       ++nbits;
+   }
 
-  return nbits;
+   return nbits;
 }
 
 /* }}} */
 
 /* {{{ mp_int_to_binary(z, buf, limit) */
 
-mp_result mp_int_to_binary(mp_int z, unsigned char *buf, int limit)
+mp_result
+mp_int_to_binary(mp_int z, unsigned char *buf, int limit)
 {
-  static const int PAD_FOR_2C = 1;
+   static const int PAD_FOR_2C = 1;
+
+   mp_result   res;
+   int         limpos = limit;
 
-  mp_result res;
-  int       limpos = limit;
+   CHECK(z != NULL && buf != NULL);
 
-  CHECK(z != NULL && buf != NULL);
-  
-  res = s_tobin(z, buf, &limpos, PAD_FOR_2C);
+   res = s_tobin(z, buf, &limpos, PAD_FOR_2C);
 
-  if(MP_SIGN(z) == MP_NEG)
-    s_2comp(buf, limpos);
+   if (MP_SIGN(z) == MP_NEG)
+       s_2comp(buf, limpos);
 
-  return res;
+   return res;
 }
 
 /* }}} */
 
 /* {{{ mp_int_read_binary(z, buf, len) */
 
-mp_result mp_int_read_binary(mp_int z, unsigned char *buf, int len)
+mp_result
+mp_int_read_binary(mp_int z, unsigned char *buf, int len)
 {
-  mp_size need, i;
-  unsigned char *tmp;
-  mp_digit *dz;
+   mp_size     need,
+               i;
+   unsigned char *tmp;
+   mp_digit   *dz;
+
+   CHECK(z != NULL && buf != NULL && len > 0);
 
-  CHECK(z != NULL && buf != NULL && len > 0);
+   /* Figure out how many digits are needed to represent this value */
+   need = ((len * CHAR_BIT) + (MP_DIGIT_BIT - 1)) / MP_DIGIT_BIT;
+   if (!s_pad(z, need))
+       return MP_MEMORY;
 
-  /* Figure out how many digits are needed to represent this value */
-  need = ((len * CHAR_BIT) + (MP_DIGIT_BIT - 1)) / MP_DIGIT_BIT;
-  if(!s_pad(z, need))
-    return MP_MEMORY;
+   mp_int_zero(z);
 
-  mp_int_zero(z);
+   /*
+    * If the high-order bit is set, take the 2's complement before reading
+    * the value (it will be restored afterward)
+    */
+   if (buf[0] >> (CHAR_BIT - 1))
+   {
+       MP_SIGN(z) = MP_NEG;
+       s_2comp(buf, len);
+   }
 
-  /* If the high-order bit is set, take the 2's complement before
-     reading the value (it will be restored afterward) */
-  if(buf[0] >> (CHAR_BIT - 1)) {
-    MP_SIGN(z) = MP_NEG;
-    s_2comp(buf, len);
-  }
-  
-  dz = MP_DIGITS(z);
-  for(tmp = buf, i = len; i > 0; --i, ++tmp) {
-    s_qmul(z, (mp_size) CHAR_BIT);
-    *dz |= *tmp;
-  }
+   dz = MP_DIGITS(z);
+   for (tmp = buf, i = len; i > 0; --i, ++tmp)
+   {
+       s_qmul(z, (mp_size) CHAR_BIT);
+       *dz |= *tmp;
+   }
 
-  /* Restore 2's complement if we took it before */
-  if(MP_SIGN(z) == MP_NEG)
-    s_2comp(buf, len);
+   /* Restore 2's complement if we took it before */
+   if (MP_SIGN(z) == MP_NEG)
+       s_2comp(buf, len);
 
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_binary_len(z) */
 
-mp_result mp_int_binary_len(mp_int z)
+mp_result
+mp_int_binary_len(mp_int z)
 {
-  mp_result  res = mp_int_count_bits(z);
-  int        bytes = mp_int_unsigned_len(z);
+   mp_result   res = mp_int_count_bits(z);
+   int         bytes = mp_int_unsigned_len(z);
 
-  if(res <= 0)
-    return res;
+   if (res <= 0)
+       return res;
 
-  bytes = (res + (CHAR_BIT - 1)) / CHAR_BIT;
+   bytes = (res + (CHAR_BIT - 1)) / CHAR_BIT;
 
-  /* If the highest-order bit falls exactly on a byte boundary, we
-     need to pad with an extra byte so that the sign will be read
-     correctly when reading it back in. */
-  if(bytes * CHAR_BIT == res)
-    ++bytes;
+   /*
+    * If the highest-order bit falls exactly on a byte boundary, we need to
+    * pad with an extra byte so that the sign will be read correctly when
+    * reading it back in.
+    */
+   if (bytes * CHAR_BIT == res)
+       ++bytes;
 
-  return bytes;
+   return bytes;
 }
 
 /* }}} */
 
 /* {{{ mp_int_to_unsigned(z, buf, limit) */
 
-mp_result mp_int_to_unsigned(mp_int z, unsigned char *buf, int limit)
+mp_result
+mp_int_to_unsigned(mp_int z, unsigned char *buf, int limit)
 {
-  static const int NO_PADDING = 0;
+   static const int NO_PADDING = 0;
 
-  CHECK(z != NULL && buf != NULL);
+   CHECK(z != NULL && buf != NULL);
 
-  return s_tobin(z, buf, &limit, NO_PADDING);
+   return s_tobin(z, buf, &limit, NO_PADDING);
 }
 
 /* }}} */
 
 /* {{{ mp_int_read_unsigned(z, buf, len) */
 
-mp_result mp_int_read_unsigned(mp_int z, unsigned char *buf, int len)
+mp_result
+mp_int_read_unsigned(mp_int z, unsigned char *buf, int len)
 {
-  mp_size need, i;
-  unsigned char *tmp;
-  mp_digit *dz;
+   mp_size     need,
+               i;
+   unsigned char *tmp;
+   mp_digit   *dz;
 
-  CHECK(z != NULL && buf != NULL && len > 0);
+   CHECK(z != NULL && buf != NULL && len > 0);
 
-  /* Figure out how many digits are needed to represent this value */
-  need = ((len * CHAR_BIT) + (MP_DIGIT_BIT - 1)) / MP_DIGIT_BIT;
-  if(!s_pad(z, need))
-    return MP_MEMORY;
+   /* Figure out how many digits are needed to represent this value */
+   need = ((len * CHAR_BIT) + (MP_DIGIT_BIT - 1)) / MP_DIGIT_BIT;
+   if (!s_pad(z, need))
+       return MP_MEMORY;
 
-  mp_int_zero(z);
+   mp_int_zero(z);
 
-  dz = MP_DIGITS(z);
-  for(tmp = buf, i = len; i > 0; --i, ++tmp) {
-    (void) s_qmul(z, CHAR_BIT);
-    *dz |= *tmp;
-  }
+   dz = MP_DIGITS(z);
+   for (tmp = buf, i = len; i > 0; --i, ++tmp)
+   {
+       (void) s_qmul(z, CHAR_BIT);
+       *dz |= *tmp;
+   }
 
-  return MP_OK;
+   return MP_OK;
 }
 
 /* }}} */
 
 /* {{{ mp_int_unsigned_len(z) */
 
-mp_result mp_int_unsigned_len(mp_int z)
+mp_result
+mp_int_unsigned_len(mp_int z)
 {
-  mp_result  res = mp_int_count_bits(z);
-  int        bytes;
+   mp_result   res = mp_int_count_bits(z);
+   int         bytes;
 
-  if(res <= 0)
-    return res;
+   if (res <= 0)
+       return res;
 
-  bytes = (res + (CHAR_BIT - 1)) / CHAR_BIT;
+   bytes = (res + (CHAR_BIT - 1)) / CHAR_BIT;
 
-  return bytes;
+   return bytes;
 }
 
 /* }}} */
 
 /* {{{ mp_error_string(res) */
 
-const char *mp_error_string(mp_result res)
+const char *
+mp_error_string(mp_result res)
 {
-  int ix;
-  if(res > 0)
-    return s_unknown_err;
+   int         ix;
+
+   if (res > 0)
+       return s_unknown_err;
 
-  res = -res;
-  for(ix = 0; ix < res && s_error_msg[ix] != NULL; ++ix)
-    ;
+   res = -res;
+   for (ix = 0; ix < res && s_error_msg[ix] != NULL; ++ix)
+       ;
 
-  if(s_error_msg[ix] != NULL)
-    return s_error_msg[ix];
-  else
-    return s_unknown_err;
+   if (s_error_msg[ix] != NULL)
+       return s_error_msg[ix];
+   else
+       return s_unknown_err;
 }
 
 /* }}} */
 
 /*------------------------------------------------------------------------*/
-/* Private functions for internal use.  These make assumptions.           */
+/* Private functions for internal use. These make assumptions.           */
 
 /* {{{ s_alloc(num) */
 
-static mp_digit *s_alloc(mp_size num)
+static mp_digit *
+s_alloc(mp_size num)
 {
-  mp_digit *out = px_alloc(num * sizeof(mp_digit));
+   mp_digit   *out = px_alloc(num * sizeof(mp_digit));
 
-  assert(out != NULL); /* for debugging */
+   assert(out != NULL);        /* for debugging */
 
-  return out;
+   return out;
 }
 
 /* }}} */
 
 /* {{{ s_realloc(old, num) */
 
-static mp_digit *s_realloc(mp_digit *old, mp_size num)
+static mp_digit *
+s_realloc(mp_digit * old, mp_size num)
 {
-  mp_digit *new = px_realloc(old, num * sizeof(mp_digit));
+   mp_digit   *new = px_realloc(old, num * sizeof(mp_digit));
 
-  assert(new != NULL); /* for debugging */
+   assert(new != NULL);        /* for debugging */
 
-  return new;
+   return new;
 }
 
 /* }}} */
@@ -2071,9 +2308,10 @@ static mp_digit *s_realloc(mp_digit *old, mp_size num)
 /* {{{ s_free(ptr) */
 
 #if TRACEABLE_FREE
-static void s_free(void *ptr)
+static void
+s_free(void *ptr)
 {
-  px_free(ptr);
+   px_free(ptr);
 }
 #endif
 
@@ -2081,20 +2319,22 @@ static void s_free(void *ptr)
 
 /* {{{ s_pad(z, min) */
 
-static int      s_pad(mp_int z, mp_size min)
+static int
+s_pad(mp_int z, mp_size min)
 {
-  if(MP_ALLOC(z) < min) {
-    mp_size nsize = ROUND_PREC(min);
-    mp_digit *tmp = s_realloc(MP_DIGITS(z), nsize);
+   if (MP_ALLOC(z) < min)
+   {
+       mp_size     nsize = ROUND_PREC(min);
+       mp_digit   *tmp = s_realloc(MP_DIGITS(z), nsize);
 
-    if(tmp == NULL)
-      return 0;
+       if (tmp == NULL)
+           return 0;
 
-    MP_DIGITS(z) = tmp;
-    MP_ALLOC(z) = nsize;
-  }
+       MP_DIGITS(z) = tmp;
+       MP_ALLOC(z) = nsize;
+   }
 
-  return 1;
+   return 1;
 }
 
 /* }}} */
@@ -2102,15 +2342,16 @@ static int      s_pad(mp_int z, mp_size min)
 /* {{{ s_clamp(z) */
 
 #if TRACEABLE_CLAMP
-static void     s_clamp(mp_int z)
+static void
+s_clamp(mp_int z)
 {
-  mp_size   uz = MP_USED(z);
-  mp_digit *zd = MP_DIGITS(z) + uz - 1;
+   mp_size     uz = MP_USED(z);
+   mp_digit   *zd = MP_DIGITS(z) + uz - 1;
 
-  while(uz > 1 && (*zd-- == 0))
-    --uz;
+   while (uz > 1 && (*zd-- == 0))
+       --uz;
 
-  MP_USED(z) = uz;
+   MP_USED(z) = uz;
 }
 #endif
 
@@ -2118,614 +2359,711 @@ static void     s_clamp(mp_int z)
 
 /* {{{ s_fake(z, value, vbuf) */
 
-static void      s_fake(mp_int z, int value, mp_digit vbuf[])
+static void
+s_fake(mp_int z, int value, mp_digit vbuf[])
 {
-  mp_size uv = (mp_size)s_vpack(value, vbuf);
+   mp_size     uv = (mp_size) s_vpack(value, vbuf);
 
-  z->used = uv;
-  z->alloc = MP_VALUE_DIGITS(value);
-  z->sign = (value < 0) ? MP_NEG : MP_ZPOS;
-  z->digits = vbuf;
+   z->used = uv;
+   z->alloc = MP_VALUE_DIGITS(value);
+   z->sign = (value < 0) ? MP_NEG : MP_ZPOS;
+   z->digits = vbuf;
 }
 
 /* }}} */
 
 /* {{{ s_cdig(da, db, len) */
 
-static int      s_cdig(mp_digit *da, mp_digit *db, mp_size len)
+static int
+s_cdig(mp_digit * da, mp_digit * db, mp_size len)
 {
-  mp_digit *dat = da + len - 1, *dbt = db + len - 1;
+   mp_digit   *dat = da + len - 1,
+              *dbt = db + len - 1;
 
-  for(/* */; len != 0; --len, --dat, --dbt) {
-    if(*dat > *dbt)
-      return 1;
-    else if(*dat < *dbt)
-      return -1;
-  }
+   for ( /* */ ; len != 0; --len, --dat, --dbt)
+   {
+       if (*dat > *dbt)
+           return 1;
+       else if (*dat < *dbt)
+           return -1;
+   }
 
-  return 0;
+   return 0;
 }
 
 /* }}} */
 
 /* {{{ s_vpack(v, t[]) */
 
-static int       s_vpack(int v, mp_digit t[])
-{
-  unsigned int uv = (unsigned int)((v < 0) ? -v : v);
-  int          ndig = 0;
-  
-  if(uv == 0)
-    t[ndig++] = 0;
-  else {
-    while(uv != 0) {
-      t[ndig++] = (mp_digit) uv;
-      uv >>= MP_DIGIT_BIT/2;
-      uv >>= MP_DIGIT_BIT/2;
-    }
-  }
+static int
+s_vpack(int v, mp_digit t[])
+{
+   unsigned int uv = (unsigned int) ((v < 0) ? -v : v);
+   int         ndig = 0;
+
+   if (uv == 0)
+       t[ndig++] = 0;
+   else
+   {
+       while (uv != 0)
+       {
+           t[ndig++] = (mp_digit) uv;
+           uv >>= MP_DIGIT_BIT / 2;
+           uv >>= MP_DIGIT_BIT / 2;
+       }
+   }
 
-  return ndig;
+   return ndig;
 }
 
 /* }}} */
 
 /* {{{ s_ucmp(a, b) */
 
-static int      s_ucmp(mp_int a, mp_int b)
+static int
+s_ucmp(mp_int a, mp_int b)
 {
-  mp_size  ua = MP_USED(a), ub = MP_USED(b);
-  
-  if(ua > ub)
-    return 1;
-  else if(ub > ua) 
-    return -1;
-  else 
-    return s_cdig(MP_DIGITS(a), MP_DIGITS(b), ua);
+   mp_size     ua = MP_USED(a),
+               ub = MP_USED(b);
+
+   if (ua > ub)
+       return 1;
+   else if (ub > ua)
+       return -1;
+   else
+       return s_cdig(MP_DIGITS(a), MP_DIGITS(b), ua);
 }
 
 /* }}} */
 
 /* {{{ s_vcmp(a, v) */
 
-static int      s_vcmp(mp_int a, int v)
+static int
+s_vcmp(mp_int a, int v)
 {
-  mp_digit     vdig[MP_VALUE_DIGITS(v)];
-  int          ndig = 0;
-  mp_size      ua = MP_USED(a);
+   mp_digit    vdig[MP_VALUE_DIGITS(v)];
+   int         ndig = 0;
+   mp_size     ua = MP_USED(a);
 
-  ndig = s_vpack(v, vdig);
+   ndig = s_vpack(v, vdig);
 
-  if(ua > ndig)
-    return 1;
-  else if(ua < ndig)
-    return -1;
-  else
-    return s_cdig(MP_DIGITS(a), vdig, ndig);
+   if (ua > ndig)
+       return 1;
+   else if (ua < ndig)
+       return -1;
+   else
+       return s_cdig(MP_DIGITS(a), vdig, ndig);
 }
 
 /* }}} */
 
 /* {{{ s_uadd(da, db, dc, size_a, size_b) */
 
-static mp_digit s_uadd(mp_digit *da, mp_digit *db, mp_digit *dc, 
-              mp_size size_a, mp_size size_b)
+static mp_digit
+s_uadd(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b)
 {
-  mp_size pos;
-  mp_word w = 0;
+   mp_size     pos;
+   mp_word     w = 0;
 
-  /* Insure that da is the longer of the two to simplify later code */
-  if(size_b > size_a) {
-    SWAP(mp_digit *, da, db);
-    SWAP(mp_size, size_a, size_b);
-  }
+   /* Insure that da is the longer of the two to simplify later code */
+   if (size_b > size_a)
+   {
+       SWAP(mp_digit *, da, db);
+       SWAP(mp_size, size_a, size_b);
+   }
 
-  /* Add corresponding digits until the shorter number runs out */
-  for(pos = 0; pos < size_b; ++pos, ++da, ++db, ++dc) {
-    w = w + (mp_word)*da + (mp_word)*db;
-    *dc = LOWER_HALF(w);
-    w = UPPER_HALF(w);
-  }
+   /* Add corresponding digits until the shorter number runs out */
+   for (pos = 0; pos < size_b; ++pos, ++da, ++db, ++dc)
+   {
+       w = w + (mp_word) * da + (mp_word) * db;
+       *dc = LOWER_HALF(w);
+       w = UPPER_HALF(w);
+   }
 
-  /* Propagate carries as far as necessary */
-  for(/* */; pos < size_a; ++pos, ++da, ++dc) {
-    w = w + *da;
+   /* Propagate carries as far as necessary */
+   for ( /* */ ; pos < size_a; ++pos, ++da, ++dc)
+   {
+       w = w + *da;
 
-    *dc = LOWER_HALF(w);
-    w = UPPER_HALF(w);
-  }
+       *dc = LOWER_HALF(w);
+       w = UPPER_HALF(w);
+   }
 
-  /* Return carry out */
-  return (mp_digit)w;
+   /* Return carry out */
+   return (mp_digit) w;
 }
 
 /* }}} */
 
 /* {{{ s_usub(da, db, dc, size_a, size_b) */
 
-static void     s_usub(mp_digit *da, mp_digit *db, mp_digit *dc,
-              mp_size size_a, mp_size size_b)
+static void
+s_usub(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b)
 {
-  mp_size pos;
-  mp_word w = 0;
+   mp_size     pos;
+   mp_word     w = 0;
 
-  /* We assume that |a| >= |b| so this should definitely hold */
-  assert(size_a >= size_b);
+   /* We assume that |a| >= |b| so this should definitely hold */
+   assert(size_a >= size_b);
 
-  /* Subtract corresponding digits and propagate borrow */
-  for(pos = 0; pos < size_b; ++pos, ++da, ++db, ++dc) {
-    w = ((mp_word)MP_DIGIT_MAX + 1 +  /* MP_RADIX */
-    (mp_word)*da) - w - (mp_word)*db;
+   /* Subtract corresponding digits and propagate borrow */
+   for (pos = 0; pos < size_b; ++pos, ++da, ++db, ++dc)
+   {
+       w = ((mp_word) MP_DIGIT_MAX + 1 +       /* MP_RADIX */
+            (mp_word) * da) - w - (mp_word) * db;
 
-    *dc = LOWER_HALF(w);
-    w = (UPPER_HALF(w) == 0);
-  }
+       *dc = LOWER_HALF(w);
+       w = (UPPER_HALF(w) == 0);
+   }
 
-  /* Finish the subtraction for remaining upper digits of da */
-  for(/* */; pos < size_a; ++pos, ++da, ++dc) {
-    w = ((mp_word)MP_DIGIT_MAX + 1 +  /* MP_RADIX */
-    (mp_word)*da) - w; 
+   /* Finish the subtraction for remaining upper digits of da */
+   for ( /* */ ; pos < size_a; ++pos, ++da, ++dc)
+   {
+       w = ((mp_word) MP_DIGIT_MAX + 1 +       /* MP_RADIX */
+            (mp_word) * da) - w;
 
-    *dc = LOWER_HALF(w);
-    w = (UPPER_HALF(w) == 0);
-  }
+       *dc = LOWER_HALF(w);
+       w = (UPPER_HALF(w) == 0);
+   }
 
-  /* If there is a borrow out at the end, it violates the precondition */
-  assert(w == 0);
+   /* If there is a borrow out at the end, it violates the precondition */
+   assert(w == 0);
 }
 
 /* }}} */
 
 /* {{{ s_kmul(da, db, dc, size_a, size_b) */
 
-static int       s_kmul(mp_digit *da, mp_digit *db, mp_digit *dc,
-           mp_size size_a, mp_size size_b)
+static int
+s_kmul(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b)
 {
-  mp_size  bot_size;
-
-  /* Make sure b is the smaller of the two input values */
-  if(size_b > size_a) {
-    SWAP(mp_digit *, da, db);
-    SWAP(mp_size, size_a, size_b);
-  }
-
-  /* Insure that the bottom is the larger half in an odd-length split;
-     the code below relies on this being true.
-   */
-  bot_size = (size_a + 1) / 2;
-
-  /* If the values are big enough to bother with recursion, use the
-     Karatsuba algorithm to compute the product; otherwise use the
-     normal multiplication algorithm
-   */
-  if(multiply_threshold && 
-     size_a >= multiply_threshold && 
-     size_b > bot_size) {
-
-    mp_digit *t1, *t2, *t3, carry;
-
-    mp_digit *a_top = da + bot_size; 
-    mp_digit *b_top = db + bot_size;
-
-    mp_size  at_size = size_a - bot_size;
-    mp_size  bt_size = size_b - bot_size;
-    mp_size  buf_size = 2 * bot_size;
-
-    /* Do a single allocation for all three temporary buffers needed;
-       each buffer must be big enough to hold the product of two
-       bottom halves, and one buffer needs space for the completed 
-       product; twice the space is plenty.
-     */
-    if((t1 = s_alloc(4 * buf_size)) == NULL) return 0;
-    t2 = t1 + buf_size; 
-    t3 = t2 + buf_size;
-    ZERO(t1, 4 * buf_size);
+   mp_size     bot_size;
 
-    /* t1 and t2 are initially used as temporaries to compute the inner product
-       (a1 + a0)(b1 + b0) = a1b1 + a1b0 + a0b1 + a0b0
-     */
-    carry = s_uadd(da, a_top, t1, bot_size, at_size); /* t1 = a1 + a0 */
-    t1[bot_size] = carry;
-
-    carry = s_uadd(db, b_top, t2, bot_size, bt_size); /* t2 = b1 + b0 */
-    t2[bot_size] = carry;
-
-    (void) s_kmul(t1, t2, t3, bot_size + 1, bot_size + 1);   /* t3 = t1 * t2 */
-
-    /* Now we'll get t1 = a0b0 and t2 = a1b1, and subtract them out so that
-       we're left with only the pieces we want:  t3 = a1b0 + a0b1
-     */
-    ZERO(t1, bot_size + 1);
-    ZERO(t2, bot_size + 1);
-    (void) s_kmul(da, db, t1, bot_size, bot_size);     /* t1 = a0 * b0 */
-    (void) s_kmul(a_top, b_top, t2, at_size, bt_size); /* t2 = a1 * b1 */
-
-    /* Subtract out t1 and t2 to get the inner product */
-    s_usub(t3, t1, t3, buf_size + 2, buf_size);
-    s_usub(t3, t2, t3, buf_size + 2, buf_size);
-
-    /* Assemble the output value */
-    COPY(t1, dc, buf_size);
-    (void) s_uadd(t3, dc + bot_size, dc + bot_size,
-         buf_size + 1, buf_size + 1);
+   /* Make sure b is the smaller of the two input values */
+   if (size_b > size_a)
+   {
+       SWAP(mp_digit *, da, db);
+       SWAP(mp_size, size_a, size_b);
+   }
 
-    (void) s_uadd(t2, dc + 2*bot_size, dc + 2*bot_size,
-         buf_size, buf_size);
-    
-    s_free(t1); /* note t2 and t3 are just internal pointers to t1 */
-  } 
-  else {
-    s_umul(da, db, dc, size_a, size_b);
-  }
+   /*
+    * Insure that the bottom is the larger half in an odd-length split; the
+    * code below relies on this being true.
+    */
+   bot_size = (size_a + 1) / 2;
+
+   /*
+    * If the values are big enough to bother with recursion, use the
+    * Karatsuba algorithm to compute the product; otherwise use the normal
+    * multiplication algorithm
+    */
+   if (multiply_threshold &&
+       size_a >= multiply_threshold &&
+       size_b > bot_size)
+   {
+
+       mp_digit   *t1,
+                  *t2,
+                  *t3,
+                   carry;
+
+       mp_digit   *a_top = da + bot_size;
+       mp_digit   *b_top = db + bot_size;
+
+       mp_size     at_size = size_a - bot_size;
+       mp_size     bt_size = size_b - bot_size;
+       mp_size     buf_size = 2 * bot_size;
+
+       /*
+        * Do a single allocation for all three temporary buffers needed; each
+        * buffer must be big enough to hold the product of two bottom halves,
+        * and one buffer needs space for the completed product; twice the
+        * space is plenty.
+        */
+       if ((t1 = s_alloc(4 * buf_size)) == NULL)
+           return 0;
+       t2 = t1 + buf_size;
+       t3 = t2 + buf_size;
+       ZERO(t1, 4 * buf_size);
+
+       /*
+        * t1 and t2 are initially used as temporaries to compute the inner
+        * product (a1 + a0)(b1 + b0) = a1b1 + a1b0 + a0b1 + a0b0
+        */
+       carry = s_uadd(da, a_top, t1, bot_size, at_size);       /* t1 = a1 + a0 */
+       t1[bot_size] = carry;
+
+       carry = s_uadd(db, b_top, t2, bot_size, bt_size);       /* t2 = b1 + b0 */
+       t2[bot_size] = carry;
+
+       (void) s_kmul(t1, t2, t3, bot_size + 1, bot_size + 1);  /* t3 = t1 * t2 */
+
+       /*
+        * Now we'll get t1 = a0b0 and t2 = a1b1, and subtract them out so
+        * that we're left with only the pieces we want:  t3 = a1b0 + a0b1
+        */
+       ZERO(t1, bot_size + 1);
+       ZERO(t2, bot_size + 1);
+       (void) s_kmul(da, db, t1, bot_size, bot_size);  /* t1 = a0 * b0 */
+       (void) s_kmul(a_top, b_top, t2, at_size, bt_size);      /* t2 = a1 * b1 */
+
+       /* Subtract out t1 and t2 to get the inner product */
+       s_usub(t3, t1, t3, buf_size + 2, buf_size);
+       s_usub(t3, t2, t3, buf_size + 2, buf_size);
+
+       /* Assemble the output value */
+       COPY(t1, dc, buf_size);
+       (void) s_uadd(t3, dc + bot_size, dc + bot_size,
+                     buf_size + 1, buf_size + 1);
+
+       (void) s_uadd(t2, dc + 2 * bot_size, dc + 2 * bot_size,
+                     buf_size, buf_size);
+
+       s_free(t1);             /* note t2 and t3 are just internal pointers
+                                * to t1 */
+   }
+   else
+   {
+       s_umul(da, db, dc, size_a, size_b);
+   }
 
-  return 1;
+   return 1;
 }
 
 /* }}} */
 
 /* {{{ s_umul(da, db, dc, size_a, size_b) */
 
-static void     s_umul(mp_digit *da, mp_digit *db, mp_digit *dc,
-              mp_size size_a, mp_size size_b)
+static void
+s_umul(mp_digit * da, mp_digit * db, mp_digit * dc,
+      mp_size size_a, mp_size size_b)
 {
-  mp_size   a, b;
-  mp_word   w;
+   mp_size     a,
+               b;
+   mp_word     w;
 
-  for(a = 0; a < size_a; ++a, ++dc, ++da) {
-    mp_digit *dct = dc;
-    mp_digit *dbt = db;
+   for (a = 0; a < size_a; ++a, ++dc, ++da)
+   {
+       mp_digit   *dct = dc;
+       mp_digit   *dbt = db;
 
-    if(*da == 0)
-      continue;
+       if (*da == 0)
+           continue;
 
-    w = 0;
-    for(b = 0; b < size_b; ++b, ++dbt, ++dct) {
-      w = (mp_word)*da * (mp_word)*dbt + w + (mp_word)*dct;
+       w = 0;
+       for (b = 0; b < size_b; ++b, ++dbt, ++dct)
+       {
+           w = (mp_word) * da * (mp_word) * dbt + w + (mp_word) * dct;
 
-      *dct = LOWER_HALF(w);
-      w = UPPER_HALF(w);
-    }
+           *dct = LOWER_HALF(w);
+           w = UPPER_HALF(w);
+       }
 
-    *dct = (mp_digit)w;
-  }
+       *dct = (mp_digit) w;
+   }
 }
 
 /* }}} */
 
 /* {{{ s_ksqr(da, dc, size_a) */
 
-static int       s_ksqr(mp_digit *da, mp_digit *dc, mp_size size_a)
-{
-  if(multiply_threshold && size_a > multiply_threshold) {
-    mp_size    bot_size = (size_a + 1) / 2;
-    mp_digit  *a_top = da + bot_size;
-    mp_digit  *t1, *t2, *t3;
-    mp_size    at_size = size_a - bot_size;
-    mp_size    buf_size = 2 * bot_size;
-
-    if((t1 = s_alloc(4 * buf_size)) == NULL) return 0;
-    t2 = t1 + buf_size;
-    t3 = t2 + buf_size;
-    ZERO(t1, 4 * buf_size);
-
-    (void) s_ksqr(da, t1, bot_size);    /* t1 = a0 ^ 2 */
-    (void) s_ksqr(a_top, t2, at_size);  /* t2 = a1 ^ 2 */
-
-    (void) s_kmul(da, a_top, t3, bot_size, at_size);  /* t3 = a0 * a1 */
-
-    /* Quick multiply t3 by 2, shifting left (can't overflow) */
-    {
-      int     i, top = bot_size + at_size;
-      mp_word w, save = 0;
+static int
+s_ksqr(mp_digit * da, mp_digit * dc, mp_size size_a)
+{
+   if (multiply_threshold && size_a > multiply_threshold)
+   {
+       mp_size     bot_size = (size_a + 1) / 2;
+       mp_digit   *a_top = da + bot_size;
+       mp_digit   *t1,
+                  *t2,
+                  *t3;
+       mp_size     at_size = size_a - bot_size;
+       mp_size     buf_size = 2 * bot_size;
+
+       if ((t1 = s_alloc(4 * buf_size)) == NULL)
+           return 0;
+       t2 = t1 + buf_size;
+       t3 = t2 + buf_size;
+       ZERO(t1, 4 * buf_size);
+
+       (void) s_ksqr(da, t1, bot_size);        /* t1 = a0 ^ 2 */
+       (void) s_ksqr(a_top, t2, at_size);      /* t2 = a1 ^ 2 */
+
+       (void) s_kmul(da, a_top, t3, bot_size, at_size);        /* t3 = a0 * a1 */
+
+       /* Quick multiply t3 by 2, shifting left (can't overflow) */
+       {
+           int         i,
+                       top = bot_size + at_size;
+           mp_word     w,
+                       save = 0;
+
+           for (i = 0; i < top; ++i)
+           {
+               w = t3[i];
+               w = (w << 1) | save;
+               t3[i] = LOWER_HALF(w);
+               save = UPPER_HALF(w);
+           }
+           t3[i] = LOWER_HALF(save);
+       }
+
+       /* Assemble the output value */
+       COPY(t1, dc, 2 * bot_size);
+       (void) s_uadd(t3, dc + bot_size, dc + bot_size,
+                     buf_size + 1, buf_size + 1);
+
+       (void) s_uadd(t2, dc + 2 * bot_size, dc + 2 * bot_size,
+                     buf_size, buf_size);
+
+       px_free(t1);            /* note that t2 and t2 are internal pointers
+                                * only */
 
-      for(i = 0; i < top; ++i) {
-   w = t3[i];
-   w = (w << 1) | save;
-   t3[i] = LOWER_HALF(w);
-   save = UPPER_HALF(w);
-      }
-      t3[i] = LOWER_HALF(save);
-    }
-
-    /* Assemble the output value */
-    COPY(t1, dc, 2 * bot_size);
-    (void) s_uadd(t3, dc + bot_size, dc + bot_size,
-         buf_size + 1, buf_size + 1);
-    
-    (void) s_uadd(t2, dc + 2*bot_size, dc + 2*bot_size,
-         buf_size, buf_size);
-
-    px_free(t1); /* note that t2 and t2 are internal pointers only */
-
-  } 
-  else {
-    s_usqr(da, dc, size_a);
-  }
+   }
+   else
+   {
+       s_usqr(da, dc, size_a);
+   }
 
-  return 1;
+   return 1;
 }
 
 /* }}} */
 
 /* {{{ s_usqr(da, dc, size_a) */
 
-static void      s_usqr(mp_digit *da, mp_digit *dc, mp_size size_a)
-{
-  mp_size  i, j;
-  mp_word  w;
-
-  for(i = 0; i < size_a; ++i, dc += 2, ++da) {
-    mp_digit  *dct = dc, *dat = da;
-
-    if(*da == 0)
-      continue;
-
-    /* Take care of the first digit, no rollover */
-    w = (mp_word)*dat * (mp_word)*dat + (mp_word)*dct;
-    *dct = LOWER_HALF(w);
-    w = UPPER_HALF(w);
-    ++dat; ++dct;
-
-    for(j = i + 1; j < size_a; ++j, ++dat, ++dct) {
-      mp_word  t = (mp_word)*da * (mp_word)*dat;
-      mp_word  u = w + (mp_word)*dct, ov = 0;
-
-      /* Check if doubling t will overflow a word */
-      if(HIGH_BIT_SET(t))
-   ov = 1;
-
-      w = t + t;
-
-      /* Check if adding u to w will overflow a word */
-      if(ADD_WILL_OVERFLOW(w, u))
-   ov = 1;
-
-      w += u;
-
-      *dct = LOWER_HALF(w);
-      w = UPPER_HALF(w);
-      if(ov) {
-   w += MP_DIGIT_MAX; /* MP_RADIX */
-   ++w;
-      }
-    }
-
-    w = w + *dct;
-    *dct = (mp_digit)w; 
-    while((w = UPPER_HALF(w)) != 0) {
-      ++dct; w = w + *dct;
-      *dct = LOWER_HALF(w);
-    }
-
-    assert(w == 0);
-  }
+static void
+s_usqr(mp_digit * da, mp_digit * dc, mp_size size_a)
+{
+   mp_size     i,
+               j;
+   mp_word     w;
+
+   for (i = 0; i < size_a; ++i, dc += 2, ++da)
+   {
+       mp_digit   *dct = dc,
+                  *dat = da;
+
+       if (*da == 0)
+           continue;
+
+       /* Take care of the first digit, no rollover */
+       w = (mp_word) * dat * (mp_word) * dat + (mp_word) * dct;
+       *dct = LOWER_HALF(w);
+       w = UPPER_HALF(w);
+       ++dat;
+       ++dct;
+
+       for (j = i + 1; j < size_a; ++j, ++dat, ++dct)
+       {
+           mp_word     t = (mp_word) * da * (mp_word) * dat;
+           mp_word     u = w + (mp_word) * dct,
+                       ov = 0;
+
+           /* Check if doubling t will overflow a word */
+           if (HIGH_BIT_SET(t))
+               ov = 1;
+
+           w = t + t;
+
+           /* Check if adding u to w will overflow a word */
+           if (ADD_WILL_OVERFLOW(w, u))
+               ov = 1;
+
+           w += u;
+
+           *dct = LOWER_HALF(w);
+           w = UPPER_HALF(w);
+           if (ov)
+           {
+               w += MP_DIGIT_MAX;      /* MP_RADIX */
+               ++w;
+           }
+       }
+
+       w = w + *dct;
+       *dct = (mp_digit) w;
+       while ((w = UPPER_HALF(w)) != 0)
+       {
+           ++dct;
+           w = w + *dct;
+           *dct = LOWER_HALF(w);
+       }
+
+       assert(w == 0);
+   }
 }
 
 /* }}} */
 
 /* {{{ s_dadd(a, b) */
 
-static void      s_dadd(mp_int a, mp_digit b)
+static void
+s_dadd(mp_int a, mp_digit b)
 {
-  mp_word   w = 0;
-  mp_digit *da = MP_DIGITS(a);
-  mp_size   ua = MP_USED(a);
+   mp_word     w = 0;
+   mp_digit   *da = MP_DIGITS(a);
+   mp_size     ua = MP_USED(a);
 
-  w = (mp_word)*da + b;
-  *da++ = LOWER_HALF(w);
-  w = UPPER_HALF(w);
+   w = (mp_word) * da + b;
+   *da++ = LOWER_HALF(w);
+   w = UPPER_HALF(w);
 
-  for(ua -= 1; ua > 0; --ua, ++da) {
-    w = (mp_word)*da + w;
+   for (ua -= 1; ua > 0; --ua, ++da)
+   {
+       w = (mp_word) * da + w;
 
-    *da = LOWER_HALF(w);
-    w = UPPER_HALF(w);
-  }
+       *da = LOWER_HALF(w);
+       w = UPPER_HALF(w);
+   }
 
-  if(w) {
-    *da = (mp_digit)w;
-    MP_USED(a) += 1;
-  }
+   if (w)
+   {
+       *da = (mp_digit) w;
+       MP_USED(a) += 1;
+   }
 }
 
 /* }}} */
 
 /* {{{ s_dmul(a, b) */
 
-static void      s_dmul(mp_int a, mp_digit b)
+static void
+s_dmul(mp_int a, mp_digit b)
 {
-  mp_word   w = 0;
-  mp_digit *da = MP_DIGITS(a);
-  mp_size   ua = MP_USED(a);
+   mp_word     w = 0;
+   mp_digit   *da = MP_DIGITS(a);
+   mp_size     ua = MP_USED(a);
 
-  while(ua > 0) {
-    w = (mp_word)*da * b + w;
-    *da++ = LOWER_HALF(w);
-    w = UPPER_HALF(w);
-    --ua;
-  }
+   while (ua > 0)
+   {
+       w = (mp_word) * da * b + w;
+       *da++ = LOWER_HALF(w);
+       w = UPPER_HALF(w);
+       --ua;
+   }
 
-  if(w) {
-    *da = (mp_digit)w;
-    MP_USED(a) += 1;
-  }
+   if (w)
+   {
+       *da = (mp_digit) w;
+       MP_USED(a) += 1;
+   }
 }
 
 /* }}} */
 
 /* {{{ s_dbmul(da, b, dc, size_a) */
 
-static void      s_dbmul(mp_digit *da, mp_digit b, mp_digit *dc, mp_size size_a)
+static void
+s_dbmul(mp_digit * da, mp_digit b, mp_digit * dc, mp_size size_a)
 {
-  mp_word  w = 0;
+   mp_word     w = 0;
 
-  while(size_a > 0) {
-    w = (mp_word)*da++ * (mp_word)b + w;
+   while (size_a > 0)
+   {
+       w = (mp_word) * da++ * (mp_word) b + w;
 
-    *dc++ = LOWER_HALF(w);
-    w = UPPER_HALF(w);
-    --size_a;
-  }
+       *dc++ = LOWER_HALF(w);
+       w = UPPER_HALF(w);
+       --size_a;
+   }
 
-  if(w)
-    *dc = LOWER_HALF(w);
+   if (w)
+       *dc = LOWER_HALF(w);
 }
 
 /* }}} */
 
 /* {{{ s_ddiv(da, d, dc, size_a) */
 
-static mp_digit  s_ddiv(mp_int a, mp_digit b)
-{
-  mp_word   w = 0, qdigit;
-  mp_size   ua = MP_USED(a);
-  mp_digit *da = MP_DIGITS(a) + ua - 1;
-  
-  for(/* */; ua > 0; --ua, --da) {
-    w = (w << MP_DIGIT_BIT) | *da;
-
-    if(w >= b) {
-      qdigit = w / b;
-      w = w % b;
-    } 
-    else {
-      qdigit = 0;
-    }
-      
-    *da = (mp_digit)qdigit;
-  }
+static mp_digit
+s_ddiv(mp_int a, mp_digit b)
+{
+   mp_word     w = 0,
+               qdigit;
+   mp_size     ua = MP_USED(a);
+   mp_digit   *da = MP_DIGITS(a) + ua - 1;
+
+   for ( /* */ ; ua > 0; --ua, --da)
+   {
+       w = (w << MP_DIGIT_BIT) | *da;
+
+       if (w >= b)
+       {
+           qdigit = w / b;
+           w = w % b;
+       }
+       else
+       {
+           qdigit = 0;
+       }
+
+       *da = (mp_digit) qdigit;
+   }
 
-  CLAMP(a);
-  return (mp_digit)w;
+   CLAMP(a);
+   return (mp_digit) w;
 }
 
 /* }}} */
 
 /* {{{ s_qdiv(z, p2) */
 
-static void     s_qdiv(mp_int z, mp_size p2)
+static void
+s_qdiv(mp_int z, mp_size p2)
 {
-  mp_size ndig = p2 / MP_DIGIT_BIT, nbits = p2 % MP_DIGIT_BIT;
-  mp_size uz = MP_USED(z);
+   mp_size     ndig = p2 / MP_DIGIT_BIT,
+               nbits = p2 % MP_DIGIT_BIT;
+   mp_size     uz = MP_USED(z);
 
-  if(ndig) {
-    mp_size  mark;
-    mp_digit *to, *from;
+   if (ndig)
+   {
+       mp_size     mark;
+       mp_digit   *to,
+                  *from;
 
-    if(ndig >= uz) {
-      mp_int_zero(z);
-      return;
-    }
+       if (ndig >= uz)
+       {
+           mp_int_zero(z);
+           return;
+       }
 
-    to = MP_DIGITS(z); from = to + ndig;
+       to = MP_DIGITS(z);
+       from = to + ndig;
 
-    for(mark = ndig; mark < uz; ++mark) 
-      *to++ = *from++;
+       for (mark = ndig; mark < uz; ++mark)
+           *to++ = *from++;
 
-    MP_USED(z) = uz - ndig;
-  }
+       MP_USED(z) = uz - ndig;
+   }
 
-  if(nbits) {
-    mp_digit d = 0, *dz, save;
-    mp_size  up = MP_DIGIT_BIT - nbits;
+   if (nbits)
+   {
+       mp_digit    d = 0,
+                  *dz,
+                   save;
+       mp_size     up = MP_DIGIT_BIT - nbits;
 
-    uz = MP_USED(z);
-    dz = MP_DIGITS(z) + uz - 1;
+       uz = MP_USED(z);
+       dz = MP_DIGITS(z) + uz - 1;
 
-    for(/* */; uz > 0; --uz, --dz) {
-      save = *dz;
+       for ( /* */ ; uz > 0; --uz, --dz)
+       {
+           save = *dz;
 
-      *dz = (*dz >> nbits) | (d << up);
-      d = save;
-    }
+           *dz = (*dz >> nbits) | (d << up);
+           d = save;
+       }
 
-    CLAMP(z);
-  }
+       CLAMP(z);
+   }
 
-  if(MP_USED(z) == 1 && z->digits[0] == 0)
-    MP_SIGN(z) = MP_ZPOS;
+   if (MP_USED(z) == 1 && z->digits[0] == 0)
+       MP_SIGN(z) = MP_ZPOS;
 }
 
 /* }}} */
 
 /* {{{ s_qmod(z, p2) */
 
-static void     s_qmod(mp_int z, mp_size p2)
+static void
+s_qmod(mp_int z, mp_size p2)
 {
-  mp_size   start = p2 / MP_DIGIT_BIT + 1, rest = p2 % MP_DIGIT_BIT;
-  mp_size   uz = MP_USED(z);
-  mp_digit  mask = (1 << rest) - 1;
+   mp_size     start = p2 / MP_DIGIT_BIT + 1,
+               rest = p2 % MP_DIGIT_BIT;
+   mp_size     uz = MP_USED(z);
+   mp_digit    mask = (1 << rest) - 1;
 
-  if(start <= uz) {
-    MP_USED(z) = start;
-    z->digits[start - 1] &= mask;
-    CLAMP(z);
-  }
+   if (start <= uz)
+   {
+       MP_USED(z) = start;
+       z->digits[start - 1] &= mask;
+       CLAMP(z);
+   }
 }
 
 /* }}} */
 
 /* {{{ s_qmul(z, p2) */
 
-static int      s_qmul(mp_int z, mp_size p2)
-{
-  mp_size   uz, need, rest, extra, i;
-  mp_digit *from, *to, d;
-
-  if(p2 == 0)
-    return 1;
-
-  uz = MP_USED(z); 
-  need = p2 / MP_DIGIT_BIT; rest = p2 % MP_DIGIT_BIT;
-
-  /* Figure out if we need an extra digit at the top end; this occurs
-     if the topmost `rest' bits of the high-order digit of z are not
-     zero, meaning they will be shifted off the end if not preserved */
-  extra = 0;
-  if(rest != 0) {
-    mp_digit *dz = MP_DIGITS(z) + uz - 1;
-
-    if((*dz >> (MP_DIGIT_BIT - rest)) != 0)
-      extra = 1;
-  }
-
-  if(!s_pad(z, uz + need + extra))
-    return 0;
+static int
+s_qmul(mp_int z, mp_size p2)
+{
+   mp_size     uz,
+               need,
+               rest,
+               extra,
+               i;
+   mp_digit   *from,
+              *to,
+               d;
+
+   if (p2 == 0)
+       return 1;
+
+   uz = MP_USED(z);
+   need = p2 / MP_DIGIT_BIT;
+   rest = p2 % MP_DIGIT_BIT;
+
+   /*
+    * Figure out if we need an extra digit at the top end; this occurs if the
+    * topmost `rest' bits of the high-order digit of z are not zero, meaning
+    * they will be shifted off the end if not preserved
+    */
+   extra = 0;
+   if (rest != 0)
+   {
+       mp_digit   *dz = MP_DIGITS(z) + uz - 1;
+
+       if ((*dz >> (MP_DIGIT_BIT - rest)) != 0)
+           extra = 1;
+   }
 
-  /* If we need to shift by whole digits, do that in one pass, then
-     to back and shift by partial digits.
-   */
-  if(need > 0) {
-    from = MP_DIGITS(z) + uz - 1;
-    to = from + need;
+   if (!s_pad(z, uz + need + extra))
+       return 0;
 
-    for(i = 0; i < uz; ++i)
-      *to-- = *from--;
+   /*
+    * If we need to shift by whole digits, do that in one pass, then to back
+    * and shift by partial digits.
+    */
+   if (need > 0)
+   {
+       from = MP_DIGITS(z) + uz - 1;
+       to = from + need;
 
-    ZERO(MP_DIGITS(z), need);
-    uz += need;
-  }
+       for (i = 0; i < uz; ++i)
+           *to-- = *from--;
 
-  if(rest) {
-    d = 0;
-    for(i = need, from = MP_DIGITS(z) + need; i < uz; ++i, ++from) {
-      mp_digit save = *from;
-      
-      *from = (*from << rest) | (d >> (MP_DIGIT_BIT - rest));
-      d = save;
-    }
+       ZERO(MP_DIGITS(z), need);
+       uz += need;
+   }
 
-    d >>= (MP_DIGIT_BIT - rest);
-    if(d != 0) {
-      *from = d;
-      uz += extra;
-    }
-  }
+   if (rest)
+   {
+       d = 0;
+       for (i = need, from = MP_DIGITS(z) + need; i < uz; ++i, ++from)
+       {
+           mp_digit    save = *from;
+
+           *from = (*from << rest) | (d >> (MP_DIGIT_BIT - rest));
+           d = save;
+       }
+
+       d >>= (MP_DIGIT_BIT - rest);
+       if (d != 0)
+       {
+           *from = d;
+           uz += extra;
+       }
+   }
 
-  MP_USED(z) = uz;
-  CLAMP(z);
+   MP_USED(z) = uz;
+   CLAMP(z);
 
-  return 1;
+   return 1;
 }
 
 /* }}} */
@@ -2733,190 +3071,218 @@ static int      s_qmul(mp_int z, mp_size p2)
 /* {{{ s_qsub(z, p2) */
 
 /* Subtract |z| from 2^p2, assuming 2^p2 > |z|, and set z to be positive */
-static int       s_qsub(mp_int z, mp_size p2)
+static int
+s_qsub(mp_int z, mp_size p2)
 {
-  mp_digit hi = (1 << (p2 % MP_DIGIT_BIT)), *zp;
-  mp_size  tdig = (p2 / MP_DIGIT_BIT), pos;
-  mp_word  w = 0;
+   mp_digit    hi = (1 << (p2 % MP_DIGIT_BIT)),
+              *zp;
+   mp_size     tdig = (p2 / MP_DIGIT_BIT),
+               pos;
+   mp_word     w = 0;
 
-  if(!s_pad(z, tdig + 1))
-    return 0;
+   if (!s_pad(z, tdig + 1))
+       return 0;
 
-  for(pos = 0, zp = MP_DIGITS(z); pos < tdig; ++pos, ++zp) {
-    w = ((mp_word) MP_DIGIT_MAX + 1) - w - (mp_word)*zp;
+   for (pos = 0, zp = MP_DIGITS(z); pos < tdig; ++pos, ++zp)
+   {
+       w = ((mp_word) MP_DIGIT_MAX + 1) - w - (mp_word) * zp;
 
-    *zp = LOWER_HALF(w);
-    w = UPPER_HALF(w) ? 0 : 1;
-  }
+       *zp = LOWER_HALF(w);
+       w = UPPER_HALF(w) ? 0 : 1;
+   }
+
+   w = ((mp_word) MP_DIGIT_MAX + 1 + hi) - w - (mp_word) * zp;
+   *zp = LOWER_HALF(w);
 
-  w = ((mp_word) MP_DIGIT_MAX + 1 + hi) - w - (mp_word)*zp;
-  *zp = LOWER_HALF(w);
+   assert(UPPER_HALF(w) != 0); /* no borrow out should be possible */
 
-  assert(UPPER_HALF(w) != 0); /* no borrow out should be possible */
-  
-  MP_SIGN(z) = MP_ZPOS;
-  CLAMP(z);
+   MP_SIGN(z) = MP_ZPOS;
+   CLAMP(z);
 
-  return 1;
+   return 1;
 }
 
 /* }}} */
 
 /* {{{ s_dp2k(z) */
 
-static int      s_dp2k(mp_int z)
+static int
+s_dp2k(mp_int z)
 {
-  int       k = 0;
-  mp_digit *dp = MP_DIGITS(z), d;
+   int         k = 0;
+   mp_digit   *dp = MP_DIGITS(z),
+               d;
 
-  if(MP_USED(z) == 1 && *dp == 0)
-    return 1;
+   if (MP_USED(z) == 1 && *dp == 0)
+       return 1;
 
-  while(*dp == 0) {
-    k += MP_DIGIT_BIT;
-    ++dp;
-  }
-  
-  d = *dp;
-  while((d & 1) == 0) {
-    d >>= 1;
-    ++k;
-  }
+   while (*dp == 0)
+   {
+       k += MP_DIGIT_BIT;
+       ++dp;
+   }
 
-  return k;
+   d = *dp;
+   while ((d & 1) == 0)
+   {
+       d >>= 1;
+       ++k;
+   }
+
+   return k;
 }
 
 /* }}} */
 
 /* {{{ s_isp2(z) */
 
-static int       s_isp2(mp_int z)
+static int
+s_isp2(mp_int z)
 {
-  mp_size uz = MP_USED(z), k = 0;
-  mp_digit *dz = MP_DIGITS(z), d;
+   mp_size     uz = MP_USED(z),
+               k = 0;
+   mp_digit   *dz = MP_DIGITS(z),
+               d;
 
-  while(uz > 1) {
-    if(*dz++ != 0)
-      return -1;
-    k += MP_DIGIT_BIT;
-    --uz;
-  }
+   while (uz > 1)
+   {
+       if (*dz++ != 0)
+           return -1;
+       k += MP_DIGIT_BIT;
+       --uz;
+   }
 
-  d = *dz;
-  while(d > 1) {
-    if(d & 1)
-      return -1;
-    ++k; d >>= 1;
-  }
+   d = *dz;
+   while (d > 1)
+   {
+       if (d & 1)
+           return -1;
+       ++k;
+       d >>= 1;
+   }
 
-  return (int) k;
+   return (int) k;
 }
 
 /* }}} */
 
 /* {{{ s_2expt(z, k) */
 
-static int       s_2expt(mp_int z, int k)
+static int
+s_2expt(mp_int z, int k)
 {
-  mp_size  ndig, rest;
-  mp_digit *dz;
+   mp_size     ndig,
+               rest;
+   mp_digit   *dz;
 
-  ndig = (k + MP_DIGIT_BIT) / MP_DIGIT_BIT;
-  rest = k % MP_DIGIT_BIT;
+   ndig = (k + MP_DIGIT_BIT) / MP_DIGIT_BIT;
+   rest = k % MP_DIGIT_BIT;
 
-  if(!s_pad(z, ndig))
-    return 0;
+   if (!s_pad(z, ndig))
+       return 0;
 
-  dz = MP_DIGITS(z);
-  ZERO(dz, ndig);
-  *(dz + ndig - 1) = (1 << rest);
-  MP_USED(z) = ndig;
+   dz = MP_DIGITS(z);
+   ZERO(dz, ndig);
+   *(dz + ndig - 1) = (1 << rest);
+   MP_USED(z) = ndig;
 
-  return 1;
+   return 1;
 }
 
 /* }}} */
 
 /* {{{ s_norm(a, b) */
 
-static int      s_norm(mp_int a, mp_int b)
+static int
+s_norm(mp_int a, mp_int b)
 {
-  mp_digit d = b->digits[MP_USED(b) - 1];
-  int      k = 0;
+   mp_digit    d = b->digits[MP_USED(b) - 1];
+   int         k = 0;
 
-  while(d < (mp_digit) (1 << (MP_DIGIT_BIT - 1))) { /* d < (MP_RADIX / 2) */
-    d <<= 1;
-    ++k;
-  }
+   while (d < (mp_digit) (1 << (MP_DIGIT_BIT - 1)))
+   {                           /* d < (MP_RADIX / 2) */
+       d <<= 1;
+       ++k;
+   }
 
-  /* These multiplications can't fail */
-  if(k != 0) {
-    (void) s_qmul(a, (mp_size) k);
-    (void) s_qmul(b, (mp_size) k);
-  }
+   /* These multiplications can't fail */
+   if (k != 0)
+   {
+       (void) s_qmul(a, (mp_size) k);
+       (void) s_qmul(b, (mp_size) k);
+   }
 
-  return k;
+   return k;
 }
 
 /* }}} */
 
 /* {{{ s_brmu(z, m) */
 
-static mp_result s_brmu(mp_int z, mp_int m)
+static mp_result
+s_brmu(mp_int z, mp_int m)
 {
-  mp_size um = MP_USED(m) * 2;
+   mp_size     um = MP_USED(m) * 2;
 
-  if(!s_pad(z, um))
-    return MP_MEMORY;
+   if (!s_pad(z, um))
+       return MP_MEMORY;
 
-  s_2expt(z, MP_DIGIT_BIT * um);
-  return mp_int_div(z, m, z, NULL);
+   s_2expt(z, MP_DIGIT_BIT * um);
+   return mp_int_div(z, m, z, NULL);
 }
 
 /* }}} */
 
 /* {{{ s_reduce(x, m, mu, q1, q2) */
 
-static int       s_reduce(mp_int x, mp_int m, mp_int mu, mp_int q1, mp_int q2)
+static int
+s_reduce(mp_int x, mp_int m, mp_int mu, mp_int q1, mp_int q2)
 {
-  mp_size   um = MP_USED(m), umb_p1, umb_m1;
+   mp_size     um = MP_USED(m),
+               umb_p1,
+               umb_m1;
 
-  umb_p1 = (um + 1) * MP_DIGIT_BIT;
-  umb_m1 = (um - 1) * MP_DIGIT_BIT;
+   umb_p1 = (um + 1) * MP_DIGIT_BIT;
+   umb_m1 = (um - 1) * MP_DIGIT_BIT;
 
-  if(mp_int_copy(x, q1) != MP_OK)
-    return 0;
+   if (mp_int_copy(x, q1) != MP_OK)
+       return 0;
 
-  /* Compute q2 = floor((floor(x / b^(k-1)) * mu) / b^(k+1)) */
-  s_qdiv(q1, umb_m1);
-  UMUL(q1, mu, q2);
-  s_qdiv(q2, umb_p1);
+   /* Compute q2 = floor((floor(x / b^(k-1)) * mu) / b^(k+1)) */
+   s_qdiv(q1, umb_m1);
+   UMUL(q1, mu, q2);
+   s_qdiv(q2, umb_p1);
 
-  /* Set x = x mod b^(k+1) */
-  s_qmod(x, umb_p1);
+   /* Set x = x mod b^(k+1) */
+   s_qmod(x, umb_p1);
 
-  /* Now, q is a guess for the quotient a / m.
-     Compute x - q * m mod b^(k+1), replacing x.  This may be off
-     by a factor of 2m, but no more than that.
-   */
-  UMUL(q2, m, q1);
-  s_qmod(q1, umb_p1);
-  (void) mp_int_sub(x, q1, x); /* can't fail */
+   /*
+    * Now, q is a guess for the quotient a / m. Compute x - q * m mod
+    * b^(k+1), replacing x.  This may be off by a factor of 2m, but no more
+    * than that.
+    */
+   UMUL(q2, m, q1);
+   s_qmod(q1, umb_p1);
+   (void) mp_int_sub(x, q1, x);    /* can't fail */
 
-  /* The result may be < 0; if it is, add b^(k+1) to pin it in the
-     proper range. */
-  if((CMPZ(x) < 0) && !s_qsub(x, umb_p1))
-    return 0;
+   /*
+    * The result may be < 0; if it is, add b^(k+1) to pin it in the proper
+    * range.
+    */
+   if ((CMPZ(x) < 0) && !s_qsub(x, umb_p1))
+       return 0;
 
-  /* If x > m, we need to back it off until it is in range.
-     This will be required at most twice.  */
-  if(mp_int_compare(x, m) >= 0)
-    (void) mp_int_sub(x, m, x);
-  if(mp_int_compare(x, m) >= 0)
-    (void) mp_int_sub(x, m, x);
+   /*
+    * If x > m, we need to back it off until it is in range. This will be
+    * required at most twice.
+    */
+   if (mp_int_compare(x, m) >= 0)
+       (void) mp_int_sub(x, m, x);
+   if (mp_int_compare(x, m) >= 0)
+       (void) mp_int_sub(x, m, x);
 
-  /* At this point, x has been properly reduced. */
-  return 1;
+   /* At this point, x has been properly reduced. */
+   return 1;
 }
 
 /* }}} */
@@ -2925,75 +3291,95 @@ static int       s_reduce(mp_int x, mp_int m, mp_int mu, mp_int q1, mp_int q2)
 
 /* Perform modular exponentiation using Barrett's method, where mu is
    the reduction constant for m.  Assumes a < m, b > 0. */
-static mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
-{
-  mp_digit  *db, *dbt, umu, d;
-  mpz_t     temp[3]; 
-  mp_result res;
-  int       last = 0;
-
-  umu = MP_USED(mu); db = MP_DIGITS(b); dbt = db + MP_USED(b) - 1;
-
-  while(last < 3) 
-    SETUP(mp_int_init_size(TEMP(last), 2 * umu), last);
-
-  (void) mp_int_set_value(c, 1);
-
-  /* Take care of low-order digits */
-  while(db < dbt) {
-    int      i;
-
-    for(d = *db, i = MP_DIGIT_BIT; i > 0; --i, d >>= 1) {
-      if(d & 1) {
-   /* The use of a second temporary avoids allocation */
-   UMUL(c, a, TEMP(0));
-   if(!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2))) {
-     res = MP_MEMORY; goto CLEANUP;
+static mp_result
+s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
+{
+   mp_digit   *db,
+              *dbt,
+               umu,
+               d;
+   mpz_t       temp[3];
+   mp_result   res;
+   int         last = 0;
+
+   umu = MP_USED(mu);
+   db = MP_DIGITS(b);
+   dbt = db + MP_USED(b) - 1;
+
+   while (last < 3)
+       SETUP(mp_int_init_size(TEMP(last), 2 * umu), last);
+
+   (void) mp_int_set_value(c, 1);
+
+   /* Take care of low-order digits */
+   while (db < dbt)
+   {
+       int         i;
+
+       for (d = *db, i = MP_DIGIT_BIT; i > 0; --i, d >>= 1)
+       {
+           if (d & 1)
+           {
+               /* The use of a second temporary avoids allocation */
+               UMUL(c, a, TEMP(0));
+               if (!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2)))
+               {
+                   res = MP_MEMORY;
+                   goto CLEANUP;
+               }
+               mp_int_copy(TEMP(0), c);
+           }
+
+
+           USQR(a, TEMP(0));
+           assert(MP_SIGN(TEMP(0)) == MP_ZPOS);
+           if (!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2)))
+           {
+               res = MP_MEMORY;
+               goto CLEANUP;
+           }
+           assert(MP_SIGN(TEMP(0)) == MP_ZPOS);
+           mp_int_copy(TEMP(0), a);
+
+
+       }
+
+       ++db;
    }
-   mp_int_copy(TEMP(0), c);
-      }
-
-
-      USQR(a, TEMP(0));
-      assert(MP_SIGN(TEMP(0)) == MP_ZPOS);
-      if(!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2))) {
-   res = MP_MEMORY; goto CLEANUP;
-      }
-      assert(MP_SIGN(TEMP(0)) == MP_ZPOS);
-      mp_int_copy(TEMP(0), a);
 
+   /* Take care of highest-order digit */
+   d = *dbt;
+   for (;;)
+   {
+       if (d & 1)
+       {
+           UMUL(c, a, TEMP(0));
+           if (!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2)))
+           {
+               res = MP_MEMORY;
+               goto CLEANUP;
+           }
+           mp_int_copy(TEMP(0), c);
+       }
+
+       d >>= 1;
+       if (!d)
+           break;
+
+       USQR(a, TEMP(0));
+       if (!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2)))
+       {
+           res = MP_MEMORY;
+           goto CLEANUP;
+       }
+       (void) mp_int_copy(TEMP(0), a);
+   }
 
-    }
-
-    ++db;
-  }
-
-  /* Take care of highest-order digit */
-  d = *dbt;
-  for(;;) {
-    if(d & 1) {
-      UMUL(c, a, TEMP(0));
-      if(!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2))) {
-   res = MP_MEMORY; goto CLEANUP;
-      }
-      mp_int_copy(TEMP(0), c);
-    }
-    
-    d >>= 1;
-    if(!d) break;
-
-    USQR(a, TEMP(0));
-    if(!s_reduce(TEMP(0), m, mu, TEMP(1), TEMP(2))) {
-      res = MP_MEMORY; goto CLEANUP;
-    }
-    (void) mp_int_copy(TEMP(0), a);
-  }
+CLEANUP:
+   while (--last >= 0)
+       mp_int_clear(TEMP(last));
 
- CLEANUP:
-  while(--last >= 0)
-    mp_int_clear(TEMP(last));
-  
-  return res;
+   return res;
 }
 
 /* }}} */
@@ -3003,92 +3389,109 @@ static mp_result s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
 /* Precondition:  a >= b and b > 0
    Postcondition: a' = a / b, b' = a % b
  */
-static mp_result s_udiv(mp_int a, mp_int b)
-{
-  mpz_t     q, r, t;
-  mp_size   ua, ub, qpos = 0;
-  mp_digit *da, btop;
-  mp_result res = MP_OK;
-  int       k, skip = 0;
-
-  /* Force signs to positive */
-  MP_SIGN(a) = MP_ZPOS;
-  MP_SIGN(b) = MP_ZPOS;
-
-  /* Normalize, per Knuth */
-  k = s_norm(a, b);
-
-  ua = MP_USED(a); ub = MP_USED(b); btop = b->digits[ub - 1];
-  if((res = mp_int_init_size(&q, ua)) != MP_OK) return res;
-  if((res = mp_int_init_size(&t, ua + 1)) != MP_OK) goto CLEANUP;
-
-  da = MP_DIGITS(a);
-  r.digits = da + ua - 1;  /* The contents of r are shared with a */
-  r.used   = 1;
-  r.sign   = MP_ZPOS;
-  r.alloc  = MP_ALLOC(a);
-  ZERO(t.digits, t.alloc);
-
-  /* Solve for quotient digits, store in q.digits in reverse order */
-  while(r.digits >= da) {
-    assert(qpos <= q.alloc);
-
-    if(s_ucmp(b, &r) > 0) {
-      r.digits -= 1;
-      r.used += 1;
-      
-      if(++skip > 1)
-   q.digits[qpos++] = 0;
-      
-      CLAMP(&r);
-    }
-    else {
-      mp_word  pfx = r.digits[r.used - 1];
-      mp_word  qdigit;
-      
-      if(r.used > 1 && (pfx < btop || r.digits[r.used - 2] == 0)) {
-   pfx <<= MP_DIGIT_BIT / 2;
-   pfx <<= MP_DIGIT_BIT / 2;
-   pfx |= r.digits[r.used - 2];
-      }
-
-      qdigit = pfx / btop;
-      if(qdigit > MP_DIGIT_MAX) 
-   qdigit = 1;
-      
-      s_dbmul(MP_DIGITS(b), (mp_digit) qdigit, t.digits, ub);
-      t.used = ub + 1; CLAMP(&t);
-      while(s_ucmp(&t, &r) > 0) {
-   --qdigit;
-   (void) mp_int_sub(&t, b, &t); /* cannot fail */
-      }
-      
-      s_usub(r.digits, t.digits, r.digits, r.used, t.used);
-      CLAMP(&r);
-      
-      q.digits[qpos++] = (mp_digit) qdigit;
-      ZERO(t.digits, t.used);
-      skip = 0;
-    }
-  }
-  
-  /* Put quotient digits in the correct order, and discard extra zeroes */
-  q.used = qpos;
-  REV(mp_digit, q.digits, qpos);
-  CLAMP(&q);
-
-  /* Denormalize the remainder */
-  CLAMP(a);
-  if(k != 0)
-    s_qdiv(a, k);
-  
-  mp_int_copy(a, b);  /* ok:  0 <= r < b */
-  mp_int_copy(&q, a); /* ok:  q <= a     */
-  
-  mp_int_clear(&t);
- CLEANUP:
-  mp_int_clear(&q);
-  return res;
+static mp_result
+s_udiv(mp_int a, mp_int b)
+{
+   mpz_t       q,
+               r,
+               t;
+   mp_size     ua,
+               ub,
+               qpos = 0;
+   mp_digit   *da,
+               btop;
+   mp_result   res = MP_OK;
+   int         k,
+               skip = 0;
+
+   /* Force signs to positive */
+   MP_SIGN(a) = MP_ZPOS;
+   MP_SIGN(b) = MP_ZPOS;
+
+   /* Normalize, per Knuth */
+   k = s_norm(a, b);
+
+   ua = MP_USED(a);
+   ub = MP_USED(b);
+   btop = b->digits[ub - 1];
+   if ((res = mp_int_init_size(&q, ua)) != MP_OK)
+       return res;
+   if ((res = mp_int_init_size(&t, ua + 1)) != MP_OK)
+       goto CLEANUP;
+
+   da = MP_DIGITS(a);
+   r.digits = da + ua - 1;     /* The contents of r are shared with a */
+   r.used = 1;
+   r.sign = MP_ZPOS;
+   r.alloc = MP_ALLOC(a);
+   ZERO(t.digits, t.alloc);
+
+   /* Solve for quotient digits, store in q.digits in reverse order */
+   while (r.digits >= da)
+   {
+       assert(qpos <= q.alloc);
+
+       if (s_ucmp(b, &r) > 0)
+       {
+           r.digits -= 1;
+           r.used += 1;
+
+           if (++skip > 1)
+               q.digits[qpos++] = 0;
+
+           CLAMP(&r);
+       }
+       else
+       {
+           mp_word     pfx = r.digits[r.used - 1];
+           mp_word     qdigit;
+
+           if (r.used > 1 && (pfx < btop || r.digits[r.used - 2] == 0))
+           {
+               pfx <<= MP_DIGIT_BIT / 2;
+               pfx <<= MP_DIGIT_BIT / 2;
+               pfx |= r.digits[r.used - 2];
+           }
+
+           qdigit = pfx / btop;
+           if (qdigit > MP_DIGIT_MAX)
+               qdigit = 1;
+
+           s_dbmul(MP_DIGITS(b), (mp_digit) qdigit, t.digits, ub);
+           t.used = ub + 1;
+           CLAMP(&t);
+           while (s_ucmp(&t, &r) > 0)
+           {
+               --qdigit;
+               (void) mp_int_sub(&t, b, &t);   /* cannot fail */
+           }
+
+           s_usub(r.digits, t.digits, r.digits, r.used, t.used);
+           CLAMP(&r);
+
+           q.digits[qpos++] = (mp_digit) qdigit;
+           ZERO(t.digits, t.used);
+           skip = 0;
+       }
+   }
+
+   /* Put quotient digits in the correct order, and discard extra zeroes */
+   q.used = qpos;
+   REV(mp_digit, q.digits, qpos);
+   CLAMP(&q);
+
+   /* Denormalize the remainder */
+   CLAMP(a);
+   if (k != 0)
+       s_qdiv(a, k);
+
+   mp_int_copy(a, b);          /* ok:  0 <= r < b */
+   mp_int_copy(&q, a);         /* ok:  q <= a     */
+
+   mp_int_clear(&t);
+CLEANUP:
+   mp_int_clear(&q);
+   return res;
 }
 
 /* }}} */
@@ -3096,133 +3499,147 @@ static mp_result s_udiv(mp_int a, mp_int b)
 /* {{{ s_outlen(z, r) */
 
 /* Precondition:  2 <= r < 64 */
-static int       s_outlen(mp_int z, mp_size r)
+static int
+s_outlen(mp_int z, mp_size r)
 {
-  mp_result  bits;
-  double     raw;
+   mp_result   bits;
+   double      raw;
 
-  bits = mp_int_count_bits(z);
-  raw = (double)bits * s_log2[r];
+   bits = mp_int_count_bits(z);
+   raw = (double) bits *s_log2[r];
 
-  return (int)(raw + 0.999999);
+   return (int) (raw + 0.999999);
 }
 
 /* }}} */
 
 /* {{{ s_inlen(len, r) */
 
-static mp_size   s_inlen(int len, mp_size r)
+static mp_size
+s_inlen(int len, mp_size r)
 {
-  double  raw = (double)len / s_log2[r];
-  mp_size bits = (mp_size)(raw + 0.5);
+   double      raw = (double) len / s_log2[r];
+   mp_size     bits = (mp_size) (raw + 0.5);
 
-  return (mp_size)((bits + (MP_DIGIT_BIT - 1)) / MP_DIGIT_BIT);
+   return (mp_size) ((bits + (MP_DIGIT_BIT - 1)) / MP_DIGIT_BIT);
 }
 
 /* }}} */
 
 /* {{{ s_ch2val(c, r) */
 
-static int       s_ch2val(char c, int r)
+static int
+s_ch2val(char c, int r)
 {
-  int out;
+   int         out;
 
-  if(isdigit((unsigned char)c))
-    out = c - '0';
-  else if(r > 10 && isalpha((unsigned char) c))
-    out = toupper((unsigned char) c) - 'A' + 10;
-  else
-    return -1;
+   if (isdigit((unsigned char) c))
+       out = c - '0';
+   else if (r > 10 && isalpha((unsigned char) c))
+       out = toupper((unsigned char) c) - 'A' + 10;
+   else
+       return -1;
 
-  return (out >= r) ? -1 : out;
+   return (out >= r) ? -1 : out;
 }
 
 /* }}} */
 
 /* {{{ s_val2ch(v, caps) */
 
-static char      s_val2ch(int v, int caps)
+static char
+s_val2ch(int v, int caps)
 {
-  assert(v >= 0);
+   assert(v >= 0);
 
-  if(v < 10)
-    return v + '0';
-  else {
-    char out = (v - 10) + 'a';
+   if (v < 10)
+       return v + '0';
+   else
+   {
+       char        out = (v - 10) + 'a';
 
-    if(caps)
-      return toupper((unsigned char) out);
-    else
-      return out;
-  }
+       if (caps)
+           return toupper((unsigned char) out);
+       else
+           return out;
+   }
 }
 
 /* }}} */
 
 /* {{{ s_2comp(buf, len) */
 
-static void      s_2comp(unsigned char *buf, int len)
+static void
+s_2comp(unsigned char *buf, int len)
 {
-  int i;
-  unsigned short s = 1;
+   int         i;
+   unsigned short s = 1;
 
-  for(i = len - 1; i >= 0; --i) {
-    unsigned char c = ~buf[i];
+   for (i = len - 1; i >= 0; --i)
+   {
+       unsigned char c = ~buf[i];
 
-    s = c + s;
-    c = s & UCHAR_MAX;
-    s >>= CHAR_BIT;
+       s = c + s;
+       c = s & UCHAR_MAX;
+       s >>= CHAR_BIT;
 
-    buf[i] = c;
-  }
+       buf[i] = c;
+   }
 
-  /* last carry out is ignored */
+   /* last carry out is ignored */
 }
 
 /* }}} */
 
 /* {{{ s_tobin(z, buf, *limpos) */
 
-static mp_result s_tobin(mp_int z, unsigned char *buf, int *limpos, int pad)
+static mp_result
+s_tobin(mp_int z, unsigned char *buf, int *limpos, int pad)
 {
-  mp_size uz;
-  mp_digit *dz;
-  int pos = 0, limit = *limpos;
+   mp_size     uz;
+   mp_digit   *dz;
+   int         pos = 0,
+               limit = *limpos;
 
-  uz = MP_USED(z); dz = MP_DIGITS(z);
-  while(uz > 0 && pos < limit) {
-    mp_digit d = *dz++;
-    int i;
+   uz = MP_USED(z);
+   dz = MP_DIGITS(z);
+   while (uz > 0 && pos < limit)
+   {
+       mp_digit    d = *dz++;
+       int         i;
 
-    for(i = sizeof(mp_digit); i > 0 && pos < limit; --i) {
-      buf[pos++] = (unsigned char)d;
-      d >>= CHAR_BIT;
+       for (i = sizeof(mp_digit); i > 0 && pos < limit; --i)
+       {
+           buf[pos++] = (unsigned char) d;
+           d >>= CHAR_BIT;
 
-      /* Don't write leading zeroes */
-      if(d == 0 && uz == 1)
-   i = 0; /* exit loop without signaling truncation */
-    }
+           /* Don't write leading zeroes */
+           if (d == 0 && uz == 1)
+               i = 0;          /* exit loop without signaling truncation */
+       }
 
-    /* Detect truncation (loop exited with pos >= limit) */
-    if(i > 0) break;
+       /* Detect truncation (loop exited with pos >= limit) */
+       if (i > 0)
+           break;
 
-    --uz;
-  }
+       --uz;
+   }
 
-  if(pad != 0 && (buf[pos - 1] >> (CHAR_BIT - 1))) {
-    if(pos < limit)
-      buf[pos++] = 0;
-    else
-      uz = 1;
-  }
+   if (pad != 0 && (buf[pos - 1] >> (CHAR_BIT - 1)))
+   {
+       if (pos < limit)
+           buf[pos++] = 0;
+       else
+           uz = 1;
+   }
 
-  /* Digits are in reverse order, fix that */
-  REV(unsigned char, buf, pos);
+   /* Digits are in reverse order, fix that */
+   REV(unsigned char, buf, pos);
 
-  /* Return the number of bytes actually written */
-  *limpos = pos;
+   /* Return the number of bytes actually written */
+   *limpos = pos;
 
-  return (uz == 0) ? MP_OK : MP_TRUNC;
+   return (uz == 0) ? MP_OK : MP_TRUNC;
 }
 
 /* }}} */
@@ -3230,30 +3647,32 @@ static mp_result s_tobin(mp_int z, unsigned char *buf, int *limpos, int pad)
 /* {{{ s_print(tag, z) */
 
 #if 0
-void      s_print(char *tag, mp_int z)
+void
+s_print(char *tag, mp_int z)
 {
-  int  i;
+   int         i;
 
-  fprintf(stderr, "%s: %c ", tag,
-     (MP_SIGN(z) == MP_NEG) ? '-' : '+');
+   fprintf(stderr, "%s: %c ", tag,
+           (MP_SIGN(z) == MP_NEG) ? '-' : '+');
 
-  for(i = MP_USED(z) - 1; i >= 0; --i)
-    fprintf(stderr, "%0*X", (int)(MP_DIGIT_BIT / 4), z->digits[i]);
+   for (i = MP_USED(z) - 1; i >= 0; --i)
+       fprintf(stderr, "%0*X", (int) (MP_DIGIT_BIT / 4), z->digits[i]);
 
-  fputc('\n', stderr);
+   fputc('\n', stderr);
 
 }
 
-void      s_print_buf(char *tag, mp_digit *buf, mp_size num)
+void
+s_print_buf(char *tag, mp_digit * buf, mp_size num)
 {
-  int  i;
+   int         i;
 
-  fprintf(stderr, "%s: ", tag);
+   fprintf(stderr, "%s: ", tag);
 
-  for(i = num - 1; i >= 0; --i) 
-    fprintf(stderr, "%0*X", (int)(MP_DIGIT_BIT / 4), buf[i]);
+   for (i = num - 1; i >= 0; --i)
+       fprintf(stderr, "%0*X", (int) (MP_DIGIT_BIT / 4), buf[i]);
 
-  fputc('\n', stderr);
+   fputc('\n', stderr);
 }
 #endif
 
index 67adb3bf4527a1c6b50d22d9e2f5f2c4e4e9bd9b..f730b320506a476dea59e777b8ce5d6038e170de 100644 (file)
@@ -1,8 +1,8 @@
 /*
-  Name:     imath.h
-  Purpose:  Arbitrary precision integer arithmetic routines.
-  Author:   M. J. Fromberger 
-  Info:     Id: imath.h 21 2006-04-02 18:58:36Z sting
+  Name:        imath.h
+  Purpose: Arbitrary precision integer arithmetic routines.
+  Author:  M. J. Fromberger 
+  Info:        Id: imath.h 21 2006-04-02 18:58:36Z sting
 
   Copyright (C) 2002 Michael J. Fromberger, All Rights Reserved.
 
   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-  NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   SOFTWARE.
  */
-/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.h,v 1.4 2006/07/19 17:05:50 neilc Exp $ */
+/* $PostgreSQL: pgsql/contrib/pgcrypto/imath.h,v 1.5 2006/10/04 00:29:46 momjian Exp $ */
 
 #ifndef IMATH_H_
 #define IMATH_H_
 
 #include 
 
-typedef unsigned char      mp_sign;
-typedef unsigned int       mp_size;
-typedef int                mp_result;
+typedef unsigned char mp_sign;
+typedef unsigned int mp_size;
+typedef int mp_result;
+
 #ifdef USE_LONG_LONG
-typedef uint32             mp_digit;
-typedef uint64             mp_word;
-#define MP_DIGIT_MAX       0xFFFFFFFFULL
-#define MP_WORD_MAX        0xFFFFFFFFFFFFFFFFULL
+typedef uint32 mp_digit;
+typedef uint64 mp_word;
+
+#define MP_DIGIT_MAX      0xFFFFFFFFULL
+#define MP_WORD_MAX           0xFFFFFFFFFFFFFFFFULL
 #else
-typedef uint16             mp_digit;
-typedef uint32             mp_word;
-#define MP_DIGIT_MAX       0xFFFFUL
-#define MP_WORD_MAX        0xFFFFFFFFUL
+typedef uint16 mp_digit;
+typedef uint32 mp_word;
+
+#define MP_DIGIT_MAX      0xFFFFUL
+#define MP_WORD_MAX           0xFFFFFFFFUL
 #endif
 
-typedef struct mpz {
-  mp_digit   *digits;
-  mp_size     alloc;
-  mp_size     used;
-  mp_sign     sign;
-} mpz_t, *mp_int;
+typedef struct mpz
+{
+   mp_digit   *digits;
+   mp_size     alloc;
+   mp_size     used;
+   mp_sign     sign;
+}  mpz_t, *mp_int;
 
 #define MP_DIGITS(Z) ((Z)->digits)
 #define MP_ALLOC(Z)  ((Z)->alloc)
-#define MP_USED(Z)   ((Z)->used)
-#define MP_SIGN(Z)   ((Z)->sign)
+#define MP_USED(Z)  ((Z)->used)
+#define MP_SIGN(Z)  ((Z)->sign)
 
 extern const mp_result MP_OK;
 extern const mp_result MP_FALSE;
@@ -72,131 +76,140 @@ extern const mp_result MP_UNDEF;
 extern const mp_result MP_TRUNC;
 extern const mp_result MP_BADARG;
 
-#define MP_DIGIT_BIT    (sizeof(mp_digit) * CHAR_BIT)
-#define MP_WORD_BIT     (sizeof(mp_word) * CHAR_BIT)
+#define MP_DIGIT_BIT   (sizeof(mp_digit) * CHAR_BIT)
+#define MP_WORD_BIT        (sizeof(mp_word) * CHAR_BIT)
 
-#define MP_MIN_RADIX    2
-#define MP_MAX_RADIX    36
+#define MP_MIN_RADIX   2
+#define MP_MAX_RADIX   36
 
-extern const mp_sign   MP_NEG;
-extern const mp_sign   MP_ZPOS;
+extern const mp_sign MP_NEG;
+extern const mp_sign MP_ZPOS;
 
 #define mp_int_is_odd(Z)  ((Z)->digits[0] & 1)
 #define mp_int_is_even(Z) !((Z)->digits[0] & 1)
 
-mp_size   mp_get_default_precision(void);
-void      mp_set_default_precision(mp_size s);
-mp_size   mp_get_multiply_threshold(void);
-void      mp_set_multiply_threshold(mp_size s);
-
-mp_result mp_int_init(mp_int z);
-mp_int    mp_int_alloc(void);
-mp_result mp_int_init_size(mp_int z, mp_size prec);
-mp_result mp_int_init_copy(mp_int z, mp_int old);
-mp_result mp_int_init_value(mp_int z, int value);
-mp_result mp_int_set_value(mp_int z, int value);
-void      mp_int_clear(mp_int z);
-void      mp_int_free(mp_int z);
-
-mp_result mp_int_copy(mp_int a, mp_int c);           /* c = a     */
-void      mp_int_swap(mp_int a, mp_int c);           /* swap a, c */
-void      mp_int_zero(mp_int z);                     /* z = 0     */
-mp_result mp_int_abs(mp_int a, mp_int c);            /* c = |a|   */
-mp_result mp_int_neg(mp_int a, mp_int c);            /* c = -a    */
-mp_result mp_int_add(mp_int a, mp_int b, mp_int c);  /* c = a + b */
-mp_result mp_int_add_value(mp_int a, int value, mp_int c);
-mp_result mp_int_sub(mp_int a, mp_int b, mp_int c);  /* c = a - b */
-mp_result mp_int_sub_value(mp_int a, int value, mp_int c);
-mp_result mp_int_mul(mp_int a, mp_int b, mp_int c);  /* c = a * b */
-mp_result mp_int_mul_value(mp_int a, int value, mp_int c);
-mp_result mp_int_mul_pow2(mp_int a, int p2, mp_int c);
-mp_result mp_int_sqr(mp_int a, mp_int c);            /* c = a * a */
-mp_result mp_int_div(mp_int a, mp_int b,             /* q = a / b */
-            mp_int q, mp_int r);            /* r = a % b */
-mp_result mp_int_div_value(mp_int a, int value,      /* q = a / value */
-              mp_int q, int *r);        /* r = a % value */
-mp_result mp_int_div_pow2(mp_int a, int p2,          /* q = a / 2^p2  */
-             mp_int q, mp_int r);       /* r = q % 2^p2  */
-mp_result mp_int_mod(mp_int a, mp_int m, mp_int c);  /* c = a % m */
+mp_size        mp_get_default_precision(void);
+void       mp_set_default_precision(mp_size s);
+mp_size        mp_get_multiply_threshold(void);
+void       mp_set_multiply_threshold(mp_size s);
+
+mp_result  mp_int_init(mp_int z);
+mp_int     mp_int_alloc(void);
+mp_result  mp_int_init_size(mp_int z, mp_size prec);
+mp_result  mp_int_init_copy(mp_int z, mp_int old);
+mp_result  mp_int_init_value(mp_int z, int value);
+mp_result  mp_int_set_value(mp_int z, int value);
+void       mp_int_clear(mp_int z);
+void       mp_int_free(mp_int z);
+
+mp_result  mp_int_copy(mp_int a, mp_int c);    /* c = a     */
+void       mp_int_swap(mp_int a, mp_int c);    /* swap a, c */
+void       mp_int_zero(mp_int z);      /* z = 0     */
+mp_result  mp_int_abs(mp_int a, mp_int c);     /* c = |a|   */
+mp_result  mp_int_neg(mp_int a, mp_int c);     /* c = -a    */
+mp_result  mp_int_add(mp_int a, mp_int b, mp_int c);   /* c = a + b */
+mp_result  mp_int_add_value(mp_int a, int value, mp_int c);
+mp_result  mp_int_sub(mp_int a, mp_int b, mp_int c);   /* c = a - b */
+mp_result  mp_int_sub_value(mp_int a, int value, mp_int c);
+mp_result  mp_int_mul(mp_int a, mp_int b, mp_int c);   /* c = a * b */
+mp_result  mp_int_mul_value(mp_int a, int value, mp_int c);
+mp_result  mp_int_mul_pow2(mp_int a, int p2, mp_int c);
+mp_result  mp_int_sqr(mp_int a, mp_int c);     /* c = a * a */
+mp_result
+mp_int_div(mp_int a, mp_int b, /* q = a / b */
+          mp_int q, mp_int r); /* r = a % b */
+mp_result
+mp_int_div_value(mp_int a, int value,  /* q = a / value */
+                mp_int q, int *r);     /* r = a % value */
+mp_result
+mp_int_div_pow2(mp_int a, int p2,      /* q = a / 2^p2  */
+               mp_int q, mp_int r);    /* r = q % 2^p2  */
+mp_result  mp_int_mod(mp_int a, mp_int m, mp_int c);   /* c = a % m */
+
 #define   mp_int_mod_value(A, V, R) mp_int_div_value((A), (V), 0, (R))
-mp_result mp_int_expt(mp_int a, int b, mp_int c);    /* c = a^b   */
-mp_result mp_int_expt_value(int a, int b, mp_int c); /* c = a^b   */
+mp_result  mp_int_expt(mp_int a, int b, mp_int c);     /* c = a^b   */
+mp_result  mp_int_expt_value(int a, int b, mp_int c);  /* c = a^b   */
 
-int       mp_int_compare(mp_int a, mp_int b);          /* a <=> b     */
-int       mp_int_compare_unsigned(mp_int a, mp_int b); /* |a| <=> |b| */
-int       mp_int_compare_zero(mp_int z);               /* a <=> 0     */
-int       mp_int_compare_value(mp_int z, int value);   /* a <=> v     */
+int            mp_int_compare(mp_int a, mp_int b); /* a <=> b     */
+int            mp_int_compare_unsigned(mp_int a, mp_int b);        /* |a| <=> |b| */
+int            mp_int_compare_zero(mp_int z);      /* a <=> 0     */
+int            mp_int_compare_value(mp_int z, int value);  /* a <=> v     */
 
 /* Returns true if v|a, false otherwise (including errors) */
-int       mp_int_divisible_value(mp_int a, int v);
+int            mp_int_divisible_value(mp_int a, int v);
 
 /* Returns k >= 0 such that z = 2^k, if one exists; otherwise < 0 */
-int       mp_int_is_pow2(mp_int z);
+int            mp_int_is_pow2(mp_int z);
 
-mp_result mp_int_exptmod(mp_int a, mp_int b, mp_int m,
-            mp_int c);                    /* c = a^b (mod m) */
-mp_result mp_int_exptmod_evalue(mp_int a, int value, 
-               mp_int m, mp_int c);   /* c = a^v (mod m) */
-mp_result mp_int_exptmod_bvalue(int value, mp_int b,
-               mp_int m, mp_int c);   /* c = v^b (mod m) */
-mp_result mp_int_exptmod_known(mp_int a, mp_int b,
-                  mp_int m, mp_int mu,
-                  mp_int c);              /* c = a^b (mod m) */
-mp_result mp_int_redux_const(mp_int m, mp_int c); 
+mp_result
+mp_int_exptmod(mp_int a, mp_int b, mp_int m,
+              mp_int c);       /* c = a^b (mod m) */
+mp_result
+mp_int_exptmod_evalue(mp_int a, int value,
+                     mp_int m, mp_int c);      /* c = a^v (mod m) */
+mp_result
+mp_int_exptmod_bvalue(int value, mp_int b,
+                     mp_int m, mp_int c);      /* c = v^b (mod m) */
+mp_result
+mp_int_exptmod_known(mp_int a, mp_int b,
+                    mp_int m, mp_int mu,
+                    mp_int c); /* c = a^b (mod m) */
+mp_result  mp_int_redux_const(mp_int m, mp_int c);
 
-mp_result mp_int_invmod(mp_int a, mp_int m, mp_int c); /* c = 1/a (mod m) */
+mp_result  mp_int_invmod(mp_int a, mp_int m, mp_int c);        /* c = 1/a (mod m) */
 
-mp_result mp_int_gcd(mp_int a, mp_int b, mp_int c);    /* c = gcd(a, b)   */
+mp_result  mp_int_gcd(mp_int a, mp_int b, mp_int c);   /* c = gcd(a, b)   */
 
-mp_result mp_int_egcd(mp_int a, mp_int b, mp_int c,    /* c = gcd(a, b)   */
-             mp_int x, mp_int y);             /* c = ax + by     */
+mp_result
+mp_int_egcd(mp_int a, mp_int b, mp_int c,      /* c = gcd(a, b)   */
+           mp_int x, mp_int y);    /* c = ax + by     */
 
-mp_result mp_int_sqrt(mp_int a, mp_int c);          /* c = floor(sqrt(q)) */
+mp_result  mp_int_sqrt(mp_int a, mp_int c);    /* c = floor(sqrt(q)) */
 
 /* Convert to an int, if representable (returns MP_RANGE if not). */
-mp_result mp_int_to_int(mp_int z, int *out);
+mp_result  mp_int_to_int(mp_int z, int *out);
 
 /* Convert to nul-terminated string with the specified radix, writing at
    most limit characters including the nul terminator  */
-mp_result mp_int_to_string(mp_int z, mp_size radix, 
-              char *str, int limit);
+mp_result mp_int_to_string(mp_int z, mp_size radix,
+                char *str, int limit);
 
-/* Return the number of characters required to represent 
+/* Return the number of characters required to represent
    z in the given radix.  May over-estimate. */
-mp_result mp_int_string_len(mp_int z, mp_size radix);
+mp_result  mp_int_string_len(mp_int z, mp_size radix);
 
 /* Read zero-terminated string into z */
-mp_result mp_int_read_string(mp_int z, mp_size radix, const char *str);
-mp_result mp_int_read_cstring(mp_int z, mp_size radix, const char *str, 
-                 char **end);
+mp_result  mp_int_read_string(mp_int z, mp_size radix, const char *str);
+mp_result mp_int_read_cstring(mp_int z, mp_size radix, const char *str,
+                   char **end);
 
 /* Return the number of significant bits in z */
-mp_result mp_int_count_bits(mp_int z);
+mp_result  mp_int_count_bits(mp_int z);
 
 /* Convert z to two's complement binary, writing at most limit bytes */
-mp_result mp_int_to_binary(mp_int z, unsigned char *buf, int limit);
+mp_result  mp_int_to_binary(mp_int z, unsigned char *buf, int limit);
 
 /* Read a two's complement binary value into z from the given buffer */
-mp_result mp_int_read_binary(mp_int z, unsigned char *buf, int len);
+mp_result  mp_int_read_binary(mp_int z, unsigned char *buf, int len);
 
 /* Return the number of bytes required to represent z in binary. */
-mp_result mp_int_binary_len(mp_int z);
+mp_result  mp_int_binary_len(mp_int z);
 
 /* Convert z to unsigned binary, writing at most limit bytes */
-mp_result mp_int_to_unsigned(mp_int z, unsigned char *buf, int limit);
+mp_result  mp_int_to_unsigned(mp_int z, unsigned char *buf, int limit);
 
 /* Read an unsigned binary value into z from the given buffer */
-mp_result mp_int_read_unsigned(mp_int z, unsigned char *buf, int len);
+mp_result  mp_int_read_unsigned(mp_int z, unsigned char *buf, int len);
 
 /* Return the number of bytes required to represent z as unsigned output */
-mp_result mp_int_unsigned_len(mp_int z);
+mp_result  mp_int_unsigned_len(mp_int z);
 
 /* Return a statically allocated string describing error code res */
 const char *mp_error_string(mp_result res);
 
 #if 0
-void      s_print(char *tag, mp_int z);
-void      s_print_buf(char *tag, mp_digit *buf, mp_size num);
+void       s_print(char *tag, mp_int z);
+void       s_print_buf(char *tag, mp_digit * buf, mp_size num);
 #endif
 
-#endif /* end IMATH_H_ */
+#endif   /* end IMATH_H_ */
index 6e1d97c4e31f1a336a2f9f432834eff763acc37f..d5530c39ed99e4f97961ef291308e3f3e62db1a9 100644 (file)
@@ -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-sha2.c,v 1.1 2006/07/13 04:15:24 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/internal-sha2.c,v 1.2 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
 #include "px.h"
 #include "sha2.h"
 
-void init_sha224(PX_MD * h);
-void init_sha256(PX_MD * h);
-void init_sha384(PX_MD * h);
-void init_sha512(PX_MD * h);
+void       init_sha224(PX_MD * h);
+void       init_sha256(PX_MD * h);
+void       init_sha384(PX_MD * h);
+void       init_sha512(PX_MD * h);
 
 /* SHA224 */
 
@@ -314,4 +314,3 @@ init_sha512(PX_MD * md)
 
    md->reset(md);
 }
-
index 4b90399cdd69858885efef74379ccad195bf1912..c0d8846a3c8a159d32deae2f79972be2a47f8cdf 100644 (file)
@@ -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.24 2006/07/13 04:15:24 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/internal.c,v 1.25 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
 static void init_md5(PX_MD * h);
 static void init_sha1(PX_MD * h);
 
-void init_sha224(PX_MD * h);
-void init_sha256(PX_MD * h);
-void init_sha384(PX_MD * h);
-void init_sha512(PX_MD * h);
+void       init_sha224(PX_MD * h);
+void       init_sha256(PX_MD * h);
+void       init_sha384(PX_MD * h);
+void       init_sha512(PX_MD * h);
 
 struct int_digest
 {
index 2ad5a63ebff9134be6764e25c5ae865fcd89bee6..7b159c4d568b8ae4cbdfc912968657b3e338e3b5 100644 (file)
@@ -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.29 2006/09/05 23:02:28 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/openssl.c,v 1.30 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
@@ -58,7 +58,6 @@
  */
 
 #include 
-
 #else                          /* old OPENSSL */
 
 /*
  * Emulate newer digest API.
  */
 
-static void EVP_MD_CTX_init(EVP_MD_CTX *ctx)
+static void
+EVP_MD_CTX_init(EVP_MD_CTX *ctx)
 {
    memset(ctx, 0, sizeof(*ctx));
 }
 
-static int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
+static int
+EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
 {
    memset(ctx, 0, sizeof(*ctx));
    return 1;
 }
 
-static int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *md, void *engine)
+static int
+EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *md, void *engine)
 {
    EVP_DigestInit(ctx, md);
    return 1;
 }
 
-static int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *res, unsigned int *len)
+static int
+EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *res, unsigned int *len)
 {
    EVP_DigestFinal(ctx, res, len);
    return 1;
 }
-
 #endif   /* old OpenSSL */
 
 /*
@@ -154,11 +156,12 @@ static int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *res, unsigned int
 #include "sha2.c"
 #include "internal-sha2.c"
 
-typedef void (*init_f)(PX_MD *md);
+typedef void (*init_f) (PX_MD * md);
 
-static int compat_find_digest(const char *name, PX_MD **res)
+static int
+compat_find_digest(const char *name, PX_MD ** res)
 {
-   init_f init = NULL;
+   init_f      init = NULL;
 
    if (pg_strcasecmp(name, "sha224") == 0)
        init = init_sha224;
@@ -175,7 +178,6 @@ static int compat_find_digest(const char *name, PX_MD **res)
    init(*res);
    return 0;
 }
-
 #else
 #define compat_find_digest(name, res)  (PXE_NO_HASH)
 #endif
@@ -184,29 +186,32 @@ static int compat_find_digest(const char *name, PX_MD **res)
  * Hashes
  */
 
-typedef struct OSSLDigest {
+typedef struct OSSLDigest
+{
    const EVP_MD *algo;
-   EVP_MD_CTX ctx;
-} OSSLDigest;
+   EVP_MD_CTX  ctx;
+}  OSSLDigest;
 
 static unsigned
 digest_result_size(PX_MD * h)
 {
-   OSSLDigest *digest = (OSSLDigest *)h->p.ptr;
+   OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
+
    return EVP_MD_CTX_size(&digest->ctx);
 }
 
 static unsigned
 digest_block_size(PX_MD * h)
 {
-   OSSLDigest *digest = (OSSLDigest *)h->p.ptr;
+   OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
+
    return EVP_MD_CTX_block_size(&digest->ctx);
 }
 
 static void
 digest_reset(PX_MD * h)
 {
-   OSSLDigest *digest = (OSSLDigest *)h->p.ptr;
+   OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
 
    EVP_DigestInit_ex(&digest->ctx, digest->algo, NULL);
 }
@@ -214,7 +219,7 @@ digest_reset(PX_MD * h)
 static void
 digest_update(PX_MD * h, const uint8 *data, unsigned dlen)
 {
-   OSSLDigest *digest = (OSSLDigest *)h->p.ptr;
+   OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
 
    EVP_DigestUpdate(&digest->ctx, data, dlen);
 }
@@ -222,7 +227,7 @@ digest_update(PX_MD * h, const uint8 *data, unsigned dlen)
 static void
 digest_finish(PX_MD * h, uint8 *dst)
 {
-   OSSLDigest *digest = (OSSLDigest *)h->p.ptr;
+   OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
 
    EVP_DigestFinal_ex(&digest->ctx, dst, NULL);
 }
@@ -230,7 +235,7 @@ digest_finish(PX_MD * h, uint8 *dst)
 static void
 digest_free(PX_MD * h)
 {
-   OSSLDigest *digest = (OSSLDigest *)h->p.ptr;
+   OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
 
    EVP_MD_CTX_cleanup(&digest->ctx);
 
@@ -560,7 +565,7 @@ ossl_des3_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen,
    ossldata   *od = c->ptr;
 
    for (i = 0; i < dlen / bs; i++)
-       DES_ecb3_encrypt((void *)(data + i * bs), (void *)(res + i * bs),
+       DES_ecb3_encrypt((void *) (data + i * bs), (void *) (res + i * bs),
                         &od->u.des3.k1, &od->u.des3.k2, &od->u.des3.k3, 1);
    return 0;
 }
@@ -574,7 +579,7 @@ ossl_des3_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen,
    ossldata   *od = c->ptr;
 
    for (i = 0; i < dlen / bs; i++)
-       DES_ecb3_encrypt((void *)(data + i * bs), (void *)(res + i * bs),
+       DES_ecb3_encrypt((void *) (data + i * bs), (void *) (res + i * bs),
                         &od->u.des3.k1, &od->u.des3.k2, &od->u.des3.k3, 0);
    return 0;
 }
index 083b31d4c2eff65527c1efa74846d20ecc6134c1..31c3a59ee5a444f24ba22d9957fd6f1619c54dd2 100644 (file)
@@ -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.23 2006/09/05 21:26:48 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgcrypto.c,v 1.24 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
@@ -491,9 +491,9 @@ PG_FUNCTION_INFO_V1(pg_random_bytes);
 Datum
 pg_random_bytes(PG_FUNCTION_ARGS)
 {
-   int err;
-   int len = PG_GETARG_INT32(0);
-   bytea *res;
+   int         err;
+   int         len = PG_GETARG_INT32(0);
+   bytea      *res;
 
    if (len < 1 || len > 1024)
        ereport(ERROR,
@@ -504,7 +504,7 @@ pg_random_bytes(PG_FUNCTION_ARGS)
    VARATT_SIZEP(res) = VARHDRSZ + len;
 
    /* generate result */
-   err = px_get_random_bytes((uint8*)VARDATA(res), len);
+   err = px_get_random_bytes((uint8 *) VARDATA(res), len);
    if (err < 0)
        ereport(ERROR,
                (errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
index 4f2e5ec9626d5bc109cfb9840aea84685cfb5b84..d2b5d0c8de73ee0d88b7c31b738ca135ac5f540d 100644 (file)
@@ -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.6 2006/07/13 04:52:51 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-mpi-internal.c,v 1.7 2006/10/04 00:29:46 momjian Exp $
  */
 #include "postgres.h"
 
 #include "mbuf.h"
 #include "pgp.h"
 
-static mpz_t *mp_new()
+static mpz_t *
+mp_new()
 {
-   mpz_t *mp = mp_int_alloc();
+   mpz_t      *mp = mp_int_alloc();
+
    mp_int_init_size(mp, 256);
    return mp;
 }
 
-static void mp_clear_free(mpz_t *a)
+static void
+mp_clear_free(mpz_t * a)
 {
    if (!a)
        return;
@@ -52,25 +55,29 @@ static void mp_clear_free(mpz_t *a)
 }
 
 
-static int mp_px_rand(uint32 bits, mpz_t *res)
+static int
+mp_px_rand(uint32 bits, mpz_t * res)
 {
-   int err;
-   unsigned bytes = (bits + 7) / 8;
-   int last_bits = bits & 7;
-   uint8 *buf;
+   int         err;
+   unsigned    bytes = (bits + 7) / 8;
+   int         last_bits = bits & 7;
+   uint8      *buf;
 
    buf = px_alloc(bytes);
    err = px_get_random_bytes(buf, bytes);
-   if (err < 0) {
+   if (err < 0)
+   {
        px_free(buf);
        return err;
    }
 
    /* clear unnecessary bits and set last bit to one */
-   if (last_bits) {
+   if (last_bits)
+   {
        buf[0] >>= 8 - last_bits;
        buf[0] |= 1 << (last_bits - 1);
-   } else
+   }
+   else
        buf[0] |= 1 << 7;
 
    mp_int_read_unsigned(res, buf, bytes);
@@ -80,9 +87,11 @@ static int mp_px_rand(uint32 bits, mpz_t *res)
    return 0;
 }
 
-static void mp_modmul(mpz_t *a, mpz_t *b, mpz_t *p, mpz_t *res)
+static void
+mp_modmul(mpz_t * a, mpz_t * b, mpz_t * p, mpz_t * res)
 {
-   mpz_t *tmp = mp_new();
+   mpz_t      *tmp = mp_new();
+
    mp_int_mul(a, b, tmp);
    mp_int_mod(tmp, p, res);
    mp_clear_free(tmp);
@@ -92,6 +101,7 @@ static mpz_t *
 mpi_to_bn(PGP_MPI * n)
 {
    mpz_t      *bn = mp_new();
+
    mp_int_read_unsigned(bn, n->data, n->bytes);
 
    if (!bn)
@@ -107,11 +117,11 @@ mpi_to_bn(PGP_MPI * n)
 }
 
 static PGP_MPI *
-bn_to_mpi(mpz_t *bn)
+bn_to_mpi(mpz_t * bn)
 {
    int         res;
    PGP_MPI    *n;
-   int bytes;
+   int         bytes;
 
    res = pgp_mpi_alloc(mp_int_count_bits(bn), &n);
    if (res < 0)
index 98e1fc1964dc4fab64fb5a19a801e9a7d9092ede..31623fb9a6990544e9546e21248ee23cd412620a 100644 (file)
@@ -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.7 2006/07/13 04:15:25 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/sha2.c,v 1.8 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
@@ -534,7 +534,7 @@ SHA256_Update(SHA256_CTX * context, const uint8 *data, size_t len)
 }
 
 static void
-SHA256_Last(SHA256_CTX *context)
+SHA256_Last(SHA256_CTX * context)
 {
    unsigned int usedspace;
 
@@ -1023,4 +1023,3 @@ SHA224_Final(uint8 digest[], SHA224_CTX * context)
    /* Clean up state data: */
    memset(context, 0, sizeof(*context));
 }
-
index 13d3f2164fcdd36f9f6cf38d4d190000e81d6788..002536b920196588d10ef777abbe339f77ad31ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgrowlocks/pgrowlocks.c,v 1.4 2006/07/13 16:57:31 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/pgrowlocks/pgrowlocks.c,v 1.5 2006/10/04 00:29:46 momjian Exp $
  *
  * Copyright (c) 2005-2006 Tatsuo Ishii
  *
@@ -63,11 +63,12 @@ extern Datum pgrowlocks(PG_FUNCTION_ARGS);
  */
 #undef MAKERANGEVARFROMNAMELIST_HAS_TWO_ARGS
 
-typedef struct {
+typedef struct
+{
    Relation    rel;
    HeapScanDesc scan;
-   int ncolumns;
-} MyData;
+   int         ncolumns;
+}  MyData;
 
 Datum
 pgrowlocks(PG_FUNCTION_ARGS)
@@ -78,7 +79,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
    TupleDesc   tupdesc;
    AttInMetadata *attinmeta;
    Datum       result;
-   MyData *mydata;
+   MyData     *mydata;
    Relation    rel;
 
    if (SRF_IS_FIRSTCALL())
@@ -96,8 +97,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
 
        relname = PG_GETARG_TEXT_P(0);
 #ifdef MAKERANGEVARFROMNAMELIST_HAS_TWO_ARGS
-       relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname,                                                "pgrowlocks"));
-
+       relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname, "pgrowlocks"));
 #else
        relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
 #endif
@@ -114,7 +114,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
 
    funcctx = SRF_PERCALL_SETUP();
    attinmeta = funcctx->attinmeta;
-   mydata = (MyData *)funcctx->user_fctx;
+   mydata = (MyData *) funcctx->user_fctx;
    scan = mydata->scan;
 
    /* scan the relation */
@@ -124,16 +124,16 @@ pgrowlocks(PG_FUNCTION_ARGS)
        LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
 
        if (HeapTupleSatisfiesUpdate(tuple->t_data, GetCurrentCommandId(), scan->rs_cbuf)
-           == HeapTupleBeingUpdated)
+           == HeapTupleBeingUpdated)
        {
 
-           char **values;
-           int i;
+           char      **values;
+           int         i;
 
            values = (char **) palloc(mydata->ncolumns * sizeof(char *));
 
            i = 0;
-           values[i++] = (char *)DirectFunctionCall1(tidout, PointerGetDatum(&tuple->t_self));
+           values[i++] = (char *) DirectFunctionCall1(tidout, PointerGetDatum(&tuple->t_self));
 
 #ifdef HEAP_XMAX_SHARED_LOCK
            if (tuple->t_data->t_infomask & HEAP_XMAX_SHARED_LOCK)
@@ -143,15 +143,15 @@ pgrowlocks(PG_FUNCTION_ARGS)
 #else
            values[i++] = pstrdup("Exclusive");
 #endif
-           values[i] = palloc(NCHARS*sizeof(char));
+           values[i] = palloc(NCHARS * sizeof(char));
            snprintf(values[i++], NCHARS, "%d", HeapTupleHeaderGetXmax(tuple->t_data));
 #ifdef HEAP_XMAX_SHARED_LOCK
            if (tuple->t_data->t_infomask & HEAP_XMAX_IS_MULTI)
            {
                TransactionId *xids;
-               int nxids;
-               int j;
-               int isValidXid = 0;     /* any valid xid ever exists? */
+               int         nxids;
+               int         j;
+               int         isValidXid = 0;     /* any valid xid ever exists? */
 
                values[i++] = pstrdup("true");
                nxids = GetMultiXactIdMembers(HeapTupleHeaderGetXmax(tuple->t_data), &xids);
@@ -160,45 +160,44 @@ pgrowlocks(PG_FUNCTION_ARGS)
                    elog(ERROR, "GetMultiXactIdMembers returns error");
                }
 
-               values[i] = palloc(NCHARS*nxids);
-               values[i+1] = palloc(NCHARS*nxids);
+               values[i] = palloc(NCHARS * nxids);
+               values[i + 1] = palloc(NCHARS * nxids);
                strcpy(values[i], "{");
-               strcpy(values[i+1], "{");
+               strcpy(values[i + 1], "{");
 
-               for (j=0;jj++)
+               for (j = 0; j < nxids; j++)
                {
-                   char buf[NCHARS];
+                   char        buf[NCHARS];
 
                    if (TransactionIdIsInProgress(xids[j]))
                    {
                        if (isValidXid)
                        {
                            strcat(values[i], ",");
-                           strcat(values[i+1], ",");
+                           strcat(values[i + 1], ",");
                        }
                        snprintf(buf, NCHARS, "%d", xids[j]);
                        strcat(values[i], buf);
                        snprintf(buf, NCHARS, "%d", BackendXidGetPid(xids[j]));
-                       strcat(values[i+1], buf);
+                       strcat(values[i + 1], buf);
 
                        isValidXid = 1;
                    }
                }
 
                strcat(values[i], "}");
-               strcat(values[i+1], "}");
+               strcat(values[i + 1], "}");
                i++;
            }
            else
            {
                values[i++] = pstrdup("false");
-               values[i] = palloc(NCHARS*sizeof(char));
+               values[i] = palloc(NCHARS * sizeof(char));
                snprintf(values[i++], NCHARS, "{%d}", HeapTupleHeaderGetXmax(tuple->t_data));
 
-               values[i] = palloc(NCHARS*sizeof(char));
+               values[i] = palloc(NCHARS * sizeof(char));
                snprintf(values[i++], NCHARS, "{%d}", BackendXidGetPid(HeapTupleHeaderGetXmax(tuple->t_data)));
            }
-
 #else
            values[i++] = pstrdup("false");
            values[i++] = pstrdup("{}");
index 6ff6012073a7c172d9f5fb48a02dea46ed828e93..5bac70949d098a48d0cd5cb1e5a37b0bf39ff5c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.24 2006/09/04 02:03:04 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.25 2006/10/04 00:29:46 momjian Exp $
  *
  * Copyright (c) 2001,2002 Tatsuo Ishii
  *
@@ -51,36 +51,36 @@ extern Datum pgstattuplebyid(PG_FUNCTION_ARGS);
  */
 typedef struct pgstattuple_type
 {
-   uint64  table_len;
-   uint64  tuple_count;
-   uint64  tuple_len;
-   uint64  dead_tuple_count;
-   uint64  dead_tuple_len;
-   uint64  free_space;         /* free/reusable space in bytes */
-} pgstattuple_type;
-
-typedef void (*pgstat_page)(pgstattuple_type *, Relation, BlockNumber);
-
-static Datum build_pgstattuple_type(pgstattuple_type *stat,
-   FunctionCallInfo fcinfo);
+   uint64      table_len;
+   uint64      tuple_count;
+   uint64      tuple_len;
+   uint64      dead_tuple_count;
+   uint64      dead_tuple_len;
+   uint64      free_space;     /* free/reusable space in bytes */
+}  pgstattuple_type;
+
+typedef void (*pgstat_page) (pgstattuple_type *, Relation, BlockNumber);
+
+static Datum build_pgstattuple_type(pgstattuple_type * stat,
+                      FunctionCallInfo fcinfo);
 static Datum pgstat_relation(Relation rel, FunctionCallInfo fcinfo);
 static Datum pgstat_heap(Relation rel, FunctionCallInfo fcinfo);
-static void pgstat_btree_page(pgstattuple_type *stat,
-   Relation rel, BlockNumber blkno);
-static void pgstat_hash_page(pgstattuple_type *stat,
-   Relation rel, BlockNumber blkno);
-static void pgstat_gist_page(pgstattuple_type *stat,
-   Relation rel, BlockNumber blkno);
+static void pgstat_btree_page(pgstattuple_type * stat,
+                 Relation rel, BlockNumber blkno);
+static void pgstat_hash_page(pgstattuple_type * stat,
+                Relation rel, BlockNumber blkno);
+static void pgstat_gist_page(pgstattuple_type * stat,
+                Relation rel, BlockNumber blkno);
 static Datum pgstat_index(Relation rel, BlockNumber start,
-   pgstat_page pagefn, FunctionCallInfo fcinfo);
-static void pgstat_index_page(pgstattuple_type *stat, Page page,
-   OffsetNumber minoff, OffsetNumber maxoff);
+            pgstat_page pagefn, FunctionCallInfo fcinfo);
+static void pgstat_index_page(pgstattuple_type * stat, Page page,
+                 OffsetNumber minoff, OffsetNumber maxoff);
 
 /*
  * build_pgstattuple_type -- build a pgstattuple_type tuple
  */
 static Datum
-build_pgstattuple_type(pgstattuple_type *stat, FunctionCallInfo fcinfo)
+build_pgstattuple_type(pgstattuple_type * stat, FunctionCallInfo fcinfo)
 {
 #define NCOLUMNS   9
 #define NCHARS     32
@@ -91,7 +91,7 @@ build_pgstattuple_type(pgstattuple_type *stat, FunctionCallInfo fcinfo)
    int         i;
    double      tuple_percent;
    double      dead_tuple_percent;
-   double      free_percent;       /* free/reusable space in % */
+   double      free_percent;   /* free/reusable space in % */
    TupleDesc   tupdesc;
    AttInMetadata *attinmeta;
 
@@ -190,49 +190,49 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
 {
    const char *err;
 
-   switch(rel->rd_rel->relkind)
+   switch (rel->rd_rel->relkind)
    {
-   case RELKIND_RELATION:
-   case RELKIND_TOASTVALUE:
-   case RELKIND_UNCATALOGED:
-   case RELKIND_SEQUENCE:
-       return pgstat_heap(rel, fcinfo);
-   case RELKIND_INDEX:
-       switch(rel->rd_rel->relam)
-       {
-       case BTREE_AM_OID:
-           return pgstat_index(rel, BTREE_METAPAGE + 1,
-               pgstat_btree_page, fcinfo);
-       case HASH_AM_OID:
-           return pgstat_index(rel, HASH_METAPAGE + 1,
-               pgstat_hash_page, fcinfo);
-       case GIST_AM_OID:
-           return pgstat_index(rel, GIST_ROOT_BLKNO + 1,
-               pgstat_gist_page, fcinfo);
-       case GIN_AM_OID:
-           err = "gin index";
+       case RELKIND_RELATION:
+       case RELKIND_TOASTVALUE:
+       case RELKIND_UNCATALOGED:
+       case RELKIND_SEQUENCE:
+           return pgstat_heap(rel, fcinfo);
+       case RELKIND_INDEX:
+           switch (rel->rd_rel->relam)
+           {
+               case BTREE_AM_OID:
+                   return pgstat_index(rel, BTREE_METAPAGE + 1,
+                                       pgstat_btree_page, fcinfo);
+               case HASH_AM_OID:
+                   return pgstat_index(rel, HASH_METAPAGE + 1,
+                                       pgstat_hash_page, fcinfo);
+               case GIST_AM_OID:
+                   return pgstat_index(rel, GIST_ROOT_BLKNO + 1,
+                                       pgstat_gist_page, fcinfo);
+               case GIN_AM_OID:
+                   err = "gin index";
+                   break;
+               default:
+                   err = "unknown index";
+                   break;
+           }
+           break;
+       case RELKIND_VIEW:
+           err = "view";
+           break;
+       case RELKIND_COMPOSITE_TYPE:
+           err = "composite type";
            break;
        default:
-           err = "unknown index";
+           err = "unknown";
            break;
-       }
-       break;
-   case RELKIND_VIEW:
-       err = "view";
-       break;
-   case RELKIND_COMPOSITE_TYPE:
-       err = "composite type";
-       break;
-   default:
-       err = "unknown";
-       break;
    }
 
    ereport(ERROR,
            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
             errmsg("\"%s\" (%s) is not supported",
-               RelationGetRelationName(rel), err)));
-   return 0;   /* should not happen */
+                   RelationGetRelationName(rel), err)));
+   return 0;                   /* should not happen */
 }
 
 /*
@@ -241,13 +241,13 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
 static Datum
 pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
 {
-   HeapScanDesc    scan;
-   HeapTuple       tuple;
-   BlockNumber     nblocks;
-   BlockNumber     block = 0;  /* next block to count free space in */
-   BlockNumber     tupblock;
-   Buffer          buffer;
-   pgstattuple_type    stat = { 0 };
+   HeapScanDesc scan;
+   HeapTuple   tuple;
+   BlockNumber nblocks;
+   BlockNumber block = 0;      /* next block to count free space in */
+   BlockNumber tupblock;
+   Buffer      buffer;
+   pgstattuple_type stat = {0};
 
    scan = heap_beginscan(rel, SnapshotAny, 0, NULL);
 
@@ -302,7 +302,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
 
    relation_close(rel, AccessShareLock);
 
-   stat.table_len = (uint64) nblocks * BLCKSZ;
+   stat.table_len = (uint64) nblocks *BLCKSZ;
 
    return build_pgstattuple_type(&stat, fcinfo);
 }
@@ -311,10 +311,10 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
  * pgstat_btree_page -- check tuples in a btree page
  */
 static void
-pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
+pgstat_btree_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno)
 {
-   Buffer              buf;
-   Page                page;
+   Buffer      buf;
+   Page        page;
 
    buf = ReadBuffer(rel, blkno);
    LockBuffer(buf, BT_READ);
@@ -328,7 +328,8 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
    }
    else
    {
-       BTPageOpaque    opaque;
+       BTPageOpaque opaque;
+
        opaque = (BTPageOpaque) PageGetSpecialPointer(page);
        if (opaque->btpo_flags & (BTP_DELETED | BTP_HALF_DEAD))
        {
@@ -338,7 +339,7 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
        else if (P_ISLEAF(opaque))
        {
            pgstat_index_page(stat, page, P_FIRSTDATAKEY(opaque),
-               PageGetMaxOffsetNumber(page));
+                             PageGetMaxOffsetNumber(page));
        }
        else
        {
@@ -353,10 +354,10 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
  * pgstat_hash_page -- check tuples in a hash page
  */
 static void
-pgstat_hash_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
+pgstat_hash_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno)
 {
-   Buffer          buf;
-   Page            page;
+   Buffer      buf;
+   Page        page;
 
    _hash_getlock(rel, blkno, HASH_SHARE);
    buf = _hash_getbuf(rel, blkno, HASH_READ);
@@ -364,22 +365,23 @@ pgstat_hash_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
 
    if (PageGetSpecialSize(page) == MAXALIGN(sizeof(HashPageOpaqueData)))
    {
-       HashPageOpaque  opaque;
+       HashPageOpaque opaque;
+
        opaque = (HashPageOpaque) PageGetSpecialPointer(page);
        switch (opaque->hasho_flag)
        {
-       case LH_UNUSED_PAGE:
-           stat->free_space += BLCKSZ;
-           break;
-       case LH_BUCKET_PAGE:
-       case LH_OVERFLOW_PAGE:
-           pgstat_index_page(stat, page, FirstOffsetNumber,
-               PageGetMaxOffsetNumber(page));
-           break;
-       case LH_BITMAP_PAGE:
-       case LH_META_PAGE:
-       default:
-           break;
+           case LH_UNUSED_PAGE:
+               stat->free_space += BLCKSZ;
+               break;
+           case LH_BUCKET_PAGE:
+           case LH_OVERFLOW_PAGE:
+               pgstat_index_page(stat, page, FirstOffsetNumber,
+                                 PageGetMaxOffsetNumber(page));
+               break;
+           case LH_BITMAP_PAGE:
+           case LH_META_PAGE:
+           default:
+               break;
        }
    }
    else
@@ -395,10 +397,10 @@ pgstat_hash_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
  * pgstat_gist_page -- check tuples in a gist page
  */
 static void
-pgstat_gist_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
+pgstat_gist_page(pgstattuple_type * stat, Relation rel, BlockNumber blkno)
 {
-   Buffer          buf;
-   Page            page;
+   Buffer      buf;
+   Page        page;
 
    buf = ReadBuffer(rel, blkno);
    LockBuffer(buf, GIST_SHARE);
@@ -408,7 +410,7 @@ pgstat_gist_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
    if (GistPageIsLeaf(page))
    {
        pgstat_index_page(stat, page, FirstOffsetNumber,
-           PageGetMaxOffsetNumber(page));
+                         PageGetMaxOffsetNumber(page));
    }
    else
    {
@@ -427,7 +429,7 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn,
 {
    BlockNumber nblocks;
    BlockNumber blkno;
-   pgstattuple_type    stat = { 0 };
+   pgstattuple_type stat = {0};
 
    blkno = start;
    for (;;)
@@ -440,7 +442,8 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn,
        /* Quit if we've scanned the whole relation */
        if (blkno >= nblocks)
        {
-           stat.table_len = (uint64) nblocks * BLCKSZ;
+           stat.table_len = (uint64) nblocks *BLCKSZ;
+
            break;
        }
 
@@ -457,16 +460,16 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn,
  * pgstat_index_page -- for generic index page
  */
 static void
-pgstat_index_page(pgstattuple_type *stat, Page page,
-   OffsetNumber minoff, OffsetNumber maxoff)
+pgstat_index_page(pgstattuple_type * stat, Page page,
+                 OffsetNumber minoff, OffsetNumber maxoff)
 {
-   OffsetNumber    i;
+   OffsetNumber i;
 
    stat->free_space += PageGetFreeSpace(page);
 
    for (i = minoff; i <= maxoff; i = OffsetNumberNext(i))
    {
-       ItemId  itemid = PageGetItemId(page, i);
+       ItemId      itemid = PageGetItemId(page, i);
 
        if (ItemIdDeleted(itemid))
        {
index afaa7079af2886c50ba2255e91f03563bf960c20..16eea5eae3330d76a932d183dceb588cc625e789 100644 (file)
@@ -4,7 +4,7 @@
  * Written by Victor B. Wagner , Cryptocom LTD
  * This file is distributed under BSD-style license.
  *
- * $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.4 2006/09/30 18:44:37 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/sslinfo/sslinfo.c,v 1.5 2006/10/04 00:29:46 momjian Exp $
  */
 
 #include "postgres.h"
 PG_MODULE_MAGIC;
 
 
-Datum ssl_is_used(PG_FUNCTION_ARGS);
-Datum ssl_client_cert_present(PG_FUNCTION_ARGS);
-Datum ssl_client_serial(PG_FUNCTION_ARGS);
-Datum ssl_client_dn_field(PG_FUNCTION_ARGS);
-Datum ssl_issuer_field(PG_FUNCTION_ARGS);
-Datum ssl_client_dn(PG_FUNCTION_ARGS);
-Datum ssl_issuer_dn(PG_FUNCTION_ARGS);
-Datum X509_NAME_field_to_text(X509_NAME *name, text *fieldName);
-Datum X509_NAME_to_text(X509_NAME *name);
-Datum ASN1_STRING_to_text(ASN1_STRING *str);
+Datum      ssl_is_used(PG_FUNCTION_ARGS);
+Datum      ssl_client_cert_present(PG_FUNCTION_ARGS);
+Datum      ssl_client_serial(PG_FUNCTION_ARGS);
+Datum      ssl_client_dn_field(PG_FUNCTION_ARGS);
+Datum      ssl_issuer_field(PG_FUNCTION_ARGS);
+Datum      ssl_client_dn(PG_FUNCTION_ARGS);
+Datum      ssl_issuer_dn(PG_FUNCTION_ARGS);
+Datum      X509_NAME_field_to_text(X509_NAME *name, text *fieldName);
+Datum      X509_NAME_to_text(X509_NAME *name);
+Datum      ASN1_STRING_to_text(ASN1_STRING *str);
 
 
-/* 
+/*
  * Indicates whether current session uses SSL
  *
  * Function has no arguments.  Returns bool.  True if current session
  * is SSL session and false if it is local or non-ssl session.
  */
 PG_FUNCTION_INFO_V1(ssl_is_used);
-Datum ssl_is_used(PG_FUNCTION_ARGS)
+Datum
+ssl_is_used(PG_FUNCTION_ARGS)
 {
-   PG_RETURN_BOOL(MyProcPort->ssl !=NULL);
+   PG_RETURN_BOOL(MyProcPort->ssl != NULL);
 }
 
 
@@ -54,7 +55,8 @@ Datum ssl_is_used(PG_FUNCTION_ARGS)
  * is SSL session and client certificate is verified, otherwise false.
  */
 PG_FUNCTION_INFO_V1(ssl_client_cert_present);
-Datum ssl_client_cert_present(PG_FUNCTION_ARGS)
+Datum
+ssl_client_cert_present(PG_FUNCTION_ARGS)
 {
    PG_RETURN_BOOL(MyProcPort->peer != NULL);
 }
@@ -69,20 +71,22 @@ Datum ssl_client_cert_present(PG_FUNCTION_ARGS)
  * SSL connection is established without sending client certificate.
  */
 PG_FUNCTION_INFO_V1(ssl_client_serial);
-Datum ssl_client_serial(PG_FUNCTION_ARGS)
+Datum
+ssl_client_serial(PG_FUNCTION_ARGS)
 {
-   Datum result;
-   Port *port = MyProcPort;
-   X509 *peer = port->peer;
+   Datum       result;
+   Port       *port = MyProcPort;
+   X509       *peer = port->peer;
    ASN1_INTEGER *serial = NULL;
-   BIGNUM *b;
-   char *decimal;
+   BIGNUM     *b;
+   char       *decimal;
 
    if (!peer)
        PG_RETURN_NULL();
    serial = X509_get_serialNumber(peer);
    b = ASN1_INTEGER_to_BN(serial, NULL);
    decimal = BN_bn2dec(b);
+
    BN_free(b);
    result = DirectFunctionCall3(numeric_in,
                                 CStringGetDatum(decimal),
@@ -100,23 +104,25 @@ Datum ssl_client_serial(PG_FUNCTION_ARGS)
  * current database encoding if possible.  Any invalid characters are
  * replaced by question marks.
  *
- * Parameter: str - OpenSSL ASN1_STRING structure.  Memory managment
+ * Parameter: str - OpenSSL ASN1_STRING structure. Memory managment
  * of this structure is responsibility of caller.
  *
  * Returns Datum, which can be directly returned from a C language SQL
  * function.
  */
-Datum ASN1_STRING_to_text(ASN1_STRING *str)
+Datum
+ASN1_STRING_to_text(ASN1_STRING *str)
 {
-   BIO *membuf = NULL;
-   size_t size, outlen;
-   char *sp;
-   char *dp;
-   text *result;
+   BIO        *membuf = NULL;
+   size_t      size,
+               outlen;
+   char       *sp;
+   char       *dp;
+   text       *result;
 
    membuf = BIO_new(BIO_s_mem());
    (void) BIO_set_close(membuf, BIO_CLOSE);
-   ASN1_STRING_print_ex(membuf,str,
+   ASN1_STRING_print_ex(membuf, str,
                         ((ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB)
                          | ASN1_STRFLGS_UTF8_CONVERT));
 
@@ -124,7 +130,7 @@ Datum ASN1_STRING_to_text(ASN1_STRING *str)
    BIO_write(membuf, &outlen, 1);
    size = BIO_get_mem_data(membuf, &sp);
    dp = (char *) pg_do_encoding_conversion((unsigned char *) sp,
-                                           size-1,
+                                           size - 1,
                                            PG_UTF8,
                                            GetDatabaseEncoding());
    outlen = strlen(dp);
@@ -146,18 +152,21 @@ Datum ASN1_STRING_to_text(ASN1_STRING *str)
  *
  * Parameter: X509_NAME *name - either subject or issuer of certificate
  * Parameter: text fieldName  - field name string like 'CN' or commonName
- *            to be looked up in the OpenSSL ASN1 OID database
+ *           to be looked up in the OpenSSL ASN1 OID database
  *
  * Returns result of ASN1_STRING_to_text applied to appropriate
  * part of name
  */
-Datum X509_NAME_field_to_text(X509_NAME *name, text *fieldName)
+Datum
+X509_NAME_field_to_text(X509_NAME *name, text *fieldName)
 {
-   char *sp;
-   char *string_fieldname;
-   char *dp;
-   size_t name_len = VARSIZE(fieldName) - VARHDRSZ;
-   int nid, index, i;
+   char       *sp;
+   char       *string_fieldname;
+   char       *dp;
+   size_t      name_len = VARSIZE(fieldName) - VARHDRSZ;
+   int         nid,
+               index,
+               i;
    ASN1_STRING *data;
 
    string_fieldname = palloc(name_len + 1);
@@ -175,7 +184,7 @@ Datum X509_NAME_field_to_text(X509_NAME *name, text *fieldName)
    pfree(string_fieldname);
    index = X509_NAME_get_index_by_NID(name, nid, -1);
    if (index < 0)
-       return (Datum)0;
+       return (Datum) 0;
    data = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, index));
    return ASN1_STRING_to_text(data);
 }
@@ -198,10 +207,11 @@ Datum X509_NAME_field_to_text(X509_NAME *name, text *fieldName)
  * there is no field with such name in the certificate.
  */
 PG_FUNCTION_INFO_V1(ssl_client_dn_field);
-Datum ssl_client_dn_field(PG_FUNCTION_ARGS)
+Datum
+ssl_client_dn_field(PG_FUNCTION_ARGS)
 {
-   text *fieldname = PG_GETARG_TEXT_P(0);
-   Datum result;
+   text       *fieldname = PG_GETARG_TEXT_P(0);
+   Datum       result;
 
    if (!(MyProcPort->peer))
        PG_RETURN_NULL();
@@ -232,10 +242,11 @@ Datum ssl_client_dn_field(PG_FUNCTION_ARGS)
  * there is no field with such name in the certificate.
  */
 PG_FUNCTION_INFO_V1(ssl_issuer_field);
-Datum ssl_issuer_field(PG_FUNCTION_ARGS)
+Datum
+ssl_issuer_field(PG_FUNCTION_ARGS)
 {
-   text *fieldname = PG_GETARG_TEXT_P(0);
-   Datum result;
+   text       *fieldname = PG_GETARG_TEXT_P(0);
+   Datum       result;
 
    if (!(MyProcPort->peer))
        PG_RETURN_NULL();
@@ -260,21 +271,25 @@ Datum ssl_issuer_field(PG_FUNCTION_ARGS)
  * Returns: text datum which contains string representation of
  * X509_NAME
  */
-Datum X509_NAME_to_text(X509_NAME *name)
+Datum
+X509_NAME_to_text(X509_NAME *name)
 {
-   BIO *membuf = BIO_new(BIO_s_mem());
-   int i,nid,count = X509_NAME_entry_count(name);
+   BIO        *membuf = BIO_new(BIO_s_mem());
+   int         i,
+               nid,
+               count = X509_NAME_entry_count(name);
    X509_NAME_ENTRY *e;
    ASN1_STRING *v;
 
    const char *field_name;
-   size_t size,outlen;
-   char *sp;
-   char *dp;
-   text *result;
+   size_t      size,
+               outlen;
+   char       *sp;
+   char       *dp;
+   text       *result;
 
    (void) BIO_set_close(membuf, BIO_CLOSE);
-   for (i=0; i<count; i++)
+   for (i = 0; i < count; i++)
    {
        e = X509_NAME_get_entry(name, i);
        nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(e));
@@ -283,17 +298,17 @@ Datum X509_NAME_to_text(X509_NAME *name)
        if (!field_name)
            field_name = OBJ_nid2ln(nid);
        BIO_printf(membuf, "/%s=", field_name);
-       ASN1_STRING_print_ex(membuf,v,
+       ASN1_STRING_print_ex(membuf, v,
                             ((ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB)
                              | ASN1_STRFLGS_UTF8_CONVERT));
    }
 
-   i=0;
+   i = 0;
    BIO_write(membuf, &i, 1);
    size = BIO_get_mem_data(membuf, &sp);
 
    dp = (char *) pg_do_encoding_conversion((unsigned char *) sp,
-                                           size-1,
+                                           size - 1,
                                            PG_UTF8,
                                            GetDatabaseEncoding());
    BIO_free(membuf);
@@ -301,8 +316,10 @@ Datum X509_NAME_to_text(X509_NAME *name)
    result = palloc(VARHDRSZ + outlen);
    memcpy(VARDATA(result), dp, outlen);
 
-   /* pg_do_encoding_conversion has annoying habit of returning
-    * source pointer */
+   /*
+    * pg_do_encoding_conversion has annoying habit of returning source
+    * pointer
+    */
    if (dp != sp)
        pfree(dp);
    VARATT_SIZEP(result) = outlen + VARHDRSZ;
@@ -320,7 +337,8 @@ Datum X509_NAME_to_text(X509_NAME *name)
  * Returns text datum.
  */
 PG_FUNCTION_INFO_V1(ssl_client_dn);
-Datum ssl_client_dn(PG_FUNCTION_ARGS)
+Datum
+ssl_client_dn(PG_FUNCTION_ARGS)
 {
    if (!(MyProcPort->peer))
        PG_RETURN_NULL();
@@ -338,7 +356,8 @@ Datum ssl_client_dn(PG_FUNCTION_ARGS)
  * Returns text datum.
  */
 PG_FUNCTION_INFO_V1(ssl_issuer_dn);
-Datum ssl_issuer_dn(PG_FUNCTION_ARGS)
+Datum
+ssl_issuer_dn(PG_FUNCTION_ARGS)
 {
    if (!(MyProcPort->peer))
        PG_RETURN_NULL();
index 7ab363972e5beab72962d7a8d20b5084e61a0871..b63bd21cd7d5cc5e6b4f97cab6dbb5f2049532d9 100644 (file)
@@ -1259,7 +1259,7 @@ build_tuplestore_recursively(char *key_fld,
    int         ret;
    int         proc;
    int         serial_column;
-   StringInfoData  sql;
+   StringInfoData sql;
    char      **values;
    char       *current_key;
    char       *current_key_parent;
@@ -1357,9 +1357,9 @@ build_tuplestore_recursively(char *key_fld,
        SPITupleTable *tuptable = SPI_tuptable;
        TupleDesc   spi_tupdesc = tuptable->tupdesc;
        int         i;
-       StringInfoData  branchstr;
-       StringInfoData  chk_branchstr;
-       StringInfoData  chk_current_key;
+       StringInfoData branchstr;
+       StringInfoData chk_branchstr;
+       StringInfoData chk_current_key;
 
        /* First time through, do a little more setup */
        if (level == 0)
index 6192821344370785bc6d1e00e978894956875e85..3ff3fad1bf2514bfd0b98f2d76a438c24ec9870c 100644 (file)
@@ -164,16 +164,19 @@ get_oidnamespace(Oid funcoid)
    return nspoid;
 }
 
   /* if path is relative, take it as relative to share dir */
+ /* if path is relative, take it as relative to share dir */
 char *
-to_absfilename(char *filename) {
-   if (!is_absolute_path(filename)) {
-       char        sharepath[MAXPGPATH];
-       char       *absfn;
-#ifdef  WIN32
-       char    delim = '\\';
+to_absfilename(char *filename)
+{
+   if (!is_absolute_path(filename))
+   {
+       char        sharepath[MAXPGPATH];
+       char       *absfn;
+
+#ifdef WIN32
+       char        delim = '\\';
 #else
-       char    delim = '/';
+       char        delim = '/';
 #endif
        get_share_path(my_exec_path, sharepath);
        absfn = palloc(strlen(sharepath) + strlen(filename) + 2);
index c33507e9ac74e89fb35abef8cea3a89f1400dd3c..ff6ebd6240f8b5ac826e5090ffed31c1a1dfce2e 100644 (file)
@@ -14,7 +14,7 @@ text     *mtextdup(text *in);
 
 int            text_cmp(text *a, text *b);
 
-char to_absfilename(char *filename);
+char      *to_absfilename(char *filename);
 
 #define NEXTVAL(x) ( (text*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
 #define ARRNELEMS(x)  ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
index 2c37a2696b3405d458123b1ccb33a8dd40dda506..182f5c3291044d48a0a482ef9ad1bfdd80f38505 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/contrib/tsearch2/dict.c,v 1.12 2006/05/31 14:05:31 teodor Exp $ */
+/* $PostgreSQL: pgsql/contrib/tsearch2/dict.c,v 1.13 2006/10/04 00:29:46 momjian Exp $ */
 
 /*
  * interface functions to dictionary
@@ -102,7 +102,8 @@ comparedict(const void *a, const void *b)
 }
 
 static void
-insertdict(Oid id) {
+insertdict(Oid id)
+{
    DictInfo    newdict;
 
    if (DList.len == DList.reallen)
@@ -143,7 +144,7 @@ finddict(Oid id)
            return DList.last_dict;
    }
 
-   /* insert new dictionary */ 
+   /* insert new dictionary */
    insertdict(id);
    return finddict(id); /* qsort changed order!! */ ;
 }
@@ -201,30 +202,31 @@ lexize(PG_FUNCTION_ARGS)
               *ptr;
    Datum      *da;
    ArrayType  *a;
-   DictSubState    dstate = { false, false, NULL };
+   DictSubState dstate = {false, false, NULL};
 
    SET_FUNCOID();
    dict = finddict(PG_GETARG_OID(0));
 
    ptr = res = (TSLexeme *) DatumGetPointer(
-                                       FunctionCall4(&(dict->lexize_info),
-                                       PointerGetDatum(dict->dictionary),
-                                       PointerGetDatum(VARDATA(in)),
-                                       Int32GetDatum(VARSIZE(in) - VARHDRSZ),
-                                       PointerGetDatum(&dstate)
+                                         FunctionCall4(&(dict->lexize_info),
+                                          PointerGetDatum(dict->dictionary),
+                                               PointerGetDatum(VARDATA(in)),
+                                      Int32GetDatum(VARSIZE(in) - VARHDRSZ),
+                                                    PointerGetDatum(&dstate)
                                                        )
        );
 
-   if (dstate.getnext)  {
-       dstate.isend = true;    
+   if (dstate.getnext)
+   {
+       dstate.isend = true;
        ptr = res = (TSLexeme *) DatumGetPointer(
-                                       FunctionCall4(&(dict->lexize_info),
+                                         FunctionCall4(&(dict->lexize_info),
                                           PointerGetDatum(dict->dictionary),
                                                PointerGetDatum(VARDATA(in)),
-                                       Int32GetDatum(VARSIZE(in) - VARHDRSZ),
-                                       PointerGetDatum(&dstate)
+                                      Int32GetDatum(VARSIZE(in) - VARHDRSZ),
+                                                    PointerGetDatum(&dstate)
                                                        )
-       );
+           );
    }
 
    PG_FREE_IF_COPY(in, 1);
index a0e9fe6facb52e9809c569f942cf707328fdb2df..78d5111f14f68ec046c85ff3151d5556b0a2ea0e 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/contrib/tsearch2/dict.h,v 1.7 2006/05/31 14:05:31 teodor Exp $ */
+/* $PostgreSQL: pgsql/contrib/tsearch2/dict.h,v 1.8 2006/10/04 00:29:46 momjian Exp $ */
 
 #ifndef __DICT_H__
 #define __DICT_H__
@@ -30,11 +30,14 @@ DictInfo   *finddict(Oid id);
 Oid            name2id_dict(text *name);
 void       reset_dict(void);
 
-typedef struct {
-   bool isend; /* in: marks for lexize_info about text end is reached */
-   bool getnext; /* out: dict wants next lexeme */
-   void    *private;  /* internal dict state between calls with getnext == true */
-} DictSubState;
+typedef struct
+{
+   bool        isend;          /* in: marks for lexize_info about text end is
+                                * reached */
+   bool        getnext;        /* out: dict wants next lexeme */
+   void       *private;        /* internal dict state between calls with
+                                * getnext == true */
+}  DictSubState;
 
 /* simple parser of cfg string */
 typedef struct
@@ -51,13 +54,8 @@ 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
+    * ball, klubb ). So, dictionary should return: nvariant lexeme 1
+    * fotball 1      klubb 2      fot 2      ball 2      klubb
     */
    uint16      nvariant;
 
@@ -74,38 +72,43 @@ typedef struct
  * Lexize subsystem
  */
 
-typedef struct ParsedLex {
-    int        type;
-    char       *lemm;
-    int        lenlemm;
+typedef struct ParsedLex
+{
+   int         type;
+   char       *lemm;
+   int         lenlemm;
    bool        resfollow;
-    struct ParsedLex *next;
-} ParsedLex;
-
-typedef struct ListParsedLex {
-   ParsedLex   *head;
-   ParsedLex   *tail;
-} ListParsedLex;
-
-typedef struct {
-    TSCfgInfo       *cfg;
-    Oid             curDictId;
-    int             posDict;
-    DictSubState    dictState;
-    ParsedLex       *curSub;
-   ListParsedLex   towork;   /* current list to work */
-   ListParsedLex   waste;    /* list of lexemes that already lexized */
-
-   /* fields to store last variant to lexize (basically, thesaurus 
-      or similar to, which wants  several lexemes */   
-      
-   ParsedLex       *lastRes;
-   TSLexeme        *tmpRes;
-} LexizeData;
-
-
-void LexizeInit(LexizeData *ld, TSCfgInfo *cfg);
-void LexizeAddLemm(LexizeData *ld, int type, char *lemm, int lenlemm);
-TSLexeme* LexizeExec(LexizeData *ld, ParsedLex **correspondLexem);
+   struct ParsedLex *next;
+}  ParsedLex;
+
+typedef struct ListParsedLex
+{
+   ParsedLex  *head;
+   ParsedLex  *tail;
+}  ListParsedLex;
+
+typedef struct
+{
+   TSCfgInfo  *cfg;
+   Oid         curDictId;
+   int         posDict;
+   DictSubState dictState;
+   ParsedLex  *curSub;
+   ListParsedLex towork;       /* current list to work */
+   ListParsedLex waste;        /* list of lexemes that already lexized */
+
+   /*
+    * fields to store last variant to lexize (basically, thesaurus or similar
+    * to, which wants  several lexemes
+    */
+
+   ParsedLex  *lastRes;
+   TSLexeme   *tmpRes;
+}  LexizeData;
+
+
+void       LexizeInit(LexizeData * ld, TSCfgInfo * cfg);
+void       LexizeAddLemm(LexizeData * ld, int type, char *lemm, int lenlemm);
+TSLexeme   *LexizeExec(LexizeData * ld, ParsedLex ** correspondLexem);
 
 #endif
index d5d837b2cce1226aeefb5f4cb1a877eab5526ca6..12ab7f222a05823b04cb4dbf723119805cede6d2 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/contrib/tsearch2/dict_thesaurus.c,v 1.5 2006/06/06 16:25:55 teodor Exp $ */
+/* $PostgreSQL: pgsql/contrib/tsearch2/dict_thesaurus.c,v 1.6 2006/10/04 00:29:46 momjian Exp $ */
 
 /*
  * thesaurus
 /*
  * Temporay we use TSLexeme.flags for inner use...
  */
-#define    DT_USEASIS      0x1000
+#define DT_USEASIS     0x1000
 
-typedef struct LexemeInfo {
-   uint16  idsubst; /* entry's number in DictThesaurus->subst */
-   uint16  posinsubst; /* pos info in entry */
-   uint16  tnvariant;  /* total num lexemes in one variant */
+typedef struct LexemeInfo
+{
+   uint16      idsubst;        /* entry's number in DictThesaurus->subst */
+   uint16      posinsubst;     /* pos info in entry */
+   uint16      tnvariant;      /* total num lexemes in one variant */
    struct LexemeInfo *nextentry;
    struct LexemeInfo *nextvariant;
-} LexemeInfo;
+}  LexemeInfo;
 
-typedef struct {
-   char        *lexeme;
-   LexemeInfo  *entries;
-} TheLexeme; 
+typedef struct
+{
+   char       *lexeme;
+   LexemeInfo *entries;
+}  TheLexeme;
 
-typedef struct {
-   uint16  lastlexeme; /* number lexemes to substitute */
-   uint16  reslen;
-   TSLexeme    *res;   /* prepared substituted result */ 
-} TheSubstitute;
+typedef struct
+{
+   uint16      lastlexeme;     /* number lexemes to substitute */
+   uint16      reslen;
+   TSLexeme   *res;            /* prepared substituted result */
+}  TheSubstitute;
 
 typedef struct
 {
-   /* subdictionary to normalize lexemes */    
+   /* subdictionary to normalize lexemes */
    DictInfo    subdict;
 
    /* Array to search lexeme by exact match */
-   TheLexeme   *wrds;
+   TheLexeme  *wrds;
    int         nwrds;
    int         ntwrds;
 
-   /* Storage of substituted result, n-th element is for
-      n-th expression */
-   TheSubstitute   *subst;
-   int             nsubst;
+   /*
+    * Storage of substituted result, n-th element is for n-th expression
+    */
+   TheSubstitute *subst;
+   int         nsubst;
 }  DictThesaurus;
 
 PG_FUNCTION_INFO_V1(thesaurus_init);
@@ -66,184 +70,225 @@ freeDictThesaurus(DictThesaurus * d)
 }
 
 static void
-newLexeme( DictThesaurus *d, char *b, char *e, uint16 idsubst, uint16 posinsubst ) {
-   TheLexeme   *ptr;
+newLexeme(DictThesaurus * d, char *b, char *e, uint16 idsubst, uint16 posinsubst)
+{
+   TheLexeme  *ptr;
 
-   if ( d->nwrds >= d->ntwrds ) {
-       if ( d->ntwrds == 0 ) {
+   if (d->nwrds >= d->ntwrds)
+   {
+       if (d->ntwrds == 0)
+       {
            d->ntwrds = 16;
-           d->wrds = (TheLexeme*)malloc(sizeof(TheLexeme) * d->ntwrds);
-       } else {
+           d->wrds = (TheLexeme *) malloc(sizeof(TheLexeme) * d->ntwrds);
+       }
+       else
+       {
            d->ntwrds *= 2;
-           d->wrds = (TheLexeme*)realloc(d->wrds, sizeof(TheLexeme) * d->ntwrds);
+           d->wrds = (TheLexeme *) realloc(d->wrds, sizeof(TheLexeme) * d->ntwrds);
        }
        if (!d->wrds)
-           elog(ERROR,"Out of memory");
+           elog(ERROR, "Out of memory");
    }
 
    ptr = d->wrds + d->nwrds;
    d->nwrds++;
 
-   if  ( (ptr->lexeme = malloc(e-b+1)) == NULL )
-       elog(ERROR,"Out of memory");
+   if ((ptr->lexeme = malloc(e - b + 1)) == NULL)
+       elog(ERROR, "Out of memory");
 
-   memcpy(ptr->lexeme, b, e-b);
-   ptr->lexeme[e-b] = '\0';
+   memcpy(ptr->lexeme, b, e - b);
+   ptr->lexeme[e - b] = '\0';
 
-   if  ( (ptr->entries = (LexemeInfo*)malloc( sizeof(LexemeInfo) ))==NULL )
-       elog(ERROR,"Out of memory");
+   if ((ptr->entries = (LexemeInfo *) malloc(sizeof(LexemeInfo))) == NULL)
+       elog(ERROR, "Out of memory");
 
-   ptr->entries->nextentry=NULL;
+   ptr->entries->nextentry = NULL;
    ptr->entries->idsubst = idsubst;
    ptr->entries->posinsubst = posinsubst;
 }
 
 static void
-addWrd( DictThesaurus *d, char *b, char *e, uint16 idsubst, uint16 nwrd, uint16 posinsubst, bool useasis ) {
-   static  int nres=0;
-   static  int ntres = 0;
-   TheSubstitute   *ptr;
+addWrd(DictThesaurus * d, char *b, char *e, uint16 idsubst, uint16 nwrd, uint16 posinsubst, bool useasis)
+{
+   static int  nres = 0;
+   static int  ntres = 0;
+   TheSubstitute *ptr;
 
-   if ( nwrd == 0 ) {
+   if (nwrd == 0)
+   {
        nres = ntres = 0;
 
-       if ( idsubst <= d->nsubst ) {
-           if ( d->nsubst == 0 ) {
+       if (idsubst <= d->nsubst)
+       {
+           if (d->nsubst == 0)
+           {
                d->nsubst = 16;
-               d->subst = (TheSubstitute*)malloc(sizeof(TheSubstitute) * d->nsubst);
-           } else {
+               d->subst = (TheSubstitute *) malloc(sizeof(TheSubstitute) * d->nsubst);
+           }
+           else
+           {
                d->nsubst *= 2;
-               d->subst = (TheSubstitute*)realloc(d->subst, sizeof(TheSubstitute) * d->nsubst);
+               d->subst = (TheSubstitute *) realloc(d->subst, sizeof(TheSubstitute) * d->nsubst);
            }
            if (!d->subst)
-               elog(ERROR,"Out of memory");
+               elog(ERROR, "Out of memory");
        }
    }
 
    ptr = d->subst + idsubst;
 
-   ptr->lastlexeme = posinsubst-1;
+   ptr->lastlexeme = posinsubst - 1;
 
-   if ( nres+1 >= ntres ) {
-       if ( ntres == 0 ) {
+   if (nres + 1 >= ntres)
+   {
+       if (ntres == 0)
+       {
            ntres = 2;
-           ptr->res = (TSLexeme*)malloc( sizeof(TSLexeme) * ntres );
-       } else {
+           ptr->res = (TSLexeme *) malloc(sizeof(TSLexeme) * ntres);
+       }
+       else
+       {
            ntres *= 2;
-           ptr->res = (TSLexeme*)realloc( ptr->res, sizeof(TSLexeme) * ntres );
+           ptr->res = (TSLexeme *) realloc(ptr->res, sizeof(TSLexeme) * ntres);
        }
 
-       if ( !ptr->res ) 
-               elog(ERROR,"Out of memory");
+       if (!ptr->res)
+           elog(ERROR, "Out of memory");
    }
 
-   if ( (ptr->res[ nres ].lexeme = malloc(e-b+1))==0 ) 
-       elog(ERROR,"Out of memory");
-   memcpy(ptr->res[ nres ].lexeme, b, e-b);
-   ptr->res[ nres ].lexeme[e-b] = '\0';
+   if ((ptr->res[nres].lexeme = malloc(e - b + 1)) == 0)
+       elog(ERROR, "Out of memory");
+   memcpy(ptr->res[nres].lexeme, b, e - b);
+   ptr->res[nres].lexeme[e - b] = '\0';
 
-   ptr->res[ nres ].nvariant = nwrd;
-   if ( useasis )
-       ptr->res[ nres ].flags = DT_USEASIS;
+   ptr->res[nres].nvariant = nwrd;
+   if (useasis)
+       ptr->res[nres].flags = DT_USEASIS;
    else
-       ptr->res[ nres ].flags = 0;
+       ptr->res[nres].flags = 0;
 
-   ptr->res[ ++nres ].lexeme = NULL;
+   ptr->res[++nres].lexeme = NULL;
 }
 
 #define TR_WAITLEX 1
 #define TR_INLEX   2
-#define    TR_WAITSUBS 3
+#define TR_WAITSUBS 3
 #define TR_INSUBS  4
 
 static void
-thesaurusRead( char *filename, DictThesaurus *d ) {
-   FILE *fh;
-   char str[BUFSIZ];
-   int lineno=0;
-   uint16  idsubst = 0;
-   bool    useasis=false;
+thesaurusRead(char *filename, DictThesaurus * d)
+{
+   FILE       *fh;
+   char        str[BUFSIZ];
+   int         lineno = 0;
+   uint16      idsubst = 0;
+   bool        useasis = false;
 
    fh = fopen(to_absfilename(filename), "r");
    if (!fh)
-       elog(ERROR,"Thesaurus: can't open '%s' file", filename);
+       elog(ERROR, "Thesaurus: can't open '%s' file", filename);
 
-   while( fgets(str, sizeof(str), fh)) {
-       char *ptr = str;
-       int state = TR_WAITLEX;
-       char    *beginwrd = NULL;
-       uint16  posinsubst=0;
-       uint16  nwrd=0;
+   while (fgets(str, sizeof(str), fh))
+   {
+       char       *ptr = str;
+       int         state = TR_WAITLEX;
+       char       *beginwrd = NULL;
+       uint16      posinsubst = 0;
+       uint16      nwrd = 0;
 
        lineno++;
 
        /* is it comment ? */
-       while( t_isspace(ptr) )
+       while (t_isspace(ptr))
            ptr += pg_mblen(ptr);
-       if ( t_iseq(str, '#') || *str=='\0' || t_iseq(str, '\n') || t_iseq(str, '\r') )
+       if (t_iseq(str, '#') || *str == '\0' || t_iseq(str, '\n') || t_iseq(str, '\r'))
            continue;
 
        pg_verifymbstr(ptr, strlen(ptr), false);
-       while(*ptr) {
-           if ( state == TR_WAITLEX ) {
-               if ( t_iseq(ptr, ':' ) ) {
-                   if ( posinsubst == 0 ) {
+       while (*ptr)
+       {
+           if (state == TR_WAITLEX)
+           {
+               if (t_iseq(ptr, ':'))
+               {
+                   if (posinsubst == 0)
+                   {
                        fclose(fh);
                        elog(ERROR, "Thesaurus: Unexpected delimiter at %d line", lineno);
                    }
                    state = TR_WAITSUBS;
-               } else if ( !t_isspace(ptr) ) {
+               }
+               else if (!t_isspace(ptr))
+               {
                    beginwrd = ptr;
                    state = TR_INLEX;
                }
-           } else if ( state == TR_INLEX ) {
-               if ( t_iseq(ptr, ':') ) {
-                   newLexeme( d, beginwrd, ptr, idsubst, posinsubst++ );
+           }
+           else if (state == TR_INLEX)
+           {
+               if (t_iseq(ptr, ':'))
+               {
+                   newLexeme(d, beginwrd, ptr, idsubst, posinsubst++);
                    state = TR_WAITSUBS;
-               } else if ( t_isspace(ptr) ) {
-                   newLexeme( d, beginwrd, ptr, idsubst, posinsubst++ );
+               }
+               else if (t_isspace(ptr))
+               {
+                   newLexeme(d, beginwrd, ptr, idsubst, posinsubst++);
                    state = TR_WAITLEX;
                }
-           } else if ( state == TR_WAITSUBS ) {
-               if ( t_iseq(ptr, '*') ) {
+           }
+           else if (state == TR_WAITSUBS)
+           {
+               if (t_iseq(ptr, '*'))
+               {
                    useasis = true;
                    state = TR_INSUBS;
                    beginwrd = ptr + pg_mblen(ptr);
-               } else if ( t_iseq(ptr, '\\') ) {
+               }
+               else if (t_iseq(ptr, '\\'))
+               {
                    useasis = false;
                    state = TR_INSUBS;
                    beginwrd = ptr + pg_mblen(ptr);
-               } else if ( !t_isspace(ptr) ) { 
+               }
+               else if (!t_isspace(ptr))
+               {
                    useasis = false;
                    beginwrd = ptr;
                    state = TR_INSUBS;
                }
-           } else if ( state == TR_INSUBS ) {
-               if ( t_isspace(ptr) ) { 
-                   if ( ptr == beginwrd )
+           }
+           else if (state == TR_INSUBS)
+           {
+               if (t_isspace(ptr))
+               {
+                   if (ptr == beginwrd)
                        elog(ERROR, "Thesaurus: Unexpected end of line or lexeme at %d line", lineno);
-                   addWrd( d, beginwrd, ptr, idsubst, nwrd++, posinsubst, useasis );
+                   addWrd(d, beginwrd, ptr, idsubst, nwrd++, posinsubst, useasis);
                    state = TR_WAITSUBS;
                }
-           } else
-               elog(ERROR,"Thesaurus: Unknown state: %d", state);
-               
+           }
+           else
+               elog(ERROR, "Thesaurus: Unknown state: %d", state);
+
            ptr += pg_mblen(ptr);
        }
 
-       if ( state == TR_INSUBS ) {
-           if ( ptr == beginwrd )
+       if (state == TR_INSUBS)
+       {
+           if (ptr == beginwrd)
                elog(ERROR, "Thesaurus: Unexpected end of line or lexeme at %d line", lineno);
-           addWrd( d, beginwrd, ptr, idsubst, nwrd++, posinsubst, useasis );
+           addWrd(d, beginwrd, ptr, idsubst, nwrd++, posinsubst, useasis);
        }
 
        idsubst++;
 
-       if ( !(nwrd && posinsubst) ) {
+       if (!(nwrd && posinsubst))
+       {
            fclose(fh);
            elog(ERROR, "Thesaurus: Unexpected end of line at %d line", lineno);
        }
-           
+
    }
 
    d->nsubst = idsubst;
@@ -251,135 +296,160 @@ thesaurusRead( char *filename, DictThesaurus *d ) {
    fclose(fh);
 }
 
-static TheLexeme*
-addCompiledLexeme(TheLexeme   *newwrds, int *nnw, int *tnm, TSLexeme *lexeme, LexemeInfo* src, uint16 tnvariant) {
+static TheLexeme *
+addCompiledLexeme(TheLexeme * newwrds, int *nnw, int *tnm, TSLexeme * lexeme, LexemeInfo * src, uint16 tnvariant)
+{
 
-   if ( *nnw >= *tnm ) {
+   if (*nnw >= *tnm)
+   {
        *tnm *= 2;
-       newwrds = (TheLexeme*)realloc( newwrds, sizeof(TheLexeme) * *tnm);
+       newwrds = (TheLexeme *) realloc(newwrds, sizeof(TheLexeme) * *tnm);
        if (!newwrds)
-           elog(ERROR,"Out of memory");
+           elog(ERROR, "Out of memory");
    }
 
-   newwrds[ *nnw ].entries = (LexemeInfo*)malloc( sizeof(LexemeInfo) );
-   if (!newwrds[ *nnw ].entries)
-       elog(ERROR,"Out of memory");
+   newwrds[*nnw].entries = (LexemeInfo *) malloc(sizeof(LexemeInfo));
+   if (!newwrds[*nnw].entries)
+       elog(ERROR, "Out of memory");
 
-   if ( lexeme && lexeme->lexeme ) {
-       newwrds[ *nnw ].lexeme = strdup( lexeme->lexeme );
-       if ( !newwrds[ *nnw ].lexeme )
-           elog(ERROR,"Out of memory");
+   if (lexeme && lexeme->lexeme)
+   {
+       newwrds[*nnw].lexeme = strdup(lexeme->lexeme);
+       if (!newwrds[*nnw].lexeme)
+           elog(ERROR, "Out of memory");
 
-       newwrds[ *nnw ].entries->tnvariant = tnvariant;
-   } else {
-       newwrds[ *nnw ].lexeme = NULL;
-       newwrds[ *nnw ].entries->tnvariant = 1;
+       newwrds[*nnw].entries->tnvariant = tnvariant;
+   }
+   else
+   {
+       newwrds[*nnw].lexeme = NULL;
+       newwrds[*nnw].entries->tnvariant = 1;
    }
 
-   newwrds[ *nnw ].entries->idsubst = src->idsubst;
-   newwrds[ *nnw ].entries->posinsubst = src->posinsubst;
+   newwrds[*nnw].entries->idsubst = src->idsubst;
+   newwrds[*nnw].entries->posinsubst = src->posinsubst;
 
-   newwrds[ *nnw ].entries->nextentry = NULL;
+   newwrds[*nnw].entries->nextentry = NULL;
 
    (*nnw)++;
    return newwrds;
 }
 
 static int
-cmpLexemeInfo(LexemeInfo *a, LexemeInfo *b) {
-   if ( a==NULL || b==NULL )
+cmpLexemeInfo(LexemeInfo * a, LexemeInfo * b)
+{
+   if (a == NULL || b == NULL)
        return 0;
 
-   if ( a->idsubst == b->idsubst ) {
-       if ( a->posinsubst == b->posinsubst ) {
-           if ( a->tnvariant == b->tnvariant ) 
-                   return 0;
+   if (a->idsubst == b->idsubst)
+   {
+       if (a->posinsubst == b->posinsubst)
+       {
+           if (a->tnvariant == b->tnvariant)
+               return 0;
 
-           return ( a->tnvariant > b->tnvariant ) ? 1 : -1;
+           return (a->tnvariant > b->tnvariant) ? 1 : -1;
        }
 
-       return ( a->posinsubst > b->posinsubst ) ? 1 : -1;
+       return (a->posinsubst > b->posinsubst) ? 1 : -1;
    }
 
-   return ( a->idsubst > b->idsubst ) ? 1 : -1;
+   return (a->idsubst > b->idsubst) ? 1 : -1;
 }
 
 static int
-cmpLexeme(TheLexeme *a, TheLexeme* b) {
-   if ( a->lexeme == NULL ) {
-       if ( b->lexeme == NULL )
+cmpLexeme(TheLexeme * a, TheLexeme * b)
+{
+   if (a->lexeme == NULL)
+   {
+       if (b->lexeme == NULL)
            return 0;
        else
            return 1;
-   } else if ( b->lexeme == NULL )
+   }
+   else if (b->lexeme == NULL)
        return -1;
 
-   return strcmp( a->lexeme, b->lexeme );
+   return strcmp(a->lexeme, b->lexeme);
 }
 
 static int
-cmpLexemeQ(const void *a, const void *b) {
-   return cmpLexeme( (TheLexeme*)a, (TheLexeme*)b ); 
+cmpLexemeQ(const void *a, const void *b)
+{
+   return cmpLexeme((TheLexeme *) a, (TheLexeme *) b);
 }
 
-static int cmpTheLexeme(const void *a, const void *b) {
-   TheLexeme *la  = (TheLexeme*)a;
-   TheLexeme *lb  = (TheLexeme*)b;
-   int res;
+static int
+cmpTheLexeme(const void *a, const void *b)
+{
+   TheLexeme  *la = (TheLexeme *) a;
+   TheLexeme  *lb = (TheLexeme *) b;
+   int         res;
 
-   if ( (res=cmpLexeme(la, lb)) != 0 )
+   if ((res = cmpLexeme(la, lb)) != 0)
        return res;
 
    return -cmpLexemeInfo(la->entries, lb->entries);
 }
 
 static void
-compileTheLexeme(DictThesaurus *d) {
-   int         i,nnw=0, tnm=16;
-   TheLexeme   *newwrds = (TheLexeme*)malloc(sizeof(TheLexeme)*tnm), *ptrwrds;
-
-   if (!newwrds) 
-       elog(ERROR,"Out of memory");
-
-   for(i=0;inwrds;i++) {
-       TSLexeme *ptr;
-
-       ptr = (TSLexeme*) DatumGetPointer( 
-               FunctionCall4(
-                   &(d->subdict.lexize_info),
-                   PointerGetDatum(d->subdict.dictionary),
-                   PointerGetDatum(d->wrds[i].lexeme),
-                   Int32GetDatum(strlen(d->wrds[i].lexeme)),
-                   PointerGetDatum(NULL)
-               )
+compileTheLexeme(DictThesaurus * d)
+{
+   int         i,
+               nnw = 0,
+               tnm = 16;
+   TheLexeme  *newwrds = (TheLexeme *) malloc(sizeof(TheLexeme) * tnm),
+              *ptrwrds;
+
+   if (!newwrds)
+       elog(ERROR, "Out of memory");
+
+   for (i = 0; i < d->nwrds; i++)
+   {
+       TSLexeme   *ptr;
+
+       ptr = (TSLexeme *) DatumGetPointer(
+                                          FunctionCall4(
+                                                  &(d->subdict.lexize_info),
+                                     PointerGetDatum(d->subdict.dictionary),
+                                         PointerGetDatum(d->wrds[i].lexeme),
+                                   Int32GetDatum(strlen(d->wrds[i].lexeme)),
+                                                        PointerGetDatum(NULL)
+                                                        )
            );
 
-       if ( !(ptr && ptr->lexeme) ) {
-           if ( !ptr )
-               elog(ERROR,"Thesaurus: word-sample '%s' isn't recognized by subdictionary (rule %d)", 
-                       d->wrds[i].lexeme, d->wrds[i].entries->idsubst+1    );
+       if (!(ptr && ptr->lexeme))
+       {
+           if (!ptr)
+               elog(ERROR, "Thesaurus: word-sample '%s' isn't recognized by subdictionary (rule %d)",
+                    d->wrds[i].lexeme, d->wrds[i].entries->idsubst + 1);
            else
-               elog(NOTICE,"Thesaurus: word-sample '%s' is recognized as stop-word, assign any stop-word (rule %d)", 
-                   d->wrds[i].lexeme,  d->wrds[i].entries->idsubst+1);
+               elog(NOTICE, "Thesaurus: word-sample '%s' is recognized as stop-word, assign any stop-word (rule %d)",
+                    d->wrds[i].lexeme, d->wrds[i].entries->idsubst + 1);
 
-           newwrds = addCompiledLexeme( newwrds, &nnw, &tnm, NULL, d->wrds[i].entries, 0);
-       } else {
-           while( ptr->lexeme ) {
-               TSLexeme    *remptr = ptr+1;
-               int tnvar = 1;
-               int curvar = ptr->nvariant;
+           newwrds = addCompiledLexeme(newwrds, &nnw, &tnm, NULL, d->wrds[i].entries, 0);
+       }
+       else
+       {
+           while (ptr->lexeme)
+           {
+               TSLexeme   *remptr = ptr + 1;
+               int         tnvar = 1;
+               int         curvar = ptr->nvariant;
 
                /* compute n words in one variant */
-               while( remptr->lexeme ) {
-                   if ( remptr->nvariant != (remptr-1)->nvariant )
+               while (remptr->lexeme)
+               {
+                   if (remptr->nvariant != (remptr - 1)->nvariant)
                        break;
                    tnvar++;
                    remptr++;
                }
 
                remptr = ptr;
-               while( remptr->lexeme && remptr->nvariant == curvar ) {
-                   newwrds = addCompiledLexeme( newwrds, &nnw, &tnm, remptr, d->wrds[i].entries, tnvar); 
+               while (remptr->lexeme && remptr->nvariant == curvar)
+               {
+                   newwrds = addCompiledLexeme(newwrds, &nnw, &tnm, remptr, d->wrds[i].entries, tnvar);
                    remptr++;
                }
 
@@ -387,32 +457,39 @@ compileTheLexeme(DictThesaurus *d) {
            }
        }
 
-       free( d->wrds[i].lexeme );
-       free( d->wrds[i].entries );
+       free(d->wrds[i].lexeme);
+       free(d->wrds[i].entries);
    }
 
-   free( d->wrds );
+   free(d->wrds);
    d->wrds = newwrds;
    d->nwrds = nnw;
    d->ntwrds = tnm;
 
-   if ( d->nwrds > 1 ) {
-       qsort( d->wrds, d->nwrds, sizeof(TheLexeme), cmpTheLexeme ); 
+   if (d->nwrds > 1)
+   {
+       qsort(d->wrds, d->nwrds, sizeof(TheLexeme), cmpTheLexeme);
 
        /* uniq */
        newwrds = d->wrds;
        ptrwrds = d->wrds + 1;
-       while( ptrwrds - d->wrds < d->nwrds ) {
-           if ( cmpLexeme( ptrwrds, newwrds ) == 0 ) {
-               if ( cmpLexemeInfo(ptrwrds->entries, newwrds->entries) ) {
+       while (ptrwrds - d->wrds < d->nwrds)
+       {
+           if (cmpLexeme(ptrwrds, newwrds) == 0)
+           {
+               if (cmpLexemeInfo(ptrwrds->entries, newwrds->entries))
+               {
                    ptrwrds->entries->nextentry = newwrds->entries;
                    newwrds->entries = ptrwrds->entries;
-               } else
-                   free( ptrwrds->entries );
+               }
+               else
+                   free(ptrwrds->entries);
 
-               if ( ptrwrds->lexeme )
-                   free( ptrwrds->lexeme );
-           } else {
+               if (ptrwrds->lexeme)
+                   free(ptrwrds->lexeme);
+           }
+           else
+           {
                newwrds++;
                *newwrds = *ptrwrds;
            }
@@ -421,80 +498,97 @@ compileTheLexeme(DictThesaurus *d) {
        }
 
        d->nwrds = newwrds - d->wrds + 1;
-       d->wrds = (TheLexeme*)realloc( d->wrds, sizeof(TheLexeme) * d->nwrds );
+       d->wrds = (TheLexeme *) realloc(d->wrds, sizeof(TheLexeme) * d->nwrds);
    }
 }
 
 static void
-compileTheSubstitute(DictThesaurus *d) {
-   int i;
-
-   for(i=0;insubst;i++) {
-       TSLexeme    *rem = d->subst[i].res, *outptr, *inptr;
-       int         n=2;
+compileTheSubstitute(DictThesaurus * d)
+{
+   int         i;
 
-       outptr = d->subst[i].res = (TSLexeme*)malloc( sizeof(TSLexeme) * n );
-       if ( d->subst[i].res == NULL )
-           elog(ERROR,"Out of Memory");
+   for (i = 0; i < d->nsubst; i++)
+   {
+       TSLexeme   *rem = d->subst[i].res,
+                  *outptr,
+                  *inptr;
+       int         n = 2;
+
+       outptr = d->subst[i].res = (TSLexeme *) malloc(sizeof(TSLexeme) * n);
+       if (d->subst[i].res == NULL)
+           elog(ERROR, "Out of Memory");
        outptr->lexeme = NULL;
        inptr = rem;
 
-       while( inptr && inptr->lexeme ) { 
-           TSLexeme    *lexized, tmplex[2];
+       while (inptr && inptr->lexeme)
+       {
+           TSLexeme   *lexized,
+                       tmplex[2];
 
-           if ( inptr->flags & DT_USEASIS ) { /* do not lexize */
+           if (inptr->flags & DT_USEASIS)
+           {                   /* do not lexize */
                tmplex[0] = *inptr;
-               tmplex[0].flags = 0; 
+               tmplex[0].flags = 0;
                tmplex[1].lexeme = NULL;
-               lexized = tmplex; 
-           } else {
-               lexized = (TSLexeme*) DatumGetPointer( 
-                   FunctionCall4(
-                       &(d->subdict.lexize_info),
-                       PointerGetDatum(d->subdict.dictionary),
-                       PointerGetDatum(inptr->lexeme),
-                       Int32GetDatum(strlen(inptr->lexeme)),
-                       PointerGetDatum(NULL)
-                   )
-               );
+               lexized = tmplex;
+           }
+           else
+           {
+               lexized = (TSLexeme *) DatumGetPointer(
+                                                      FunctionCall4(
+                                                  &(d->subdict.lexize_info),
+                                     PointerGetDatum(d->subdict.dictionary),
+                                             PointerGetDatum(inptr->lexeme),
+                                       Int32GetDatum(strlen(inptr->lexeme)),
+                                                       PointerGetDatum(NULL)
+                                                                    )
+                   );
            }
 
-           if ( lexized && lexized->lexeme ) {
-               int toset = (lexized->lexeme && outptr != d->subst[i].res ) ? (outptr - d->subst[i].res)  : -1;
+           if (lexized && lexized->lexeme)
+           {
+               int         toset = (lexized->lexeme && outptr != d->subst[i].res) ? (outptr - d->subst[i].res) : -1;
+
+               while (lexized->lexeme)
+               {
+                   if (outptr - d->subst[i].res + 1 >= n)
+                   {
+                       int         diff = outptr - d->subst[i].res;
 
-               while( lexized->lexeme ) {
-                   if ( outptr - d->subst[i].res + 1 >= n ) {
-                       int diff = outptr - d->subst[i].res;
                        n *= 2;
-                       d->subst[i].res = (TSLexeme*)realloc( d->subst[i].res, sizeof(TSLexeme) * n );
-                       if ( d->subst[i].res == NULL )
-                           elog(ERROR,"Out of Memory");
+                       d->subst[i].res = (TSLexeme *) realloc(d->subst[i].res, sizeof(TSLexeme) * n);
+                       if (d->subst[i].res == NULL)
+                           elog(ERROR, "Out of Memory");
                        outptr = d->subst[i].res + diff;
                    }
 
                    *outptr = *lexized;
-                   if ( (outptr->lexeme = strdup(lexized->lexeme)) == NULL )
-                       elog(ERROR,"Out of Memory");
+                   if ((outptr->lexeme = strdup(lexized->lexeme)) == NULL)
+                       elog(ERROR, "Out of Memory");
 
                    outptr++;
                    lexized++;
                }
 
-               if ( toset > 0)
+               if (toset > 0)
                    d->subst[i].res[toset].flags |= TSL_ADDPOS;
-           } else if ( lexized ) {
-               elog(NOTICE,"Thesaurus: word '%s' in substition is a stop-word, ignored (rule %d)", inptr->lexeme, i+1);
-           } else {
-               elog(ERROR,"Thesaurus: word '%s' in substition isn't recognized (rule %d)", inptr->lexeme, i+1);
+           }
+           else if (lexized)
+           {
+               elog(NOTICE, "Thesaurus: word '%s' in substition is a stop-word, ignored (rule %d)", inptr->lexeme, i + 1);
+           }
+           else
+           {
+               elog(ERROR, "Thesaurus: word '%s' in substition isn't recognized (rule %d)", inptr->lexeme, i + 1);
            }
 
-           if ( inptr->lexeme )
-               free( inptr->lexeme );
+           if (inptr->lexeme)
+               free(inptr->lexeme);
            inptr++;
        }
 
-       if ( outptr == d->subst[i].res )
-           elog(ERROR,"Thesaurus: all words in subsitution are stop word (rule %d)", i+1);
+       if (outptr == d->subst[i].res)
+           elog(ERROR, "Thesaurus: all words in subsitution are stop word (rule %d)", i + 1);
 
        d->subst[i].reslen = outptr - d->subst[i].res;
 
@@ -508,8 +602,9 @@ thesaurus_init(PG_FUNCTION_ARGS)
    DictThesaurus *d;
    Map        *cfg,
               *pcfg;
-   text       *in, *subdictname=NULL;
-   bool        fileloaded = false;
+   text       *in,
+              *subdictname = NULL;
+   bool        fileloaded = false;
 
    if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
        ereport(ERROR,
@@ -539,7 +634,7 @@ thesaurus_init(PG_FUNCTION_ARGS)
                         errmsg("Thesaurus file is already loaded")));
            }
            fileloaded = true;
-           thesaurusRead( pcfg->value, d );
+           thesaurusRead(pcfg->value, d);
        }
        else if (pg_strcasecmp("Dictionary", pcfg->key) == 0)
        {
@@ -548,9 +643,9 @@ thesaurus_init(PG_FUNCTION_ARGS)
                freeDictThesaurus(d);
                ereport(ERROR,
                        (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-                        errmsg("Thesaurus: SubDictionary is already defined")));
+                    errmsg("Thesaurus: SubDictionary is already defined")));
            }
-           subdictname = char2text( pcfg->value );
+           subdictname = char2text(pcfg->value);
        }
        else
        {
@@ -571,53 +666,60 @@ thesaurus_init(PG_FUNCTION_ARGS)
                (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
                 errmsg("Thesaurus file  isn't defined")));
 
-   if ( subdictname ) {
-       DictInfo    *subdictptr;
-       /* 
-        * we already in SPI, but name2id_dict()/finddict()
-        * invoke SPI_connect()
+   if (subdictname)
+   {
+       DictInfo   *subdictptr;
+
+       /*
+        * we already in SPI, but name2id_dict()/finddict() invoke
+        * SPI_connect()
         */
-       SPI_push(); 
+       SPI_push();
 
-       subdictptr = finddict( name2id_dict( subdictname ) );
+       subdictptr = finddict(name2id_dict(subdictname));
 
        SPI_pop();
 
        d->subdict = *subdictptr;
-   } else 
+   }
+   else
        ereport(ERROR,
                (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
                 errmsg("Thesaurus: SubDictionary isn't defined")));
 
-   compileTheLexeme( d );
+   compileTheLexeme(d);
    compileTheSubstitute(d);
 
    PG_RETURN_POINTER(d);
 }
 
-static LexemeInfo*
-findTheLexeme(DictThesaurus *d, char * lexeme) {
-   TheLexeme key = { lexeme, NULL }, *res;
+static LexemeInfo *
+findTheLexeme(DictThesaurus * d, char *lexeme)
+{
+   TheLexeme   key = {lexeme, NULL}, *res;
 
-   if ( d->nwrds == 0 )
+   if (d->nwrds == 0)
        return NULL;
 
    res = bsearch(&key, d->wrds, d->nwrds, sizeof(TheLexeme), cmpLexemeQ);
 
-   if ( res == NULL )
+   if (res == NULL)
        return NULL;
    return res->entries;
 }
 
 static bool
-matchIdSubst(LexemeInfo *stored, uint16 idsubst) {
-   bool res = true;
+matchIdSubst(LexemeInfo * stored, uint16 idsubst)
+{
+   bool        res = true;
 
-   if (stored) {
+   if (stored)
+   {
        res = false;
 
-       for(; stored; stored=stored->nextvariant) 
-           if ( stored->idsubst == idsubst ) {
+       for (; stored; stored = stored->nextvariant)
+           if (stored->idsubst == idsubst)
+           {
                res = true;
                break;
            }
@@ -626,66 +728,76 @@ matchIdSubst(LexemeInfo *stored, uint16 idsubst) {
    return res;
 }
 
-static LexemeInfo*
-findVariant( LexemeInfo *in, LexemeInfo *stored, uint16 curpos, LexemeInfo **newin, int newn) {
-   for(;;) {
-       int i;
+static LexemeInfo *
+findVariant(LexemeInfo * in, LexemeInfo * stored, uint16 curpos, LexemeInfo ** newin, int newn)
+{
+   for (;;)
+   {
+       int         i;
        LexemeInfo *ptr = newin[0];
 
-       for(i=0; i
-           while(newin[i] && newin[i]->idsubst < ptr->idsubst) 
+       for (i = 0; i < newn; i++)
+       {
+           while (newin[i] && newin[i]->idsubst < ptr->idsubst)
                newin[i] = newin[i]->nextentry;
 
-           if ( newin[i] == NULL )
+           if (newin[i] == NULL)
                return in;
 
-           if ( newin[i]->idsubst > ptr->idsubst ) {
+           if (newin[i]->idsubst > ptr->idsubst)
+           {
                ptr = newin[i];
-               i=-1;
+               i = -1;
                continue;
            }
 
-           while(newin[i]->idsubst == ptr->idsubst) {
-               if ( newin[i]->posinsubst == curpos && newin[i]->tnvariant == newn ) {
+           while (newin[i]->idsubst == ptr->idsubst)
+           {
+               if (newin[i]->posinsubst == curpos && newin[i]->tnvariant == newn)
+               {
                    ptr = newin[i];
                    break;
                }
 
                newin[i] = newin[i]->nextentry;
-               if ( newin[i] == NULL )
+               if (newin[i] == NULL)
                    return in;
            }
 
-           if ( newin[i]->idsubst != ptr->idsubst ) {
+           if (newin[i]->idsubst != ptr->idsubst)
+           {
                ptr = newin[i];
-               i=-1;
+               i = -1;
                continue;
            }
        }
 
-       if ( i==newn && matchIdSubst(stored, ptr->idsubst) && (in==NULL || !matchIdSubst(in, ptr->idsubst)) ) { /* found */
+       if (i == newn && matchIdSubst(stored, ptr->idsubst) && (in == NULL || !matchIdSubst(in, ptr->idsubst)))
+       {                       /* found */
 
            ptr->nextvariant = in;
            in = ptr;
        }
 
        /* step forward */
-       for(i=0; i<newn; i++)
+       for (i = 0; i < newn; i++)
            newin[i] = newin[i]->nextentry;
    }
 
    return NULL;
 }
 
-static TSLexeme*
-copyTSLexeme( TheSubstitute *ts ) {
-   TSLexeme    *res;
-   uint16 i;
+static TSLexeme *
+copyTSLexeme(TheSubstitute * ts)
+{
+   TSLexeme   *res;
+   uint16      i;
 
-   res = (TSLexeme*)palloc( sizeof(TSLexeme) * (ts->reslen+1) );
-   for(i=0;ireslen;i++) { 
+   res = (TSLexeme *) palloc(sizeof(TSLexeme) * (ts->reslen + 1));
+   for (i = 0; i < ts->reslen; i++)
+   {
        res[i] = ts->res[i];
-       res[i].lexeme = pstrdup( ts->res[i].lexeme );
+       res[i].lexeme = pstrdup(ts->res[i].lexeme);
    }
 
    res[ts->reslen].lexeme = NULL;
@@ -693,15 +805,17 @@ copyTSLexeme( TheSubstitute *ts ) {
    return res;
 }
 
-static TSLexeme*
-checkMatch(DictThesaurus *d, LexemeInfo *info, uint16 curpos, bool *moreres) {
+static TSLexeme *
+checkMatch(DictThesaurus * d, LexemeInfo * info, uint16 curpos, bool *moreres)
+{
    *moreres = false;
-   while(info) {
-       Assert( info->idsubst < d->nsubst );
-       if ( info->nextvariant )
+   while (info)
+   {
+       Assert(info->idsubst < d->nsubst);
+       if (info->nextvariant)
            *moreres = true;
-       if ( d->subst[ info->idsubst ].lastlexeme == curpos ) 
-           return copyTSLexeme( d->subst + info->idsubst );
+       if (d->subst[info->idsubst].lastlexeme == curpos)
+           return copyTSLexeme(d->subst + info->idsubst);
        info = info->nextvariant;
    }
 
@@ -712,79 +826,93 @@ Datum
 thesaurus_lexize(PG_FUNCTION_ARGS)
 {
    DictThesaurus *d = (DictThesaurus *) PG_GETARG_POINTER(0);
-   DictSubState    *dstate = (DictSubState*)PG_GETARG_POINTER(3);
-   TSLexeme    *res=NULL;
-   LexemeInfo *stored, *info = NULL;
-   uint16  curpos = 0;
-   bool    moreres = false;
+   DictSubState *dstate = (DictSubState *) PG_GETARG_POINTER(3);
+   TSLexeme   *res = NULL;
+   LexemeInfo *stored,
+              *info = NULL;
+   uint16      curpos = 0;
+   bool        moreres = false;
 
-   if ( dstate == NULL || PG_NARGS() < 4 )
-       elog(ERROR,"Forbidden call of thesaurus or nested call");
+   if (dstate == NULL || PG_NARGS() < 4)
+       elog(ERROR, "Forbidden call of thesaurus or nested call");
 
-   if ( dstate->isend ) 
+   if (dstate->isend)
        PG_RETURN_POINTER(NULL);
-   stored = (LexemeInfo*) dstate->private;
-
-   if (stored) 
-       curpos = stored->posinsubst+1;
-
-   res =(TSLexeme*) DatumGetPointer (
-       FunctionCall4(
-           &(d->subdict.lexize_info),
-           PointerGetDatum(d->subdict.dictionary),
-           PG_GETARG_DATUM(1),
-           PG_GETARG_INT32(2),
-           PointerGetDatum(NULL)
-       )
-   );
-
-   if ( res && res->lexeme ) {
-       TSLexeme    *ptr = res , *basevar;
+   stored = (LexemeInfo *) dstate->private;
+
+   if (stored)
+       curpos = stored->posinsubst + 1;
+
+   res = (TSLexeme *) DatumGetPointer(
+                                      FunctionCall4(
+                                                  &(d->subdict.lexize_info),
+                                     PointerGetDatum(d->subdict.dictionary),
+                                                    PG_GETARG_DATUM(1),
+                                                    PG_GETARG_INT32(2),
+                                                    PointerGetDatum(NULL)
+                                                    )
+       );
+
+   if (res && res->lexeme)
+   {
+       TSLexeme   *ptr = res,
+                  *basevar;
 
-       while( ptr->lexeme ) {
+       while (ptr->lexeme)
+       {
            uint16      nv = ptr->nvariant;
-           uint16      i,nlex = 0;
-           LexemeInfo  **infos;
+           uint16      i,
+                       nlex = 0;
+           LexemeInfo **infos;
 
            basevar = ptr;
-           while( ptr->lexeme && nv == ptr->nvariant ) {
+           while (ptr->lexeme && nv == ptr->nvariant)
+           {
                nlex++;
                ptr++;
            }
 
-           infos = (LexemeInfo**)palloc(sizeof(LexemeInfo*)*nlex);
-           for(i=0;i
-               if ( (infos[i] = findTheLexeme(d, basevar[i].lexeme)) == NULL ) 
+           infos = (LexemeInfo **) palloc(sizeof(LexemeInfo *) * nlex);
+           for (i = 0; i < nlex; i++)
+               if ((infos[i] = findTheLexeme(d, basevar[i].lexeme)) == NULL)
                    break;
 
-           if ( i
+           if (i < nlex)
+           {
                /* no chance to find */
-               pfree( infos );
+               pfree(infos);
                continue;
            }
 
-           info = findVariant( info, stored, curpos, infos, nlex);
+           info = findVariant(info, stored, curpos, infos, nlex);
        }
-   } else if ( res ) { /* stop-word */
-       LexemeInfo  *infos = findTheLexeme(d, NULL);
-       info = findVariant( NULL, stored, curpos, &infos, 1);
-   } else {
-       info = NULL; /* word isn't recognized */
    }
+   else if (res)
+   {                           /* stop-word */
+       LexemeInfo *infos = findTheLexeme(d, NULL);
 
-   dstate->private = (void*)info;
+       info = findVariant(NULL, stored, curpos, &infos, 1);
+   }
+   else
+   {
+       info = NULL;            /* word isn't recognized */
+   }
+
+   dstate->private = (void *) info;
 
-   if ( !info ) {
+   if (!info)
+   {
        dstate->getnext = false;
        PG_RETURN_POINTER(NULL);
    }
-           
-   if ( (res=checkMatch(d, info, curpos,&moreres)) != NULL ) {
+
+   if ((res = checkMatch(d, info, curpos, &moreres)) != NULL)
+   {
        dstate->getnext = moreres;
        PG_RETURN_POINTER(res);
    }
 
    dstate->getnext = true;
 
-   PG_RETURN_POINTER(NULL);    
+   PG_RETURN_POINTER(NULL);
 }
index 4ba3fc62a04f2a9ad132454f0d0f3c6f2c5a98ad..c1bb173e1ce37b03e8d7edd9df06ae1ecb829581 100644 (file)
 #include "query_cleanup.h"
 
 PG_FUNCTION_INFO_V1(gin_extract_tsvector);
-Datum       gin_extract_tsvector(PG_FUNCTION_ARGS);
+Datum      gin_extract_tsvector(PG_FUNCTION_ARGS);
 
 Datum
-gin_extract_tsvector(PG_FUNCTION_ARGS) {
-   tsvector    *vector = (tsvector *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-   uint32      *nentries = (uint32*)PG_GETARG_POINTER(1);
-   Datum       *entries = NULL;
+gin_extract_tsvector(PG_FUNCTION_ARGS)
+{
+   tsvector   *vector = (tsvector *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+   uint32     *nentries = (uint32 *) PG_GETARG_POINTER(1);
+   Datum      *entries = NULL;
 
    *nentries = 0;
-   if ( vector->size > 0 ) {
-       int i;
-       WordEntry   *we = ARRPTR( vector );
+   if (vector->size > 0)
+   {
+       int         i;
+       WordEntry  *we = ARRPTR(vector);
 
-       *nentries = (uint32)vector->size;
-       entries = (Datum*)palloc( sizeof(Datum) * vector->size );
+       *nentries = (uint32) vector->size;
+       entries = (Datum *) palloc(sizeof(Datum) * vector->size);
 
-       for(i=0;isize;i++) {
-           text    *txt = (text*)palloc( VARHDRSZ + we->len );
+       for (i = 0; i < vector->size; i++)
+       {
+           text       *txt = (text *) palloc(VARHDRSZ + we->len);
 
-           VARATT_SIZEP(txt) = VARHDRSZ + we->len; 
-           memcpy( VARDATA(txt), STRPTR( vector ) + we->pos, we->len ); 
+           VARATT_SIZEP(txt) = VARHDRSZ + we->len;
+           memcpy(VARDATA(txt), STRPTR(vector) + we->pos, we->len);
 
-           entries[i] = PointerGetDatum( txt );
+           entries[i] = PointerGetDatum(txt);
 
            we++;
        }
@@ -49,45 +52,50 @@ gin_extract_tsvector(PG_FUNCTION_ARGS) {
 
 
 PG_FUNCTION_INFO_V1(gin_extract_tsquery);
-Datum       gin_extract_tsquery(PG_FUNCTION_ARGS);
+Datum      gin_extract_tsquery(PG_FUNCTION_ARGS);
 
 Datum
-gin_extract_tsquery(PG_FUNCTION_ARGS) {
-   QUERYTYPE *query = (QUERYTYPE*) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-   uint32      *nentries = (uint32*)PG_GETARG_POINTER(1);
-   StrategyNumber  strategy = DatumGetUInt16( PG_GETARG_DATUM(2) ); 
-   Datum       *entries = NULL;
+gin_extract_tsquery(PG_FUNCTION_ARGS)
+{
+   QUERYTYPE  *query = (QUERYTYPE *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+   uint32     *nentries = (uint32 *) PG_GETARG_POINTER(1);
+   StrategyNumber strategy = DatumGetUInt16(PG_GETARG_DATUM(2));
+   Datum      *entries = NULL;
 
    *nentries = 0;
-   if ( query->size > 0 ) {
-       int4 i, j=0, len;
-       ITEM *item;
+   if (query->size > 0)
+   {
+       int4        i,
+                   j = 0,
+                   len;
+       ITEM       *item;
 
        item = clean_NOT_v2(GETQUERY(query), &len);
-       if ( !item )
-           elog(ERROR,"Query requires full scan, GIN doesn't support it");
+       if (!item)
+           elog(ERROR, "Query requires full scan, GIN doesn't support it");
 
        item = GETQUERY(query);
 
-       for(i=0; i<query->size; i++)
-           if ( item[i].type == VAL )
+       for (i = 0; i < query->size; i++)
+           if (item[i].type == VAL)
                (*nentries)++;
 
-       entries = (Datum*)palloc( sizeof(Datum) * (*nentries) );
+       entries = (Datum *) palloc(sizeof(Datum) * (*nentries));
 
-       for(i=0; isize; i++)
-           if ( item[i].type == VAL ) {
-               text    *txt;
+       for (i = 0; i < query->size; i++)
+           if (item[i].type == VAL)
+           {
+               text       *txt;
 
-               txt = (text*)palloc( VARHDRSZ + item[i].length );
+               txt = (text *) palloc(VARHDRSZ + item[i].length);
 
-               VARATT_SIZEP(txt) = VARHDRSZ + item[i].length; 
-               memcpy( VARDATA(txt), GETOPERAND( query ) + item[i].distance, item[i].length );
+               VARATT_SIZEP(txt) = VARHDRSZ + item[i].length;
+               memcpy(VARDATA(txt), GETOPERAND(query) + item[i].distance, item[i].length);
 
-               entries[j++] = PointerGetDatum( txt );
+               entries[j++] = PointerGetDatum(txt);
 
-               if ( strategy == 1 && item[i].weight != 0 )
-                   elog(ERROR,"With class of lexeme restrictions use @@@ operation");
+               if (strategy == 1 && item[i].weight != 0)
+                   elog(ERROR, "With class of lexeme restrictions use @@@ operation");
            }
 
    }
@@ -96,51 +104,54 @@ gin_extract_tsquery(PG_FUNCTION_ARGS) {
    PG_RETURN_POINTER(entries);
 }
 
-typedef struct {
-   ITEM    *frst;
-   bool    *mapped_check;
-} GinChkVal; 
+typedef struct
+{
+   ITEM       *frst;
+   bool       *mapped_check;
+}  GinChkVal;
 
 static bool
-checkcondition_gin(void *checkval, ITEM * val) {
-   GinChkVal   *gcv = (GinChkVal*)checkval;
+checkcondition_gin(void *checkval, ITEM * val)
+{
+   GinChkVal  *gcv = (GinChkVal *) checkval;
 
-   return gcv->mapped_check[ val - gcv->frst ];
+   return gcv->mapped_check[val - gcv->frst];
 }
 
 PG_FUNCTION_INFO_V1(gin_ts_consistent);
-Datum       gin_ts_consistent(PG_FUNCTION_ARGS);
+Datum      gin_ts_consistent(PG_FUNCTION_ARGS);
 
 Datum
-gin_ts_consistent(PG_FUNCTION_ARGS) {
-   bool    *check = (bool*)PG_GETARG_POINTER(0);
-   QUERYTYPE *query = (QUERYTYPE*) PG_DETOAST_DATUM(PG_GETARG_DATUM(2));
-   bool    res = FALSE;
-
-   if ( query->size > 0 ) {
-       int4 i, j=0;
-       ITEM *item;
+gin_ts_consistent(PG_FUNCTION_ARGS)
+{
+   bool       *check = (bool *) PG_GETARG_POINTER(0);
+   QUERYTYPE  *query = (QUERYTYPE *) PG_DETOAST_DATUM(PG_GETARG_DATUM(2));
+   bool        res = FALSE;
+
+   if (query->size > 0)
+   {
+       int4        i,
+                   j = 0;
+       ITEM       *item;
        GinChkVal   gcv;
 
-       gcv.frst = item = GETQUERY(query); 
-       gcv.mapped_check= (bool*)palloc( sizeof(bool) * query->size );
+       gcv.frst = item = GETQUERY(query);
+       gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size);
 
-       for(i=0; i<query->size; i++)
-           if ( item[i].type == VAL )
-               gcv.mapped_check[ i ] = check[ j++ ];
+       for (i = 0; i < query->size; i++)
+           if (item[i].type == VAL)
+               gcv.mapped_check[i] = check[j++];
 
 
        res = TS_execute(
-           GETQUERY(query),
-           &gcv,
-           true,
-           checkcondition_gin
-       );
+                        GETQUERY(query),
+                        &gcv,
+                        true,
+                        checkcondition_gin
+           );
 
    }
 
    PG_FREE_IF_COPY(query, 2);
    PG_RETURN_BOOL(res);
 }
-
-
index 5afb1a41b3b80f55c4b0f7b8413e60a8307223d9..a4d9b2312ed828ea79b9a8c0a25bbac419b0c92b 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/contrib/tsearch2/gistidx.c,v 1.14 2006/06/28 12:00:06 teodor Exp $ */
+/* $PostgreSQL: pgsql/contrib/tsearch2/gistidx.c,v 1.15 2006/10/04 00:29:46 momjian Exp $ */
 
 #include "postgres.h"
 
@@ -447,7 +447,7 @@ sizebitvec(BITVECP sign)
                i;
 
    LOOPBYTE(
-       size += number_of_ones[(unsigned char) sign[i]];
+            size += number_of_ones[(unsigned char) sign[i]];
    );
    return size;
 }
@@ -460,8 +460,8 @@ hemdistsign(BITVECP a, BITVECP b)
                dist = 0;
 
    LOOPBYTE(
-       diff = (unsigned char) (a[i] ^ b[i]);
-       dist += number_of_ones[diff];
+            diff = (unsigned char) (a[i] ^ b[i]);
+   dist += number_of_ones[diff];
    );
    return dist;
 }
@@ -533,7 +533,7 @@ typedef struct
 {
    OffsetNumber pos;
    int4        cost;
-} SPLITCOST;
+}  SPLITCOST;
 
 static int
 comparecost(const void *a, const void *b)
index 4be863431d1bd895a89665fd94d56fb47f5e41d9..904521e50783fec01dfdf4556a9388854f863449 100644 (file)
@@ -9,7 +9,7 @@ RS_isRegis(const char *str)
    {
        if (t_isalpha(str) ||
            t_iseq(str, '[') ||
-           t_iseq(str,']') ||
+           t_iseq(str, ']') ||
            t_iseq(str, '^'))
            str += pg_mblen(str);
        else
@@ -42,13 +42,13 @@ RS_compile(Regis * r, bool issuffix, char *str)
 {
    int         len = strlen(str);
    int         state = RS_IN_WAIT;
-   char            *c = (char*)str;
+   char       *c = (char *) str;
    RegisNode  *ptr = NULL;
 
    memset(r, 0, sizeof(Regis));
    r->issuffix = (issuffix) ? 1 : 0;
 
-   while(*c)
+   while (*c)
    {
        if (state == RS_IN_WAIT)
        {
@@ -62,7 +62,7 @@ RS_compile(Regis * r, bool issuffix, char *str)
                ptr->type = RSF_ONEOF;
                ptr->len = pg_mblen(c);
            }
-           else if (t_iseq(c,'['))
+           else if (t_iseq(c, '['))
            {
                if (ptr)
                    ptr = newRegisNode(ptr, len);
@@ -72,11 +72,11 @@ RS_compile(Regis * r, bool issuffix, char *str)
                state = RS_IN_ONEOF;
            }
            else
-               ts_error(ERROR, "Error in regis: %s", str );
+               ts_error(ERROR, "Error in regis: %s", str);
        }
        else if (state == RS_IN_ONEOF)
        {
-           if (t_iseq(c,'^'))
+           if (t_iseq(c, '^'))
            {
                ptr->type = RSF_NONEOF;
                state = RS_IN_NONEOF;
@@ -94,10 +94,10 @@ RS_compile(Regis * r, bool issuffix, char *str)
        {
            if (t_isalpha(c))
            {
-               COPYCHAR(ptr->data+ptr->len,  c);
-               ptr->len+=pg_mblen(c);
+               COPYCHAR(ptr->data + ptr->len, c);
+               ptr->len += pg_mblen(c);
            }
-           else if (t_iseq(c,']'))
+           else if (t_iseq(c, ']'))
                state = RS_IN_WAIT;
            else
                ts_error(ERROR, "Error in regis: %s", str);
@@ -133,28 +133,34 @@ RS_free(Regis * r)
 
 #ifdef TS_USE_WIDE
 static bool
-mb_strchr(char *str, char *c) {
-   int clen = pg_mblen(c), plen,i;
-   char    *ptr =str;
-   bool    res=false;
+mb_strchr(char *str, char *c)
+{
+   int         clen = pg_mblen(c),
+               plen,
+               i;
+   char       *ptr = str;
+   bool        res = false;
 
    clen = pg_mblen(c);
-   while( *ptr && !res) {
+   while (*ptr && !res)
+   {
        plen = pg_mblen(ptr);
-       if ( plen == clen ) {
-           i=plen;
+       if (plen == clen)
+       {
+           i = plen;
            res = true;
-           while(i--)
-               if ( *(ptr+i) != *(c+i) ) {
+           while (i--)
+               if (*(ptr + i) != *(c + i))
+               {
                    res = false;
-                   break; 
+                   break;
                }
        }
-       
+
        ptr += plen;
-   }    
+   }
 
-   return res; 
+   return res;
 }
 #else
 #define mb_strchr(s,c) ( (strchr((s),*(c)) == NULL) ? false : true )
@@ -165,21 +171,23 @@ bool
 RS_execute(Regis * r, char *str)
 {
    RegisNode  *ptr = r->node;
-   char *c = str;
-   int len=0;
+   char       *c = str;
+   int         len = 0;
 
-   while(*c) {
+   while (*c)
+   {
        len++;
        c += pg_mblen(c);
-   }   
+   }
 
    if (len < r->nchar)
        return 0;
 
    c = str;
-   if (r->issuffix) {
+   if (r->issuffix)
+   {
        len -= r->nchar;
-       while(len-- > 0)
+       while (len-- > 0)
            c += pg_mblen(c);
    }
 
@@ -189,18 +197,18 @@ RS_execute(Regis * r, char *str)
        switch (ptr->type)
        {
            case RSF_ONEOF:
-               if ( mb_strchr((char *) ptr->data, c) != true )
+               if (mb_strchr((char *) ptr->data, c) != true)
                    return false;
                break;
            case RSF_NONEOF:
-               if ( mb_strchr((char *) ptr->data, c) == true )
+               if (mb_strchr((char *) ptr->data, c) == true)
                    return false;
                break;
            default:
                ts_error(ERROR, "RS_execute: Unknown type node: %d\n", ptr->type);
        }
        ptr = ptr->next;
-       c+=pg_mblen(c);
+       c += pg_mblen(c);
    }
 
    return true;
index 5bc337c9251033a2df1a7a236bc684ac9f082893..a0b840b0a0d6ad272e3bd0883aa7256e9a03c32f 100644 (file)
@@ -27,12 +27,12 @@ typedef struct Regis
                unused:15;
 }  Regis;
 
-bool           RS_isRegis(const char *str);
+bool       RS_isRegis(const char *str);
 
-void           RS_compile(Regis * r, bool issuffix, char *str);
+void       RS_compile(Regis * r, bool issuffix, char *str);
 void       RS_free(Regis * r);
 
 /*returns true if matches */
-bool           RS_execute(Regis * r, char *str);
+bool       RS_execute(Regis * r, char *str);
 
 #endif
index 4e199f4bc07a6cc5f18494a7abd827ac4866661c..9e4d689cd41167ca5ddc7271ae1b074efe868a13 100644 (file)
@@ -41,16 +41,18 @@ strnduplicate(char *s, int len)
 }
 
 static char *
-findchar(char *str, int c) {
-   while( *str ) {
-       if ( t_iseq(str, c) ) 
+findchar(char *str, int c)
+{
+   while (*str)
+   {
+       if (t_iseq(str, c))
            return str;
-       str+=pg_mblen(str);
+       str += pg_mblen(str);
    }
 
    return NULL;
 }
-       
+
 
 /* backward string compare for suffix tree operations */
 static int
@@ -126,16 +128,16 @@ NIAddSpell(IspellDict * Conf, const char *word, const char *flag)
        if (Conf->mspell)
        {
            Conf->mspell += 1024 * 20;
-           Conf->Spell = (SPELL **) repalloc(Conf->Spell, Conf->mspell * sizeof(SPELL*));
+           Conf->Spell = (SPELL **) repalloc(Conf->Spell, Conf->mspell * sizeof(SPELL *));
        }
        else
        {
            Conf->mspell = 1024 * 20;
-           Conf->Spell = (SPELL **) palloc(Conf->mspell * sizeof(SPELL*));
+           Conf->Spell = (SPELL **) palloc(Conf->mspell * sizeof(SPELL *));
        }
    }
-   Conf->Spell[Conf->nspell] = (SPELL*)palloc(SPELLHDRSZ + strlen(word) + 1);
-   strcpy( Conf->Spell[Conf->nspell]->word ,word );
+   Conf->Spell[Conf->nspell] = (SPELL *) palloc(SPELLHDRSZ + strlen(word) + 1);
+   strcpy(Conf->Spell[Conf->nspell]->word, word);
    strncpy(Conf->Spell[Conf->nspell]->p.flag, flag, 16);
    Conf->nspell++;
    return (0);
@@ -155,7 +157,7 @@ NIImportDictionary(IspellDict * Conf, const char *filename)
        char       *s;
        const char *flag;
 
-       pg_verifymbstr( str, strlen(str), false);
+       pg_verifymbstr(str, strlen(str), false);
 
        flag = NULL;
        if ((s = findchar(str, '/')))
@@ -181,11 +183,12 @@ NIImportDictionary(IspellDict * Conf, const char *filename)
        s = str;
        while (*s)
        {
-           if (t_isspace(s)) {
+           if (t_isspace(s))
+           {
                *s = '\0';
                break;
            }
-           s+=pg_mblen(s);
+           s += pg_mblen(s);
        }
        lowerstr(str);
 
@@ -268,12 +271,13 @@ NIAddAffix(IspellDict * Conf, int flag, char flagflags, const char *mask, const
    }
    else
    {
-       int masklen = strlen(mask);
+       int         masklen = strlen(mask);
+
        Conf->Affix[Conf->naffixes].issimple = 0;
        Conf->Affix[Conf->naffixes].isregis = 0;
        Conf->Affix[Conf->naffixes].mask = (char *) malloc(masklen + 2);
-       if (type == FF_SUFFIX) 
-           sprintf(Conf->Affix[Conf->naffixes].mask, "%s$", mask); 
+       if (type == FF_SUFFIX)
+           sprintf(Conf->Affix[Conf->naffixes].mask, "%s$", mask);
        else
            sprintf(Conf->Affix[Conf->naffixes].mask, "^%s", mask);
    }
@@ -286,83 +290,121 @@ NIAddAffix(IspellDict * Conf, int flag, char flagflags, const char *mask, const
 
    Conf->Affix[Conf->naffixes].find = (find && *find) ? strdup(find) : VoidString;
    MEMOUT(Conf->Affix[Conf->naffixes].find);
-   if ( (Conf->Affix[Conf->naffixes].replen = strlen(repl)) > 0 ) {
+   if ((Conf->Affix[Conf->naffixes].replen = strlen(repl)) > 0)
+   {
        Conf->Affix[Conf->naffixes].repl = strdup(repl);
        MEMOUT(Conf->Affix[Conf->naffixes].repl);
-   } else
-        Conf->Affix[Conf->naffixes].repl = VoidString;
+   }
+   else
+       Conf->Affix[Conf->naffixes].repl = VoidString;
    Conf->naffixes++;
    return (0);
 }
 
 #define PAE_WAIT_MASK  0
-#define PAE_INMASK     1
-#define PAE_WAIT_FIND  2
-#define PAE_INFIND     3
-#define PAE_WAIT_REPL  4
-#define PAE_INREPL     5
+#define PAE_INMASK 1
+#define PAE_WAIT_FIND  2
+#define PAE_INFIND 3
+#define PAE_WAIT_REPL  4
+#define PAE_INREPL 5
 
 static bool
-parse_affentry( char *str, char *mask, char *find, char *repl, int line ) {
-   int state = PAE_WAIT_MASK;
-   char    *pmask=mask, *pfind=find, *prepl=repl;
+parse_affentry(char *str, char *mask, char *find, char *repl, int line)
+{
+   int         state = PAE_WAIT_MASK;
+   char       *pmask = mask,
+              *pfind = find,
+              *prepl = repl;
 
    *mask = *find = *repl = '\0';
 
-   while(*str) {
-       if ( state == PAE_WAIT_MASK ) {
-           if ( t_iseq(str,'#') ) 
+   while (*str)
+   {
+       if (state == PAE_WAIT_MASK)
+       {
+           if (t_iseq(str, '#'))
                return false;
-           else if (!t_isspace(str)) {
+           else if (!t_isspace(str))
+           {
                COPYCHAR(pmask, str);
                pmask += pg_mblen(str);
                state = PAE_INMASK;
            }
-       } else if ( state == PAE_INMASK ) {
-           if ( t_iseq(str,'>') ) {
-               *pmask='\0';
+       }
+       else if (state == PAE_INMASK)
+       {
+           if (t_iseq(str, '>'))
+           {
+               *pmask = '\0';
                state = PAE_WAIT_FIND;
-           } else if (!t_isspace(str)) {
+           }
+           else if (!t_isspace(str))
+           {
                COPYCHAR(pmask, str);
                pmask += pg_mblen(str);
            }
-       } else if ( state == PAE_WAIT_FIND ) {
-           if ( t_iseq(str,'-') ) {
+       }
+       else if (state == PAE_WAIT_FIND)
+       {
+           if (t_iseq(str, '-'))
+           {
                state = PAE_INFIND;
-           } else if (t_isalpha(str) || t_iseq(str,'\'') /* english 's */) {
-               COPYCHAR(prepl,str);
+           }
+           else if (t_isalpha(str) || t_iseq(str, '\'') /* english 's */ )
+           {
+               COPYCHAR(prepl, str);
                prepl += pg_mblen(str);
                state = PAE_INREPL;
-           } else if (!t_isspace(str))
+           }
+           else if (!t_isspace(str))
                ts_error(ERROR, "Affix parse error at %d line", line);
-       } else if ( state == PAE_INFIND ) {
-           if ( t_iseq(str,',') ) {
-               *pfind='\0';
+       }
+       else if (state == PAE_INFIND)
+       {
+           if (t_iseq(str, ','))
+           {
+               *pfind = '\0';
                state = PAE_WAIT_REPL;
-           } else if (t_isalpha(str)) {
-               COPYCHAR(pfind,str);
+           }
+           else if (t_isalpha(str))
+           {
+               COPYCHAR(pfind, str);
                pfind += pg_mblen(str);
-           } else if (!t_isspace(str))
+           }
+           else if (!t_isspace(str))
                ts_error(ERROR, "Affix parse error at %d line", line);
-       } else if ( state == PAE_WAIT_REPL ) {
-           if ( t_iseq(str,'-') ) {
-               break; /* void repl */
-           } else if ( t_isalpha(str) ) {
-               COPYCHAR(prepl,str);
+       }
+       else if (state == PAE_WAIT_REPL)
+       {
+           if (t_iseq(str, '-'))
+           {
+               break;          /* void repl */
+           }
+           else if (t_isalpha(str))
+           {
+               COPYCHAR(prepl, str);
                prepl += pg_mblen(str);
                state = PAE_INREPL;
-           } else if (!t_isspace(str))
+           }
+           else if (!t_isspace(str))
                ts_error(ERROR, "Affix parse error at %d line", line);
-       } else if ( state == PAE_INREPL ) {
-           if ( t_iseq(str,'#') ) {
+       }
+       else if (state == PAE_INREPL)
+       {
+           if (t_iseq(str, '#'))
+           {
                *prepl = '\0';
                break;
-           } else if ( t_isalpha(str) ) { 
-               COPYCHAR(prepl,str);
+           }
+           else if (t_isalpha(str))
+           {
+               COPYCHAR(prepl, str);
                prepl += pg_mblen(str);
-           } else if (!t_isspace(str))
+           }
+           else if (!t_isspace(str))
                ts_error(ERROR, "Affix parse error at %d line", line);
-       } else
+       }
+       else
            ts_error(ERROR, "Unknown state in parse_affentry: %d", state);
 
        str += pg_mblen(str);
@@ -370,8 +412,8 @@ parse_affentry( char *str, char *mask, char *find, char *repl, int line ) {
 
    *pmask = *pfind = *prepl = '\0';
 
-   return ( *mask && ( *find || *repl) ) ? true : false;
-} 
+   return (*mask && (*find || *repl)) ? true : false;
+}
 
 int
 NIImportAffixes(IspellDict * Conf, const char *filename)
@@ -387,8 +429,8 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
    int         flag = 0;
    char        flagflags = 0;
    FILE       *affix;
-   int line=0;
-   int oldformat = 0;
+   int         line = 0;
+   int         oldformat = 0;
 
    if (!(affix = fopen(filename, "r")))
        return (1);
@@ -397,18 +439,20 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
    while (fgets(str, sizeof(str), affix))
    {
        line++;
-       pg_verifymbstr( str, strlen(str), false);
-       memcpy(tmpstr, str, 32); /* compoundwords... */
-       tmpstr[32]='\0';
+       pg_verifymbstr(str, strlen(str), false);
+       memcpy(tmpstr, str, 32);    /* compoundwords... */
+       tmpstr[32] = '\0';
        lowerstr(tmpstr);
        if (STRNCMP(tmpstr, "compoundwords") == 0)
        {
            s = findchar(str, 'l');
            if (s)
            {
-               while (*s && !t_isspace(s)) s++;
-               while (*s && t_isspace(s)) s++;
-               if ( *s && pg_mblen(s) == 1 ) 
+               while (*s && !t_isspace(s))
+                   s++;
+               while (*s && t_isspace(s))
+                   s++;
+               if (*s && pg_mblen(s) == 1)
                    Conf->compoundcontrol = *s;
                oldformat++;
                continue;
@@ -433,12 +477,13 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
            s = str + 4;
            flagflags = 0;
 
-           while (*s && t_isspace(s)) s++;
+           while (*s && t_isspace(s))
+               s++;
            oldformat++;
 
            /* allow only single-encoded flags */
-           if ( pg_mblen(s) != 1 ) 
-               elog(ERROR,"Multiencoded flag at line %d: %s", line, s);
+           if (pg_mblen(s) != 1)
+               elog(ERROR, "Multiencoded flag at line %d: %s", line, s);
 
            if (*s == '*')
            {
@@ -455,29 +500,31 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
                s++;
 
            /* allow only single-encoded flags */
-           if ( pg_mblen(s) != 1 ) {
+           if (pg_mblen(s) != 1)
+           {
                flagflags = 0;
-               elog(ERROR,"Multiencoded flag at line %d: %s", line, s);
+               elog(ERROR, "Multiencoded flag at line %d: %s", line, s);
            }
 
            flag = (unsigned char) *s;
            continue;
        }
-       if ( STRNCMP(str, "COMPOUNDFLAG") == 0 || STRNCMP(str, "COMPOUNDMIN") == 0 || 
-                    STRNCMP(str, "PFX")==0 || STRNCMP(str, "SFX")==0 ) {
+       if (STRNCMP(str, "COMPOUNDFLAG") == 0 || STRNCMP(str, "COMPOUNDMIN") == 0 ||
+           STRNCMP(str, "PFX") == 0 || STRNCMP(str, "SFX") == 0)
+       {
 
-           if ( oldformat ) 
-               elog(ERROR,"Wrong affix file format");
+           if (oldformat)
+               elog(ERROR, "Wrong affix file format");
 
            fclose(affix);
            return NIImportOOAffixes(Conf, filename);
-           
+
        }
        if ((!suffixes) && (!prefixes))
            continue;
 
        lowerstr(str);
-       if ( !parse_affentry(str, mask, find, repl, line) )
+       if (!parse_affentry(str, mask, find, repl, line))
            continue;
 
        NIAddAffix(Conf, flag, flagflags, mask, find, repl, suffixes ? FF_SUFFIX : FF_PREFIX);
@@ -488,7 +535,8 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
 }
 
 int
-NIImportOOAffixes(IspellDict * Conf, const char *filename) {
+NIImportOOAffixes(IspellDict * Conf, const char *filename)
+{
    char        str[BUFSIZ];
    char        type[BUFSIZ];
    char        sflag[BUFSIZ];
@@ -499,11 +547,11 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename) {
    int         flag = 0;
    char        flagflags = 0;
    FILE       *affix;
-   int line=0;
-   int scanread = 0;
+   int         line = 0;
+   int         scanread = 0;
    char        scanbuf[BUFSIZ];
 
-   sprintf(scanbuf,"%%6s %%%ds %%%ds %%%ds %%%ds", BUFSIZ/5, BUFSIZ/5, BUFSIZ/5, BUFSIZ/5);
+   sprintf(scanbuf, "%%6s %%%ds %%%ds %%%ds %%%ds", BUFSIZ / 5, BUFSIZ / 5, BUFSIZ / 5, BUFSIZ / 5);
 
    if (!(affix = fopen(filename, "r")))
        return (1);
@@ -512,14 +560,17 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename) {
    while (fgets(str, sizeof(str), affix))
    {
        line++;
-       if ( *str == '\0' || t_isspace(str) || t_iseq(str,'#') )
+       if (*str == '\0' || t_isspace(str) || t_iseq(str, '#'))
            continue;
-       pg_verifymbstr( str, strlen(str), false);
+       pg_verifymbstr(str, strlen(str), false);
 
-       if ( STRNCMP(str, "COMPOUNDFLAG")==0 ) {
-           char *s = str+strlen("COMPOUNDFLAG");
-           while (*s && t_isspace(s)) s++;
-           if ( *s && pg_mblen(s) == 1 ) 
+       if (STRNCMP(str, "COMPOUNDFLAG") == 0)
+       {
+           char       *s = str + strlen("COMPOUNDFLAG");
+
+           while (*s && t_isspace(s))
+               s++;
+           if (*s && pg_mblen(s) == 1)
                Conf->compoundcontrol = *s;
            continue;
        }
@@ -527,28 +578,31 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename) {
        scanread = sscanf(str, scanbuf, type, sflag, find, repl, mask);
 
        lowerstr(type);
-       if ( scanread<4 || (STRNCMP(type,"sfx") && STRNCMP(type,"pfx")) )
+       if (scanread < 4 || (STRNCMP(type, "sfx") && STRNCMP(type, "pfx")))
            continue;
 
-       if ( scanread == 4 ) {
-           if ( strlen(sflag) != 1 )
+       if (scanread == 4)
+       {
+           if (strlen(sflag) != 1)
                continue;
            flag = *sflag;
-           isSuffix = (STRNCMP(type,"sfx")==0) ? true : false;
+           isSuffix = (STRNCMP(type, "sfx") == 0) ? true : false;
            lowerstr(find);
-           if ( t_iseq(find,'y') )
+           if (t_iseq(find, 'y'))
                flagflags |= FF_CROSSPRODUCT;
            else
                flagflags = 0;
-       } else {
-           if ( strlen(sflag) != 1 || flag != *sflag || flag==0 )
+       }
+       else
+       {
+           if (strlen(sflag) != 1 || flag != *sflag || flag == 0)
                continue;
            lowerstr(repl);
            lowerstr(find);
            lowerstr(mask);
-           if ( t_iseq(find,'0') )
+           if (t_iseq(find, '0'))
                *find = '\0';
-           if ( t_iseq(repl,'0') )
+           if (t_iseq(repl, '0'))
                *repl = '\0';
 
            NIAddAffix(Conf, flag, flagflags, mask, find, repl, isSuffix ? FF_SUFFIX : FF_PREFIX);
@@ -658,7 +712,7 @@ NISortDictionary(IspellDict * Conf)
    int         naffix = 3;
 
    /* compress affixes */
-   qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL*), cmpspellaffix);
+   qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL *), cmpspellaffix);
    for (i = 1; i < Conf->nspell; i++)
        if (strcmp(Conf->Spell[i]->p.flag, Conf->Spell[i - 1]->p.flag))
            naffix++;
@@ -685,7 +739,7 @@ NISortDictionary(IspellDict * Conf)
        Conf->Spell[i]->p.d.len = strlen(Conf->Spell[i]->word);
    }
 
-   qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL*), cmpspell);
+   qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL *), cmpspell);
    Conf->Dictionary = mkSPNode(Conf, 0, Conf->nspell, 0);
 
    for (i = 0; i < Conf->nspell; i++)
@@ -806,7 +860,7 @@ NISortAffixes(IspellDict * Conf)
    CMPDAffix  *ptr;
    int         firstsuffix = -1;
 
-   if (Conf->naffixes==0)
+   if (Conf->naffixes == 0)
        return;
 
    if (Conf->naffixes > 1)
@@ -822,7 +876,7 @@ NISortAffixes(IspellDict * Conf)
        {
            if (firstsuffix < 0)
                firstsuffix = i;
-           if ((Affix->flagflags & FF_COMPOUNDONLYAFX) && Affix->replen>0 )
+           if ((Affix->flagflags & FF_COMPOUNDONLYAFX) && Affix->replen > 0)
            {
                if (ptr == Conf->CompoundAffix ||
                    strbncmp((const unsigned char *) (ptr - 1)->affix,
@@ -907,14 +961,16 @@ CheckAffix(const char *word, size_t len, AFFIX * Affix, char flagflags, char *ne
    {
        strcpy(newword, word);
        strcpy(newword + len - Affix->replen, Affix->find);
-       if ( baselen ) /* store length of non-changed part of word */ 
+       if (baselen)            /* store length of non-changed part of word */
            *baselen = len - Affix->replen;
    }
    else
    {
-       /* if prefix is a all non-chaged part's length then all word contains only prefix and suffix,
-          so out */
-       if ( baselen && *baselen + strlen(Affix->find) <= Affix->replen )
+       /*
+        * if prefix is a all non-chaged part's length then all word contains
+        * only prefix and suffix, so out
+        */
+       if (baselen && *baselen + strlen(Affix->find) <= Affix->replen)
            return NULL;
        strcpy(newword, Affix->find);
        strcat(newword, word + Affix->replen);
@@ -944,6 +1000,7 @@ CheckAffix(const char *word, size_t len, AFFIX * Affix, char flagflags, char *ne
            int         wmasklen,
                        masklen = strlen(Affix->mask);
            pg_wchar   *mask;
+
            mask = (pg_wchar *) palloc((masklen + 1) * sizeof(pg_wchar));
            wmasklen = pg_mb2wchar_with_len(Affix->mask, mask, masklen);
 
@@ -1040,7 +1097,7 @@ NormalizeSubWord(IspellDict * Conf, char *word, char flag)
     */
    while (snode)
    {
-       int baselen=0;
+       int         baselen = 0;
 
        /* find possible suffix */
        suffix = FinfAffixes(snode, word, wrdlen, &slevel, FF_SUFFIX);
@@ -1111,7 +1168,8 @@ typedef struct SplitVar
 static int
 CheckCompoundAffixes(CMPDAffix ** ptr, char *word, int len, bool CheckInPlace)
 {
-   if ( CheckInPlace ) {
+   if (CheckInPlace)
+   {
        while ((*ptr)->affix)
        {
            if (len > (*ptr)->len && strncmp((*ptr)->affix, word, (*ptr)->len) == 0)
@@ -1122,13 +1180,16 @@ CheckCompoundAffixes(CMPDAffix ** ptr, char *word, int len, bool CheckInPlace)
            }
            (*ptr)++;
        }
-   } else {
-       char *affbegin;
+   }
+   else
+   {
+       char       *affbegin;
+
        while ((*ptr)->affix)
        {
            if (len > (*ptr)->len && (affbegin = strstr(word, (*ptr)->affix)) != NULL)
            {
-               len = (*ptr)->len + (affbegin-word);
+               len = (*ptr)->len + (affbegin - word);
                (*ptr)++;
                return len;
            }
@@ -1227,8 +1288,8 @@ SplitToVariants(IspellDict * Conf, SPNode * snode, SplitVar * orig, char *word,
            }
        }
 
-       if ( !node )
-           break; 
+       if (!node)
+           break;
 
        StopLow = node->data;
        StopHigh = node->data + node->length;
@@ -1243,7 +1304,8 @@ SplitToVariants(IspellDict * Conf, SPNode * snode, SplitVar * orig, char *word,
                StopHigh = StopMiddle;
        }
 
-       if (StopLow < StopHigh) {
+       if (StopLow < StopHigh)
+       {
 
            /* find infinitive */
            if (StopMiddle->isword && StopMiddle->compoundallow && notprobed[level])
@@ -1264,7 +1326,7 @@ SplitToVariants(IspellDict * Conf, SPNode * snode, SplitVar * orig, char *word,
                    {
                        /* then we will search more big word at the same point */
                        SplitVar   *ptr = var;
-   
+
                        while (ptr->next)
                            ptr = ptr->next;
                        ptr->next = SplitToVariants(Conf, node, var, word, wordlen, startpos, level);
@@ -1279,8 +1341,9 @@ SplitToVariants(IspellDict * Conf, SPNode * snode, SplitVar * orig, char *word,
                }
            }
            node = StopMiddle->node;
-       } else
-           node = NULL;  
+       }
+       else
+           node = NULL;
        level++;
    }
 
@@ -1436,9 +1499,12 @@ NIFree(IspellDict * Conf)
            else
                pg_regfree(&(Affix[i].reg.regex));
        }
-       if ( Affix[i].mask != VoidString ) free(Affix[i].mask);
-       if ( Affix[i].find != VoidString ) free(Affix[i].find);
-       if ( Affix[i].repl != VoidString ) free(Affix[i].repl);
+       if (Affix[i].mask != VoidString)
+           free(Affix[i].mask);
+       if (Affix[i].find != VoidString)
+           free(Affix[i].find);
+       if (Affix[i].repl != VoidString)
+           free(Affix[i].repl);
    }
    if (Conf->Spell)
    {
index 5734881947e9b6a1309108783a0920b926b3e323..50a5947680e7cda064c08a659e7b5b23909c9179 100644 (file)
@@ -42,8 +42,8 @@ typedef struct spell_struct
            int         affix;
            int         len;
        }           d;
-   }   p;
-   char    word[1];
+   }           p;
+   char        word[1];
 }  SPELL;
 
 #define SPELLHDRSZ (offsetof(SPELL, word))
@@ -110,7 +110,7 @@ typedef struct
 
    int         nspell;
    int         mspell;
-   SPELL      **Spell;
+   SPELL     **Spell;
 
    AffixNode  *Suffix;
    AffixNode  *Prefix;
index 42fd6712e6d835b9a96a2ef434857407fd6a8670..c519f5f3d4d45d2823780f39b5a86a7fb3a0d033 100644 (file)
@@ -33,9 +33,9 @@ nstrdup(char *ptr, int len)
    {
        if (t_iseq(ptr, '\\'))
            ptr++;
-       COPYCHAR( cptr, ptr );
-       cptr+=pg_mblen(ptr);
-       ptr+=pg_mblen(ptr);
+       COPYCHAR(cptr, ptr);
+       cptr += pg_mblen(ptr);
+       ptr += pg_mblen(ptr);
    }
    *cptr = '\0';
 
@@ -53,9 +53,9 @@ parse_cfgdict(text *in, Map ** m)
 
    while (ptr - VARDATA(in) < VARSIZE(in) - VARHDRSZ)
    {
-       if ( t_iseq(ptr, ',') )
+       if (t_iseq(ptr, ','))
            num++;
-       ptr+=pg_mblen(ptr);
+       ptr += pg_mblen(ptr);
    }
 
    *m = mptr = (Map *) palloc(sizeof(Map) * (num + 2));
@@ -84,7 +84,7 @@ parse_cfgdict(text *in, Map ** m)
                mptr->key = nstrdup(begin, ptr - begin);
                state = CS_WAITEQ;
            }
-           else if (t_iseq(ptr,'='))
+           else if (t_iseq(ptr, '='))
            {
                mptr->key = nstrdup(begin, ptr - begin);
                state = CS_WAITVALUE;
@@ -163,7 +163,7 @@ parse_cfgdict(text *in, Map ** m)
                     errmsg("bad parser state"),
                     errdetail("%d at position %d.",
                               state, (int) (ptr - VARDATA(in)))));
-       ptr+=pg_mblen(ptr);
+       ptr += pg_mblen(ptr);
    }
 
    if (state == CS_IN2VALUE)
index 6aeff0078d1d687d4e1b38732bf28a3c3a7a5dfe..c325e453d4fb6e818afda2ec0593cb7fcb70828a 100644 (file)
@@ -108,11 +108,11 @@ get_weight(char *buf, int2 *weight)
 {
    *weight = 0;
 
-   if ( !t_iseq(buf, ':') )
+   if (!t_iseq(buf, ':'))
        return buf;
 
    buf++;
-   while ( *buf && pg_mblen(buf) == 1 )
+   while (*buf && pg_mblen(buf) == 1)
    {
        switch (*buf)
        {
@@ -153,25 +153,26 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
        {
            case WAITFIRSTOPERAND:
            case WAITOPERAND:
-               if ( t_iseq(state->buf, '!') )
+               if (t_iseq(state->buf, '!'))
                {
-                   (state->buf)++; /* can safely ++, t_iseq guarantee that pg_mblen()==1 */
+                   (state->buf)++;     /* can safely ++, t_iseq guarantee
+                                        * that pg_mblen()==1 */
                    *val = (int4) '!';
                    return OPR;
                }
-               else if ( t_iseq(state->buf, '(') )
+               else if (t_iseq(state->buf, '('))
                {
                    state->count++;
                    (state->buf)++;
                    return OPEN;
                }
-               else if ( t_iseq(state->buf, ':') )
+               else if (t_iseq(state->buf, ':'))
                {
                    ereport(ERROR,
                            (errcode(ERRCODE_SYNTAX_ERROR),
                             errmsg("error at start of operand")));
                }
-               else if ( !t_isspace(state->buf) )
+               else if (!t_isspace(state->buf))
                {
                    state->valstate.prsbuf = state->buf;
                    if (gettoken_tsvector(&(state->valstate)))
@@ -191,14 +192,14 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
                }
                break;
            case WAITOPERATOR:
-               if ( t_iseq(state->buf, '&') || t_iseq(state->buf, '|') )
+               if (t_iseq(state->buf, '&') || t_iseq(state->buf, '|'))
                {
                    state->state = WAITOPERAND;
                    *val = (int4) *(state->buf);
                    (state->buf)++;
                    return OPR;
                }
-               else if ( t_iseq(state->buf, ')') )
+               else if (t_iseq(state->buf, ')'))
                {
                    (state->buf)++;
                    state->count--;
@@ -206,7 +207,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
                }
                else if (*(state->buf) == '\0')
                    return (state->count) ? ERR : END;
-               else if ( !t_isspace(state->buf) )
+               else if (!t_isspace(state->buf))
                    return ERR;
                break;
            case WAITSINGLEOPERAND:
@@ -221,7 +222,7 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
                return ERR;
                break;
        }
-       state->buf+=pg_mblen(state->buf);
+       state->buf += pg_mblen(state->buf);
    }
    return END;
 }
@@ -604,7 +605,7 @@ findoprnd(ITEM * ptr, int4 *pos)
  * input
  */
 static QUERYTYPE *
-queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int cfg_id, bool isplain)
+           queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int cfg_id, bool isplain)
 {
    QPRS_STATE  state;
    int4        i;
@@ -701,8 +702,9 @@ queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int c
 Datum
 tsquery_in(PG_FUNCTION_ARGS)
 {
-   char * in = (char*)PG_GETARG_POINTER(0);
-   pg_verifymbstr( in, strlen(in), false);
+   char       *in = (char *) PG_GETARG_POINTER(0);
+
+   pg_verifymbstr(in, strlen(in), false);
 
    SET_FUNCOID();
    PG_RETURN_POINTER(queryin((char *) in, pushval_asis, 0, false));
@@ -739,23 +741,23 @@ infix(INFIX * in, bool first)
    if (in->curpol->type == VAL)
    {
        char       *op = in->op + in->curpol->distance;
-       int     clen;
+       int         clen;
 
-       RESIZEBUF(in, in->curpol->length * (pg_database_encoding_max_length()+1) + 2 + 5);
+       RESIZEBUF(in, in->curpol->length * (pg_database_encoding_max_length() + 1) + 2 + 5);
        *(in->cur) = '\'';
        in->cur++;
        while (*op)
        {
-           if ( t_iseq(op, '\'') )
+           if (t_iseq(op, '\''))
            {
                *(in->cur) = '\'';
                in->cur++;
            }
-           COPYCHAR(in->cur,op);
+           COPYCHAR(in->cur, op);
 
            clen = pg_mblen(op);
-           op+=clen;
-           in->cur+=clen;
+           op += clen;
+           in->cur += clen;
        }
        *(in->cur) = '\'';
        in->cur++;
index bf1fe18c33a315838d1c85b690b08e92cefa7249..b4d586a684b085c043c0eb611a269a73a0edf97d 100644 (file)
@@ -48,7 +48,7 @@ typedef struct
 #define CLOSE          5
 #define VALSTOP            6       /* for stop words */
 
-bool TS_execute(ITEM *curitem, void *checkval,
-          bool calcnot, bool (*chkcond) (void *checkval, ITEM *val));
+bool TS_execute(ITEM * curitem, void *checkval,
+          bool calcnot, bool (*chkcond) (void *checkval, ITEM * val));
 
 #endif
index f6ce893609c248e7d6bd2cec8bca1431820e5e05..5879f644e649717f24f31c967bfa47d4883076e3 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "query.h"
 
-ITEM      *clean_NOT_v2(ITEM *ptr, int4 *len);
-ITEM      *clean_fakeval_v2(ITEM *ptr, int4 *len);
+ITEM      *clean_NOT_v2(ITEM * ptr, int4 *len);
+ITEM      *clean_fakeval_v2(ITEM * ptr, int4 *len);
 
 #endif
index ffa765560d9c30d7fee41613d670d5ecbefb7951..aafb6901092475404329bb6cfae01a5ccffbcb8f 100644 (file)
@@ -29,7 +29,7 @@ makesign(QUERYTYPE * a)
    for (i = 0; i < a->size; i++)
    {
        if (ptr->type == VAL)
-           sign |= ((TPQTGist)1) << (ptr->val % SIGLEN);
+           sign |= ((TPQTGist) 1) << (ptr->val % SIGLEN);
        ptr++;
    }
 
@@ -104,7 +104,7 @@ tsq_mcontained(PG_FUNCTION_ARGS)
                                        PG_GETARG_DATUM(1),
                                        PG_GETARG_DATUM(0)
                                        )
-   );
+       );
 }
 
 PG_FUNCTION_INFO_V1(gtsq_in);
@@ -272,7 +272,7 @@ typedef struct
 {
    OffsetNumber pos;
    int4        cost;
-} SPLITCOST;
+}  SPLITCOST;
 
 static int
 comparecost(const void *a, const void *b)
index 7ffa62051f563dedb7f82f18d3aeefabb4ebfd5b..41e633580d59207bf84ad1406b3a9e488e075608 100644 (file)
@@ -41,13 +41,13 @@ static float weights[] = {0.1, 0.2, 0.4, 1.0};
 
 #define wpos(wep)  ( w[ WEP_GETWEIGHT(wep) ] )
 
-#define    RANK_NO_NORM        0x00
-#define RANK_NORM_LOGLENGTH    0x01
-#define RANK_NORM_LENGTH   0x02
-#define    RANK_NORM_EXTDIST   0x04
+#define RANK_NO_NORM       0x00
+#define RANK_NORM_LOGLENGTH        0x01
+#define RANK_NORM_LENGTH   0x02
+#define RANK_NORM_EXTDIST  0x04
 #define RANK_NORM_UNIQ     0x08
 #define RANK_NORM_LOGUNIQ  0x10
-#define DEF_NORM_METHOD    RANK_NO_NORM
+#define DEF_NORM_METHOD        RANK_NO_NORM
 
 static float calc_rank_or(float *w, tsvector * t, QUERYTYPE * q);
 static float calc_rank_and(float *w, tsvector * t, QUERYTYPE * q);
@@ -334,19 +334,20 @@ calc_rank(float *w, tsvector * t, QUERYTYPE * q, int4 method)
    if (res < 0)
        res = 1e-20;
 
-   if ( (method & RANK_NORM_LOGLENGTH) && t->size>0 )
+   if ((method & RANK_NORM_LOGLENGTH) && t->size > 0)
        res /= log((double) (cnt_length(t) + 1)) / log(2.0);
 
-   if ( method & RANK_NORM_LENGTH ) {
+   if (method & RANK_NORM_LENGTH)
+   {
        len = cnt_length(t);
-       if ( len>0 )
+       if (len > 0)
            res /= (float) len;
    }
 
-   if ( (method & RANK_NORM_UNIQ) && t->size > 0 )
-       res /= (float)( t->size );
+   if ((method & RANK_NORM_UNIQ) && t->size > 0)
+       res /= (float) (t->size);
 
-   if ( (method & RANK_NORM_LOGUNIQ) && t->size > 0 )
+   if ((method & RANK_NORM_LOGUNIQ) && t->size > 0)
        res /= log((double) (t->size + 1)) / log(2.0);
 
    return res;
@@ -457,17 +458,18 @@ reset_istrue_flag(QUERYTYPE * query)
    }
 }
 
-typedef struct {
-   int pos;
-   int p;
-   int q;
-   DocRepresentation   *begin;
-   DocRepresentation   *end;
-} Extention;
+typedef struct
+{
+   int         pos;
+   int         p;
+   int         q;
+   DocRepresentation *begin;
+   DocRepresentation *end;
+}  Extention;
 
 
 static bool
-Cover(DocRepresentation * doc, int len, QUERYTYPE * query, Extention *ext)
+Cover(DocRepresentation * doc, int len, QUERYTYPE * query, Extention * ext)
 {
    DocRepresentation *ptr;
    int         lastpos = ext->pos;
@@ -513,7 +515,8 @@ Cover(DocRepresentation * doc, int len, QUERYTYPE * query, Extention *ext)
            ptr->item[i]->istrue = 1;
        if (TS_execute(GETQUERY(query), NULL, true, checkcondition_ITEM))
        {
-           if (ptr->pos < ext->p) {
+           if (ptr->pos < ext->p)
+           {
                ext->begin = ptr;
                ext->p = ptr->pos;
            }
@@ -629,69 +632,77 @@ get_docrep(tsvector * txt, QUERYTYPE * query, int *doclen)
 }
 
 static float4
-calc_rank_cd(float4 *arrdata, tsvector *txt, QUERYTYPE *query, int method) {
+calc_rank_cd(float4 *arrdata, tsvector * txt, QUERYTYPE * query, int method)
+{
    DocRepresentation *doc;
-   int             len,
+   int         len,
                i,
                doclen = 0;
    Extention   ext;
    double      Wdoc = 0.0;
    double      invws[lengthof(weights)];
-   double      SumDist=0.0, PrevExtPos=0.0, CurExtPos=0.0;
-   int     NExtent=0;
+   double      SumDist = 0.0,
+               PrevExtPos = 0.0,
+               CurExtPos = 0.0;
+   int         NExtent = 0;
 
    for (i = 0; i < lengthof(weights); i++)
    {
-       invws[i] = ((double)((arrdata[i] >= 0) ? arrdata[i] : weights[i]));
+       invws[i] = ((double) ((arrdata[i] >= 0) ? arrdata[i] : weights[i]));
        if (invws[i] > 1.0)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                     errmsg("weight out of range")));
-       invws[i] = 1.0/invws[i]; 
+       invws[i] = 1.0 / invws[i];
    }
 
    doc = get_docrep(txt, query, &doclen);
-   if (!doc) 
+   if (!doc)
        return 0.0;
 
-   MemSet( &ext, 0, sizeof(Extention) );
-   while (Cover(doc, doclen, query, &ext)) {
-       double  Cpos = 0.0;
-       double  InvSum = 0.0;
+   MemSet(&ext, 0, sizeof(Extention));
+   while (Cover(doc, doclen, query, &ext))
+   {
+       double      Cpos = 0.0;
+       double      InvSum = 0.0;
        DocRepresentation *ptr = ext.begin;
 
-       while ( ptr<=ext.end ) {
-           InvSum += invws[ ptr->wclass ];
+       while (ptr <= ext.end)
+       {
+           InvSum += invws[ptr->wclass];
            ptr++;
        }
 
-       Cpos = ((double)( ext.end-ext.begin+1 )) / InvSum;
-       Wdoc += Cpos / ( (double)(( 1 + (ext.q - ext.p) - (ext.end - ext.begin) )) ); 
+       Cpos = ((double) (ext.end - ext.begin + 1)) / InvSum;
+       Wdoc += Cpos / ((double) ((1 + (ext.q - ext.p) - (ext.end - ext.begin))));
 
-       CurExtPos = ((double)(ext.q + ext.p))/2.0; 
-       if ( NExtent>0 && CurExtPos > PrevExtPos /* prevent devision by zero in a case of multiple lexize */ ) 
-           SumDist += 1.0/( CurExtPos - PrevExtPos );
+       CurExtPos = ((double) (ext.q + ext.p)) / 2.0;
+       if (NExtent > 0 && CurExtPos > PrevExtPos       /* prevent devision by
+                                                        * zero in a case of
+               multiple lexize */ )
+           SumDist += 1.0 / (CurExtPos - PrevExtPos);
 
        PrevExtPos = CurExtPos;
-       NExtent++; 
+       NExtent++;
    }
 
-   if ( (method & RANK_NORM_LOGLENGTH) && txt->size > 0 )
+   if ((method & RANK_NORM_LOGLENGTH) && txt->size > 0)
        Wdoc /= log((double) (cnt_length(txt) + 1));
 
-   if ( method & RANK_NORM_LENGTH ) {
+   if (method & RANK_NORM_LENGTH)
+   {
        len = cnt_length(txt);
-       if ( len>0 )
+       if (len > 0)
            Wdoc /= (double) len;
    }
 
-   if ( (method & RANK_NORM_EXTDIST) && SumDist > 0 ) 
-       Wdoc /= ((double)NExtent) / SumDist;
+   if ((method & RANK_NORM_EXTDIST) && SumDist > 0)
+       Wdoc /= ((double) NExtent) / SumDist;
 
-   if ( (method & RANK_NORM_UNIQ) && txt->size > 0 )
-       Wdoc /= (double)( txt->size );
+   if ((method & RANK_NORM_UNIQ) && txt->size > 0)
+       Wdoc /= (double) (txt->size);
 
-   if ( (method & RANK_NORM_LOGUNIQ) && txt->size > 0 )
+   if ((method & RANK_NORM_LOGUNIQ) && txt->size > 0)
        Wdoc /= log((double) (txt->size + 1)) / log(2.0);
 
    for (i = 0; i < doclen; i++)
@@ -699,13 +710,13 @@ calc_rank_cd(float4 *arrdata, tsvector *txt, QUERYTYPE *query, int method) {
            pfree(doc[i].item);
    pfree(doc);
 
-   return (float4)Wdoc;
-} 
+   return (float4) Wdoc;
+}
 
 Datum
 rank_cd(PG_FUNCTION_ARGS)
 {
-   ArrayType *win =  (ArrayType *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+   ArrayType  *win = (ArrayType *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
    tsvector   *txt = (tsvector *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
    QUERYTYPE  *query = (QUERYTYPE *) PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(2));
    int         method = DEF_NORM_METHOD;
@@ -729,7 +740,7 @@ rank_cd(PG_FUNCTION_ARGS)
    if (PG_NARGS() == 4)
        method = PG_GETARG_INT32(3);
 
-   res = calc_rank_cd( (float4 *) ARR_DATA_PTR(win), txt, query, method);
+   res = calc_rank_cd((float4 *) ARR_DATA_PTR(win), txt, query, method);
 
    PG_FREE_IF_COPY(win, 0);
    PG_FREE_IF_COPY(txt, 1);
@@ -744,10 +755,10 @@ rank_cd_def(PG_FUNCTION_ARGS)
 {
    tsvector   *txt = (tsvector *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
    QUERYTYPE  *query = (QUERYTYPE *) PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(1));
-   float4 res;
+   float4      res;
+
+   res = calc_rank_cd(weights, txt, query, (PG_NARGS() == 3) ? PG_GETARG_DATUM(2) : DEF_NORM_METHOD);
 
-   res = calc_rank_cd( weights, txt, query, (PG_NARGS() == 3) ? PG_GETARG_DATUM(2) : DEF_NORM_METHOD);
-   
    PG_FREE_IF_COPY(txt, 0);
    PG_FREE_IF_COPY(query, 1);
 
@@ -791,7 +802,7 @@ get_covers(PG_FUNCTION_ARGS)
    text       *out;
    char       *cptr;
    DocRepresentation *doc;
-   int             olddwpos = 0;
+   int         olddwpos = 0;
    int         ncover = 1;
    Extention   ext;
 
@@ -833,7 +844,7 @@ get_covers(PG_FUNCTION_ARGS)
    }
    qsort((void *) dw, dlen, sizeof(DocWord), compareDocWord);
 
-   MemSet( &ext, 0, sizeof(Extention) );
+   MemSet(&ext, 0, sizeof(Extention));
    while (Cover(doc, rlen, query, &ext))
    {
        dwptr = dw + olddwpos;
index 99f84db7907fb95bac15754bac1f5a4d9b67788b..994ff267cab62cf17c4efa5bcb33b39a99d2f182 100644 (file)
 
 #include "header.h"
 
-extern int russian_UTF_8_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_UTF_8_create_env(void);
+extern int russian_UTF_8_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_UTF_8_create_env(void);
 extern void russian_UTF_8_close_env(struct SN_env * z);
 
-static symbol s_0_0[10] = { 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8, 0xD1, 0x81, 0xD1, 0x8C };
-static symbol s_0_1[12] = { 0xD1, 0x8B, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8, 0xD1, 0x81, 0xD1, 0x8C };
-static symbol s_0_2[12] = { 0xD0, 0xB8, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8, 0xD1, 0x81, 0xD1, 0x8C };
-static symbol s_0_3[2] = { 0xD0, 0xB2 };
-static symbol s_0_4[4] = { 0xD1, 0x8B, 0xD0, 0xB2 };
-static symbol s_0_5[4] = { 0xD0, 0xB8, 0xD0, 0xB2 };
-static symbol s_0_6[6] = { 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8 };
-static symbol s_0_7[8] = { 0xD1, 0x8B, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8 };
-static symbol s_0_8[8] = { 0xD0, 0xB8, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8 };
+static symbol s_0_0[10] = {0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8, 0xD1, 0x81, 0xD1, 0x8C};
+static symbol s_0_1[12] = {0xD1, 0x8B, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8, 0xD1, 0x81, 0xD1, 0x8C};
+static symbol s_0_2[12] = {0xD0, 0xB8, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8, 0xD1, 0x81, 0xD1, 0x8C};
+static symbol s_0_3[2] = {0xD0, 0xB2};
+static symbol s_0_4[4] = {0xD1, 0x8B, 0xD0, 0xB2};
+static symbol s_0_5[4] = {0xD0, 0xB8, 0xD0, 0xB2};
+static symbol s_0_6[6] = {0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8};
+static symbol s_0_7[8] = {0xD1, 0x8B, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8};
+static symbol s_0_8[8] = {0xD0, 0xB8, 0xD0, 0xB2, 0xD1, 0x88, 0xD0, 0xB8};
 
 static struct among a_0[9] =
 {
-/*  0 */ { 10, s_0_0, -1, 1, 0},
-/*  1 */ { 12, s_0_1, 0, 2, 0},
-/*  2 */ { 12, s_0_2, 0, 2, 0},
-/*  3 */ { 2, s_0_3, -1, 1, 0},
-/*  4 */ { 4, s_0_4, 3, 2, 0},
-/*  5 */ { 4, s_0_5, 3, 2, 0},
-/*  6 */ { 6, s_0_6, -1, 1, 0},
-/*  7 */ { 8, s_0_7, 6, 2, 0},
-/*  8 */ { 8, s_0_8, 6, 2, 0}
+    /*  0 */ {10, s_0_0, -1, 1, 0},
+    /*  1 */ {12, s_0_1, 0, 2, 0},
+    /*  2 */ {12, s_0_2, 0, 2, 0},
+    /*  3 */ {2, s_0_3, -1, 1, 0},
+    /*  4 */ {4, s_0_4, 3, 2, 0},
+    /*  5 */ {4, s_0_5, 3, 2, 0},
+    /*  6 */ {6, s_0_6, -1, 1, 0},
+    /*  7 */ {8, s_0_7, 6, 2, 0},
+    /*  8 */ {8, s_0_8, 6, 2, 0}
 };
 
-static symbol s_1_0[6] = { 0xD0, 0xB5, 0xD0, 0xBC, 0xD1, 0x83 };
-static symbol s_1_1[6] = { 0xD0, 0xBE, 0xD0, 0xBC, 0xD1, 0x83 };
-static symbol s_1_2[4] = { 0xD1, 0x8B, 0xD1, 0x85 };
-static symbol s_1_3[4] = { 0xD0, 0xB8, 0xD1, 0x85 };
-static symbol s_1_4[4] = { 0xD1, 0x83, 0xD1, 0x8E };
-static symbol s_1_5[4] = { 0xD1, 0x8E, 0xD1, 0x8E };
-static symbol s_1_6[4] = { 0xD0, 0xB5, 0xD1, 0x8E };
-static symbol s_1_7[4] = { 0xD0, 0xBE, 0xD1, 0x8E };
-static symbol s_1_8[4] = { 0xD1, 0x8F, 0xD1, 0x8F };
-static symbol s_1_9[4] = { 0xD0, 0xB0, 0xD1, 0x8F };
-static symbol s_1_10[4] = { 0xD1, 0x8B, 0xD0, 0xB5 };
-static symbol s_1_11[4] = { 0xD0, 0xB5, 0xD0, 0xB5 };
-static symbol s_1_12[4] = { 0xD0, 0xB8, 0xD0, 0xB5 };
-static symbol s_1_13[4] = { 0xD0, 0xBE, 0xD0, 0xB5 };
-static symbol s_1_14[6] = { 0xD1, 0x8B, 0xD0, 0xBC, 0xD0, 0xB8 };
-static symbol s_1_15[6] = { 0xD0, 0xB8, 0xD0, 0xBC, 0xD0, 0xB8 };
-static symbol s_1_16[4] = { 0xD1, 0x8B, 0xD0, 0xB9 };
-static symbol s_1_17[4] = { 0xD0, 0xB5, 0xD0, 0xB9 };
-static symbol s_1_18[4] = { 0xD0, 0xB8, 0xD0, 0xB9 };
-static symbol s_1_19[4] = { 0xD0, 0xBE, 0xD0, 0xB9 };
-static symbol s_1_20[4] = { 0xD1, 0x8B, 0xD0, 0xBC };
-static symbol s_1_21[4] = { 0xD0, 0xB5, 0xD0, 0xBC };
-static symbol s_1_22[4] = { 0xD0, 0xB8, 0xD0, 0xBC };
-static symbol s_1_23[4] = { 0xD0, 0xBE, 0xD0, 0xBC };
-static symbol s_1_24[6] = { 0xD0, 0xB5, 0xD0, 0xB3, 0xD0, 0xBE };
-static symbol s_1_25[6] = { 0xD0, 0xBE, 0xD0, 0xB3, 0xD0, 0xBE };
+static symbol s_1_0[6] = {0xD0, 0xB5, 0xD0, 0xBC, 0xD1, 0x83};
+static symbol s_1_1[6] = {0xD0, 0xBE, 0xD0, 0xBC, 0xD1, 0x83};
+static symbol s_1_2[4] = {0xD1, 0x8B, 0xD1, 0x85};
+static symbol s_1_3[4] = {0xD0, 0xB8, 0xD1, 0x85};
+static symbol s_1_4[4] = {0xD1, 0x83, 0xD1, 0x8E};
+static symbol s_1_5[4] = {0xD1, 0x8E, 0xD1, 0x8E};
+static symbol s_1_6[4] = {0xD0, 0xB5, 0xD1, 0x8E};
+static symbol s_1_7[4] = {0xD0, 0xBE, 0xD1, 0x8E};
+static symbol s_1_8[4] = {0xD1, 0x8F, 0xD1, 0x8F};
+static symbol s_1_9[4] = {0xD0, 0xB0, 0xD1, 0x8F};
+static symbol s_1_10[4] = {0xD1, 0x8B, 0xD0, 0xB5};
+static symbol s_1_11[4] = {0xD0, 0xB5, 0xD0, 0xB5};
+static symbol s_1_12[4] = {0xD0, 0xB8, 0xD0, 0xB5};
+static symbol s_1_13[4] = {0xD0, 0xBE, 0xD0, 0xB5};
+static symbol s_1_14[6] = {0xD1, 0x8B, 0xD0, 0xBC, 0xD0, 0xB8};
+static symbol s_1_15[6] = {0xD0, 0xB8, 0xD0, 0xBC, 0xD0, 0xB8};
+static symbol s_1_16[4] = {0xD1, 0x8B, 0xD0, 0xB9};
+static symbol s_1_17[4] = {0xD0, 0xB5, 0xD0, 0xB9};
+static symbol s_1_18[4] = {0xD0, 0xB8, 0xD0, 0xB9};
+static symbol s_1_19[4] = {0xD0, 0xBE, 0xD0, 0xB9};
+static symbol s_1_20[4] = {0xD1, 0x8B, 0xD0, 0xBC};
+static symbol s_1_21[4] = {0xD0, 0xB5, 0xD0, 0xBC};
+static symbol s_1_22[4] = {0xD0, 0xB8, 0xD0, 0xBC};
+static symbol s_1_23[4] = {0xD0, 0xBE, 0xD0, 0xBC};
+static symbol s_1_24[6] = {0xD0, 0xB5, 0xD0, 0xB3, 0xD0, 0xBE};
+static symbol s_1_25[6] = {0xD0, 0xBE, 0xD0, 0xB3, 0xD0, 0xBE};
 
 static struct among a_1[26] =
 {
-/*  0 */ { 6, s_1_0, -1, 1, 0},
-/*  1 */ { 6, s_1_1, -1, 1, 0},
-/*  2 */ { 4, s_1_2, -1, 1, 0},
-/*  3 */ { 4, s_1_3, -1, 1, 0},
-/*  4 */ { 4, s_1_4, -1, 1, 0},
-/*  5 */ { 4, s_1_5, -1, 1, 0},
-/*  6 */ { 4, s_1_6, -1, 1, 0},
-/*  7 */ { 4, s_1_7, -1, 1, 0},
-/*  8 */ { 4, s_1_8, -1, 1, 0},
-/*  9 */ { 4, s_1_9, -1, 1, 0},
-/* 10 */ { 4, s_1_10, -1, 1, 0},
-/* 11 */ { 4, s_1_11, -1, 1, 0},
-/* 12 */ { 4, s_1_12, -1, 1, 0},
-/* 13 */ { 4, s_1_13, -1, 1, 0},
-/* 14 */ { 6, s_1_14, -1, 1, 0},
-/* 15 */ { 6, s_1_15, -1, 1, 0},
-/* 16 */ { 4, s_1_16, -1, 1, 0},
-/* 17 */ { 4, s_1_17, -1, 1, 0},
-/* 18 */ { 4, s_1_18, -1, 1, 0},
-/* 19 */ { 4, s_1_19, -1, 1, 0},
-/* 20 */ { 4, s_1_20, -1, 1, 0},
-/* 21 */ { 4, s_1_21, -1, 1, 0},
-/* 22 */ { 4, s_1_22, -1, 1, 0},
-/* 23 */ { 4, s_1_23, -1, 1, 0},
-/* 24 */ { 6, s_1_24, -1, 1, 0},
-/* 25 */ { 6, s_1_25, -1, 1, 0}
+    /*  0 */ {6, s_1_0, -1, 1, 0},
+    /*  1 */ {6, s_1_1, -1, 1, 0},
+    /*  2 */ {4, s_1_2, -1, 1, 0},
+    /*  3 */ {4, s_1_3, -1, 1, 0},
+    /*  4 */ {4, s_1_4, -1, 1, 0},
+    /*  5 */ {4, s_1_5, -1, 1, 0},
+    /*  6 */ {4, s_1_6, -1, 1, 0},
+    /*  7 */ {4, s_1_7, -1, 1, 0},
+    /*  8 */ {4, s_1_8, -1, 1, 0},
+    /*  9 */ {4, s_1_9, -1, 1, 0},
+    /* 10 */ {4, s_1_10, -1, 1, 0},
+    /* 11 */ {4, s_1_11, -1, 1, 0},
+    /* 12 */ {4, s_1_12, -1, 1, 0},
+    /* 13 */ {4, s_1_13, -1, 1, 0},
+    /* 14 */ {6, s_1_14, -1, 1, 0},
+    /* 15 */ {6, s_1_15, -1, 1, 0},
+    /* 16 */ {4, s_1_16, -1, 1, 0},
+    /* 17 */ {4, s_1_17, -1, 1, 0},
+    /* 18 */ {4, s_1_18, -1, 1, 0},
+    /* 19 */ {4, s_1_19, -1, 1, 0},
+    /* 20 */ {4, s_1_20, -1, 1, 0},
+    /* 21 */ {4, s_1_21, -1, 1, 0},
+    /* 22 */ {4, s_1_22, -1, 1, 0},
+    /* 23 */ {4, s_1_23, -1, 1, 0},
+    /* 24 */ {6, s_1_24, -1, 1, 0},
+    /* 25 */ {6, s_1_25, -1, 1, 0}
 };
 
-static symbol s_2_0[4] = { 0xD0, 0xB2, 0xD1, 0x88 };
-static symbol s_2_1[6] = { 0xD1, 0x8B, 0xD0, 0xB2, 0xD1, 0x88 };
-static symbol s_2_2[6] = { 0xD0, 0xB8, 0xD0, 0xB2, 0xD1, 0x88 };
-static symbol s_2_3[2] = { 0xD1, 0x89 };
-static symbol s_2_4[4] = { 0xD1, 0x8E, 0xD1, 0x89 };
-static symbol s_2_5[6] = { 0xD1, 0x83, 0xD1, 0x8E, 0xD1, 0x89 };
-static symbol s_2_6[4] = { 0xD0, 0xB5, 0xD0, 0xBC };
-static symbol s_2_7[4] = { 0xD0, 0xBD, 0xD0, 0xBD };
+static symbol s_2_0[4] = {0xD0, 0xB2, 0xD1, 0x88};
+static symbol s_2_1[6] = {0xD1, 0x8B, 0xD0, 0xB2, 0xD1, 0x88};
+static symbol s_2_2[6] = {0xD0, 0xB8, 0xD0, 0xB2, 0xD1, 0x88};
+static symbol s_2_3[2] = {0xD1, 0x89};
+static symbol s_2_4[4] = {0xD1, 0x8E, 0xD1, 0x89};
+static symbol s_2_5[6] = {0xD1, 0x83, 0xD1, 0x8E, 0xD1, 0x89};
+static symbol s_2_6[4] = {0xD0, 0xB5, 0xD0, 0xBC};
+static symbol s_2_7[4] = {0xD0, 0xBD, 0xD0, 0xBD};
 
 static struct among a_2[8] =
 {
-/*  0 */ { 4, s_2_0, -1, 1, 0},
-/*  1 */ { 6, s_2_1, 0, 2, 0},
-/*  2 */ { 6, s_2_2, 0, 2, 0},
-/*  3 */ { 2, s_2_3, -1, 1, 0},
-/*  4 */ { 4, s_2_4, 3, 1, 0},
-/*  5 */ { 6, s_2_5, 4, 2, 0},
-/*  6 */ { 4, s_2_6, -1, 1, 0},
-/*  7 */ { 4, s_2_7, -1, 1, 0}
+    /*  0 */ {4, s_2_0, -1, 1, 0},
+    /*  1 */ {6, s_2_1, 0, 2, 0},
+    /*  2 */ {6, s_2_2, 0, 2, 0},
+    /*  3 */ {2, s_2_3, -1, 1, 0},
+    /*  4 */ {4, s_2_4, 3, 1, 0},
+    /*  5 */ {6, s_2_5, 4, 2, 0},
+    /*  6 */ {4, s_2_6, -1, 1, 0},
+    /*  7 */ {4, s_2_7, -1, 1, 0}
 };
 
-static symbol s_3_0[4] = { 0xD1, 0x81, 0xD1, 0x8C };
-static symbol s_3_1[4] = { 0xD1, 0x81, 0xD1, 0x8F };
+static symbol s_3_0[4] = {0xD1, 0x81, 0xD1, 0x8C};
+static symbol s_3_1[4] = {0xD1, 0x81, 0xD1, 0x8F};
 
 static struct among a_3[2] =
 {
-/*  0 */ { 4, s_3_0, -1, 1, 0},
-/*  1 */ { 4, s_3_1, -1, 1, 0}
+    /*  0 */ {4, s_3_0, -1, 1, 0},
+    /*  1 */ {4, s_3_1, -1, 1, 0}
 };
 
-static symbol s_4_0[4] = { 0xD1, 0x8B, 0xD1, 0x82 };
-static symbol s_4_1[4] = { 0xD1, 0x8E, 0xD1, 0x82 };
-static symbol s_4_2[6] = { 0xD1, 0x83, 0xD1, 0x8E, 0xD1, 0x82 };
-static symbol s_4_3[4] = { 0xD1, 0x8F, 0xD1, 0x82 };
-static symbol s_4_4[4] = { 0xD0, 0xB5, 0xD1, 0x82 };
-static symbol s_4_5[6] = { 0xD1, 0x83, 0xD0, 0xB5, 0xD1, 0x82 };
-static symbol s_4_6[4] = { 0xD0, 0xB8, 0xD1, 0x82 };
-static symbol s_4_7[4] = { 0xD0, 0xBD, 0xD1, 0x8B };
-static symbol s_4_8[6] = { 0xD0, 0xB5, 0xD0, 0xBD, 0xD1, 0x8B };
-static symbol s_4_9[4] = { 0xD1, 0x82, 0xD1, 0x8C };
-static symbol s_4_10[6] = { 0xD1, 0x8B, 0xD1, 0x82, 0xD1, 0x8C };
-static symbol s_4_11[6] = { 0xD0, 0xB8, 0xD1, 0x82, 0xD1, 0x8C };
-static symbol s_4_12[6] = { 0xD0, 0xB5, 0xD1, 0x88, 0xD1, 0x8C };
-static symbol s_4_13[6] = { 0xD0, 0xB8, 0xD1, 0x88, 0xD1, 0x8C };
-static symbol s_4_14[2] = { 0xD1, 0x8E };
-static symbol s_4_15[4] = { 0xD1, 0x83, 0xD1, 0x8E };
-static symbol s_4_16[4] = { 0xD0, 0xBB, 0xD0, 0xB0 };
-static symbol s_4_17[6] = { 0xD1, 0x8B, 0xD0, 0xBB, 0xD0, 0xB0 };
-static symbol s_4_18[6] = { 0xD0, 0xB8, 0xD0, 0xBB, 0xD0, 0xB0 };
-static symbol s_4_19[4] = { 0xD0, 0xBD, 0xD0, 0xB0 };
-static symbol s_4_20[6] = { 0xD0, 0xB5, 0xD0, 0xBD, 0xD0, 0xB0 };
-static symbol s_4_21[6] = { 0xD0, 0xB5, 0xD1, 0x82, 0xD0, 0xB5 };
-static symbol s_4_22[6] = { 0xD0, 0xB8, 0xD1, 0x82, 0xD0, 0xB5 };
-static symbol s_4_23[6] = { 0xD0, 0xB9, 0xD1, 0x82, 0xD0, 0xB5 };
-static symbol s_4_24[8] = { 0xD1, 0x83, 0xD0, 0xB9, 0xD1, 0x82, 0xD0, 0xB5 };
-static symbol s_4_25[8] = { 0xD0, 0xB5, 0xD0, 0xB9, 0xD1, 0x82, 0xD0, 0xB5 };
-static symbol s_4_26[4] = { 0xD0, 0xBB, 0xD0, 0xB8 };
-static symbol s_4_27[6] = { 0xD1, 0x8B, 0xD0, 0xBB, 0xD0, 0xB8 };
-static symbol s_4_28[6] = { 0xD0, 0xB8, 0xD0, 0xBB, 0xD0, 0xB8 };
-static symbol s_4_29[2] = { 0xD0, 0xB9 };
-static symbol s_4_30[4] = { 0xD1, 0x83, 0xD0, 0xB9 };
-static symbol s_4_31[4] = { 0xD0, 0xB5, 0xD0, 0xB9 };
-static symbol s_4_32[2] = { 0xD0, 0xBB };
-static symbol s_4_33[4] = { 0xD1, 0x8B, 0xD0, 0xBB };
-static symbol s_4_34[4] = { 0xD0, 0xB8, 0xD0, 0xBB };
-static symbol s_4_35[4] = { 0xD1, 0x8B, 0xD0, 0xBC };
-static symbol s_4_36[4] = { 0xD0, 0xB5, 0xD0, 0xBC };
-static symbol s_4_37[4] = { 0xD0, 0xB8, 0xD0, 0xBC };
-static symbol s_4_38[2] = { 0xD0, 0xBD };
-static symbol s_4_39[4] = { 0xD0, 0xB5, 0xD0, 0xBD };
-static symbol s_4_40[4] = { 0xD0, 0xBB, 0xD0, 0xBE };
-static symbol s_4_41[6] = { 0xD1, 0x8B, 0xD0, 0xBB, 0xD0, 0xBE };
-static symbol s_4_42[6] = { 0xD0, 0xB8, 0xD0, 0xBB, 0xD0, 0xBE };
-static symbol s_4_43[4] = { 0xD0, 0xBD, 0xD0, 0xBE };
-static symbol s_4_44[6] = { 0xD0, 0xB5, 0xD0, 0xBD, 0xD0, 0xBE };
-static symbol s_4_45[6] = { 0xD0, 0xBD, 0xD0, 0xBD, 0xD0, 0xBE };
+static symbol s_4_0[4] = {0xD1, 0x8B, 0xD1, 0x82};
+static symbol s_4_1[4] = {0xD1, 0x8E, 0xD1, 0x82};
+static symbol s_4_2[6] = {0xD1, 0x83, 0xD1, 0x8E, 0xD1, 0x82};
+static symbol s_4_3[4] = {0xD1, 0x8F, 0xD1, 0x82};
+static symbol s_4_4[4] = {0xD0, 0xB5, 0xD1, 0x82};
+static symbol s_4_5[6] = {0xD1, 0x83, 0xD0, 0xB5, 0xD1, 0x82};
+static symbol s_4_6[4] = {0xD0, 0xB8, 0xD1, 0x82};
+static symbol s_4_7[4] = {0xD0, 0xBD, 0xD1, 0x8B};
+static symbol s_4_8[6] = {0xD0, 0xB5, 0xD0, 0xBD, 0xD1, 0x8B};
+static symbol s_4_9[4] = {0xD1, 0x82, 0xD1, 0x8C};
+static symbol s_4_10[6] = {0xD1, 0x8B, 0xD1, 0x82, 0xD1, 0x8C};
+static symbol s_4_11[6] = {0xD0, 0xB8, 0xD1, 0x82, 0xD1, 0x8C};
+static symbol s_4_12[6] = {0xD0, 0xB5, 0xD1, 0x88, 0xD1, 0x8C};
+static symbol s_4_13[6] = {0xD0, 0xB8, 0xD1, 0x88, 0xD1, 0x8C};
+static symbol s_4_14[2] = {0xD1, 0x8E};
+static symbol s_4_15[4] = {0xD1, 0x83, 0xD1, 0x8E};
+static symbol s_4_16[4] = {0xD0, 0xBB, 0xD0, 0xB0};
+static symbol s_4_17[6] = {0xD1, 0x8B, 0xD0, 0xBB, 0xD0, 0xB0};
+static symbol s_4_18[6] = {0xD0, 0xB8, 0xD0, 0xBB, 0xD0, 0xB0};
+static symbol s_4_19[4] = {0xD0, 0xBD, 0xD0, 0xB0};
+static symbol s_4_20[6] = {0xD0, 0xB5, 0xD0, 0xBD, 0xD0, 0xB0};
+static symbol s_4_21[6] = {0xD0, 0xB5, 0xD1, 0x82, 0xD0, 0xB5};
+static symbol s_4_22[6] = {0xD0, 0xB8, 0xD1, 0x82, 0xD0, 0xB5};
+static symbol s_4_23[6] = {0xD0, 0xB9, 0xD1, 0x82, 0xD0, 0xB5};
+static symbol s_4_24[8] = {0xD1, 0x83, 0xD0, 0xB9, 0xD1, 0x82, 0xD0, 0xB5};
+static symbol s_4_25[8] = {0xD0, 0xB5, 0xD0, 0xB9, 0xD1, 0x82, 0xD0, 0xB5};
+static symbol s_4_26[4] = {0xD0, 0xBB, 0xD0, 0xB8};
+static symbol s_4_27[6] = {0xD1, 0x8B, 0xD0, 0xBB, 0xD0, 0xB8};
+static symbol s_4_28[6] = {0xD0, 0xB8, 0xD0, 0xBB, 0xD0, 0xB8};
+static symbol s_4_29[2] = {0xD0, 0xB9};
+static symbol s_4_30[4] = {0xD1, 0x83, 0xD0, 0xB9};
+static symbol s_4_31[4] = {0xD0, 0xB5, 0xD0, 0xB9};
+static symbol s_4_32[2] = {0xD0, 0xBB};
+static symbol s_4_33[4] = {0xD1, 0x8B, 0xD0, 0xBB};
+static symbol s_4_34[4] = {0xD0, 0xB8, 0xD0, 0xBB};
+static symbol s_4_35[4] = {0xD1, 0x8B, 0xD0, 0xBC};
+static symbol s_4_36[4] = {0xD0, 0xB5, 0xD0, 0xBC};
+static symbol s_4_37[4] = {0xD0, 0xB8, 0xD0, 0xBC};
+static symbol s_4_38[2] = {0xD0, 0xBD};
+static symbol s_4_39[4] = {0xD0, 0xB5, 0xD0, 0xBD};
+static symbol s_4_40[4] = {0xD0, 0xBB, 0xD0, 0xBE};
+static symbol s_4_41[6] = {0xD1, 0x8B, 0xD0, 0xBB, 0xD0, 0xBE};
+static symbol s_4_42[6] = {0xD0, 0xB8, 0xD0, 0xBB, 0xD0, 0xBE};
+static symbol s_4_43[4] = {0xD0, 0xBD, 0xD0, 0xBE};
+static symbol s_4_44[6] = {0xD0, 0xB5, 0xD0, 0xBD, 0xD0, 0xBE};
+static symbol s_4_45[6] = {0xD0, 0xBD, 0xD0, 0xBD, 0xD0, 0xBE};
 
 static struct among a_4[46] =
 {
-/*  0 */ { 4, s_4_0, -1, 2, 0},
-/*  1 */ { 4, s_4_1, -1, 1, 0},
-/*  2 */ { 6, s_4_2, 1, 2, 0},
-/*  3 */ { 4, s_4_3, -1, 2, 0},
-/*  4 */ { 4, s_4_4, -1, 1, 0},
-/*  5 */ { 6, s_4_5, 4, 2, 0},
-/*  6 */ { 4, s_4_6, -1, 2, 0},
-/*  7 */ { 4, s_4_7, -1, 1, 0},
-/*  8 */ { 6, s_4_8, 7, 2, 0},
-/*  9 */ { 4, s_4_9, -1, 1, 0},
-/* 10 */ { 6, s_4_10, 9, 2, 0},
-/* 11 */ { 6, s_4_11, 9, 2, 0},
-/* 12 */ { 6, s_4_12, -1, 1, 0},
-/* 13 */ { 6, s_4_13, -1, 2, 0},
-/* 14 */ { 2, s_4_14, -1, 2, 0},
-/* 15 */ { 4, s_4_15, 14, 2, 0},
-/* 16 */ { 4, s_4_16, -1, 1, 0},
-/* 17 */ { 6, s_4_17, 16, 2, 0},
-/* 18 */ { 6, s_4_18, 16, 2, 0},
-/* 19 */ { 4, s_4_19, -1, 1, 0},
-/* 20 */ { 6, s_4_20, 19, 2, 0},
-/* 21 */ { 6, s_4_21, -1, 1, 0},
-/* 22 */ { 6, s_4_22, -1, 2, 0},
-/* 23 */ { 6, s_4_23, -1, 1, 0},
-/* 24 */ { 8, s_4_24, 23, 2, 0},
-/* 25 */ { 8, s_4_25, 23, 2, 0},
-/* 26 */ { 4, s_4_26, -1, 1, 0},
-/* 27 */ { 6, s_4_27, 26, 2, 0},
-/* 28 */ { 6, s_4_28, 26, 2, 0},
-/* 29 */ { 2, s_4_29, -1, 1, 0},
-/* 30 */ { 4, s_4_30, 29, 2, 0},
-/* 31 */ { 4, s_4_31, 29, 2, 0},
-/* 32 */ { 2, s_4_32, -1, 1, 0},
-/* 33 */ { 4, s_4_33, 32, 2, 0},
-/* 34 */ { 4, s_4_34, 32, 2, 0},
-/* 35 */ { 4, s_4_35, -1, 2, 0},
-/* 36 */ { 4, s_4_36, -1, 1, 0},
-/* 37 */ { 4, s_4_37, -1, 2, 0},
-/* 38 */ { 2, s_4_38, -1, 1, 0},
-/* 39 */ { 4, s_4_39, 38, 2, 0},
-/* 40 */ { 4, s_4_40, -1, 1, 0},
-/* 41 */ { 6, s_4_41, 40, 2, 0},
-/* 42 */ { 6, s_4_42, 40, 2, 0},
-/* 43 */ { 4, s_4_43, -1, 1, 0},
-/* 44 */ { 6, s_4_44, 43, 2, 0},
-/* 45 */ { 6, s_4_45, 43, 1, 0}
+    /*  0 */ {4, s_4_0, -1, 2, 0},
+    /*  1 */ {4, s_4_1, -1, 1, 0},
+    /*  2 */ {6, s_4_2, 1, 2, 0},
+    /*  3 */ {4, s_4_3, -1, 2, 0},
+    /*  4 */ {4, s_4_4, -1, 1, 0},
+    /*  5 */ {6, s_4_5, 4, 2, 0},
+    /*  6 */ {4, s_4_6, -1, 2, 0},
+    /*  7 */ {4, s_4_7, -1, 1, 0},
+    /*  8 */ {6, s_4_8, 7, 2, 0},
+    /*  9 */ {4, s_4_9, -1, 1, 0},
+    /* 10 */ {6, s_4_10, 9, 2, 0},
+    /* 11 */ {6, s_4_11, 9, 2, 0},
+    /* 12 */ {6, s_4_12, -1, 1, 0},
+    /* 13 */ {6, s_4_13, -1, 2, 0},
+    /* 14 */ {2, s_4_14, -1, 2, 0},
+    /* 15 */ {4, s_4_15, 14, 2, 0},
+    /* 16 */ {4, s_4_16, -1, 1, 0},
+    /* 17 */ {6, s_4_17, 16, 2, 0},
+    /* 18 */ {6, s_4_18, 16, 2, 0},
+    /* 19 */ {4, s_4_19, -1, 1, 0},
+    /* 20 */ {6, s_4_20, 19, 2, 0},
+    /* 21 */ {6, s_4_21, -1, 1, 0},
+    /* 22 */ {6, s_4_22, -1, 2, 0},
+    /* 23 */ {6, s_4_23, -1, 1, 0},
+    /* 24 */ {8, s_4_24, 23, 2, 0},
+    /* 25 */ {8, s_4_25, 23, 2, 0},
+    /* 26 */ {4, s_4_26, -1, 1, 0},
+    /* 27 */ {6, s_4_27, 26, 2, 0},
+    /* 28 */ {6, s_4_28, 26, 2, 0},
+    /* 29 */ {2, s_4_29, -1, 1, 0},
+    /* 30 */ {4, s_4_30, 29, 2, 0},
+    /* 31 */ {4, s_4_31, 29, 2, 0},
+    /* 32 */ {2, s_4_32, -1, 1, 0},
+    /* 33 */ {4, s_4_33, 32, 2, 0},
+    /* 34 */ {4, s_4_34, 32, 2, 0},
+    /* 35 */ {4, s_4_35, -1, 2, 0},
+    /* 36 */ {4, s_4_36, -1, 1, 0},
+    /* 37 */ {4, s_4_37, -1, 2, 0},
+    /* 38 */ {2, s_4_38, -1, 1, 0},
+    /* 39 */ {4, s_4_39, 38, 2, 0},
+    /* 40 */ {4, s_4_40, -1, 1, 0},
+    /* 41 */ {6, s_4_41, 40, 2, 0},
+    /* 42 */ {6, s_4_42, 40, 2, 0},
+    /* 43 */ {4, s_4_43, -1, 1, 0},
+    /* 44 */ {6, s_4_44, 43, 2, 0},
+    /* 45 */ {6, s_4_45, 43, 1, 0}
 };
 
-static symbol s_5_0[2] = { 0xD1, 0x83 };
-static symbol s_5_1[4] = { 0xD1, 0x8F, 0xD1, 0x85 };
-static symbol s_5_2[6] = { 0xD0, 0xB8, 0xD1, 0x8F, 0xD1, 0x85 };
-static symbol s_5_3[4] = { 0xD0, 0xB0, 0xD1, 0x85 };
-static symbol s_5_4[2] = { 0xD1, 0x8B };
-static symbol s_5_5[2] = { 0xD1, 0x8C };
-static symbol s_5_6[2] = { 0xD1, 0x8E };
-static symbol s_5_7[4] = { 0xD1, 0x8C, 0xD1, 0x8E };
-static symbol s_5_8[4] = { 0xD0, 0xB8, 0xD1, 0x8E };
-static symbol s_5_9[2] = { 0xD1, 0x8F };
-static symbol s_5_10[4] = { 0xD1, 0x8C, 0xD1, 0x8F };
-static symbol s_5_11[4] = { 0xD0, 0xB8, 0xD1, 0x8F };
-static symbol s_5_12[2] = { 0xD0, 0xB0 };
-static symbol s_5_13[4] = { 0xD0, 0xB5, 0xD0, 0xB2 };
-static symbol s_5_14[4] = { 0xD0, 0xBE, 0xD0, 0xB2 };
-static symbol s_5_15[2] = { 0xD0, 0xB5 };
-static symbol s_5_16[4] = { 0xD1, 0x8C, 0xD0, 0xB5 };
-static symbol s_5_17[4] = { 0xD0, 0xB8, 0xD0, 0xB5 };
-static symbol s_5_18[2] = { 0xD0, 0xB8 };
-static symbol s_5_19[4] = { 0xD0, 0xB5, 0xD0, 0xB8 };
-static symbol s_5_20[4] = { 0xD0, 0xB8, 0xD0, 0xB8 };
-static symbol s_5_21[6] = { 0xD1, 0x8F, 0xD0, 0xBC, 0xD0, 0xB8 };
-static symbol s_5_22[8] = { 0xD0, 0xB8, 0xD1, 0x8F, 0xD0, 0xBC, 0xD0, 0xB8 };
-static symbol s_5_23[6] = { 0xD0, 0xB0, 0xD0, 0xBC, 0xD0, 0xB8 };
-static symbol s_5_24[2] = { 0xD0, 0xB9 };
-static symbol s_5_25[4] = { 0xD0, 0xB5, 0xD0, 0xB9 };
-static symbol s_5_26[6] = { 0xD0, 0xB8, 0xD0, 0xB5, 0xD0, 0xB9 };
-static symbol s_5_27[4] = { 0xD0, 0xB8, 0xD0, 0xB9 };
-static symbol s_5_28[4] = { 0xD0, 0xBE, 0xD0, 0xB9 };
-static symbol s_5_29[4] = { 0xD1, 0x8F, 0xD0, 0xBC };
-static symbol s_5_30[6] = { 0xD0, 0xB8, 0xD1, 0x8F, 0xD0, 0xBC };
-static symbol s_5_31[4] = { 0xD0, 0xB0, 0xD0, 0xBC };
-static symbol s_5_32[4] = { 0xD0, 0xB5, 0xD0, 0xBC };
-static symbol s_5_33[6] = { 0xD0, 0xB8, 0xD0, 0xB5, 0xD0, 0xBC };
-static symbol s_5_34[4] = { 0xD0, 0xBE, 0xD0, 0xBC };
-static symbol s_5_35[2] = { 0xD0, 0xBE };
+static symbol s_5_0[2] = {0xD1, 0x83};
+static symbol s_5_1[4] = {0xD1, 0x8F, 0xD1, 0x85};
+static symbol s_5_2[6] = {0xD0, 0xB8, 0xD1, 0x8F, 0xD1, 0x85};
+static symbol s_5_3[4] = {0xD0, 0xB0, 0xD1, 0x85};
+static symbol s_5_4[2] = {0xD1, 0x8B};
+static symbol s_5_5[2] = {0xD1, 0x8C};
+static symbol s_5_6[2] = {0xD1, 0x8E};
+static symbol s_5_7[4] = {0xD1, 0x8C, 0xD1, 0x8E};
+static symbol s_5_8[4] = {0xD0, 0xB8, 0xD1, 0x8E};
+static symbol s_5_9[2] = {0xD1, 0x8F};
+static symbol s_5_10[4] = {0xD1, 0x8C, 0xD1, 0x8F};
+static symbol s_5_11[4] = {0xD0, 0xB8, 0xD1, 0x8F};
+static symbol s_5_12[2] = {0xD0, 0xB0};
+static symbol s_5_13[4] = {0xD0, 0xB5, 0xD0, 0xB2};
+static symbol s_5_14[4] = {0xD0, 0xBE, 0xD0, 0xB2};
+static symbol s_5_15[2] = {0xD0, 0xB5};
+static symbol s_5_16[4] = {0xD1, 0x8C, 0xD0, 0xB5};
+static symbol s_5_17[4] = {0xD0, 0xB8, 0xD0, 0xB5};
+static symbol s_5_18[2] = {0xD0, 0xB8};
+static symbol s_5_19[4] = {0xD0, 0xB5, 0xD0, 0xB8};
+static symbol s_5_20[4] = {0xD0, 0xB8, 0xD0, 0xB8};
+static symbol s_5_21[6] = {0xD1, 0x8F, 0xD0, 0xBC, 0xD0, 0xB8};
+static symbol s_5_22[8] = {0xD0, 0xB8, 0xD1, 0x8F, 0xD0, 0xBC, 0xD0, 0xB8};
+static symbol s_5_23[6] = {0xD0, 0xB0, 0xD0, 0xBC, 0xD0, 0xB8};
+static symbol s_5_24[2] = {0xD0, 0xB9};
+static symbol s_5_25[4] = {0xD0, 0xB5, 0xD0, 0xB9};
+static symbol s_5_26[6] = {0xD0, 0xB8, 0xD0, 0xB5, 0xD0, 0xB9};
+static symbol s_5_27[4] = {0xD0, 0xB8, 0xD0, 0xB9};
+static symbol s_5_28[4] = {0xD0, 0xBE, 0xD0, 0xB9};
+static symbol s_5_29[4] = {0xD1, 0x8F, 0xD0, 0xBC};
+static symbol s_5_30[6] = {0xD0, 0xB8, 0xD1, 0x8F, 0xD0, 0xBC};
+static symbol s_5_31[4] = {0xD0, 0xB0, 0xD0, 0xBC};
+static symbol s_5_32[4] = {0xD0, 0xB5, 0xD0, 0xBC};
+static symbol s_5_33[6] = {0xD0, 0xB8, 0xD0, 0xB5, 0xD0, 0xBC};
+static symbol s_5_34[4] = {0xD0, 0xBE, 0xD0, 0xBC};
+static symbol s_5_35[2] = {0xD0, 0xBE};
 
 static struct among a_5[36] =
 {
-/*  0 */ { 2, s_5_0, -1, 1, 0},
-/*  1 */ { 4, s_5_1, -1, 1, 0},
-/*  2 */ { 6, s_5_2, 1, 1, 0},
-/*  3 */ { 4, s_5_3, -1, 1, 0},
-/*  4 */ { 2, s_5_4, -1, 1, 0},
-/*  5 */ { 2, s_5_5, -1, 1, 0},
-/*  6 */ { 2, s_5_6, -1, 1, 0},
-/*  7 */ { 4, s_5_7, 6, 1, 0},
-/*  8 */ { 4, s_5_8, 6, 1, 0},
-/*  9 */ { 2, s_5_9, -1, 1, 0},
-/* 10 */ { 4, s_5_10, 9, 1, 0},
-/* 11 */ { 4, s_5_11, 9, 1, 0},
-/* 12 */ { 2, s_5_12, -1, 1, 0},
-/* 13 */ { 4, s_5_13, -1, 1, 0},
-/* 14 */ { 4, s_5_14, -1, 1, 0},
-/* 15 */ { 2, s_5_15, -1, 1, 0},
-/* 16 */ { 4, s_5_16, 15, 1, 0},
-/* 17 */ { 4, s_5_17, 15, 1, 0},
-/* 18 */ { 2, s_5_18, -1, 1, 0},
-/* 19 */ { 4, s_5_19, 18, 1, 0},
-/* 20 */ { 4, s_5_20, 18, 1, 0},
-/* 21 */ { 6, s_5_21, 18, 1, 0},
-/* 22 */ { 8, s_5_22, 21, 1, 0},
-/* 23 */ { 6, s_5_23, 18, 1, 0},
-/* 24 */ { 2, s_5_24, -1, 1, 0},
-/* 25 */ { 4, s_5_25, 24, 1, 0},
-/* 26 */ { 6, s_5_26, 25, 1, 0},
-/* 27 */ { 4, s_5_27, 24, 1, 0},
-/* 28 */ { 4, s_5_28, 24, 1, 0},
-/* 29 */ { 4, s_5_29, -1, 1, 0},
-/* 30 */ { 6, s_5_30, 29, 1, 0},
-/* 31 */ { 4, s_5_31, -1, 1, 0},
-/* 32 */ { 4, s_5_32, -1, 1, 0},
-/* 33 */ { 6, s_5_33, 32, 1, 0},
-/* 34 */ { 4, s_5_34, -1, 1, 0},
-/* 35 */ { 2, s_5_35, -1, 1, 0}
+    /*  0 */ {2, s_5_0, -1, 1, 0},
+    /*  1 */ {4, s_5_1, -1, 1, 0},
+    /*  2 */ {6, s_5_2, 1, 1, 0},
+    /*  3 */ {4, s_5_3, -1, 1, 0},
+    /*  4 */ {2, s_5_4, -1, 1, 0},
+    /*  5 */ {2, s_5_5, -1, 1, 0},
+    /*  6 */ {2, s_5_6, -1, 1, 0},
+    /*  7 */ {4, s_5_7, 6, 1, 0},
+    /*  8 */ {4, s_5_8, 6, 1, 0},
+    /*  9 */ {2, s_5_9, -1, 1, 0},
+    /* 10 */ {4, s_5_10, 9, 1, 0},
+    /* 11 */ {4, s_5_11, 9, 1, 0},
+    /* 12 */ {2, s_5_12, -1, 1, 0},
+    /* 13 */ {4, s_5_13, -1, 1, 0},
+    /* 14 */ {4, s_5_14, -1, 1, 0},
+    /* 15 */ {2, s_5_15, -1, 1, 0},
+    /* 16 */ {4, s_5_16, 15, 1, 0},
+    /* 17 */ {4, s_5_17, 15, 1, 0},
+    /* 18 */ {2, s_5_18, -1, 1, 0},
+    /* 19 */ {4, s_5_19, 18, 1, 0},
+    /* 20 */ {4, s_5_20, 18, 1, 0},
+    /* 21 */ {6, s_5_21, 18, 1, 0},
+    /* 22 */ {8, s_5_22, 21, 1, 0},
+    /* 23 */ {6, s_5_23, 18, 1, 0},
+    /* 24 */ {2, s_5_24, -1, 1, 0},
+    /* 25 */ {4, s_5_25, 24, 1, 0},
+    /* 26 */ {6, s_5_26, 25, 1, 0},
+    /* 27 */ {4, s_5_27, 24, 1, 0},
+    /* 28 */ {4, s_5_28, 24, 1, 0},
+    /* 29 */ {4, s_5_29, -1, 1, 0},
+    /* 30 */ {6, s_5_30, 29, 1, 0},
+    /* 31 */ {4, s_5_31, -1, 1, 0},
+    /* 32 */ {4, s_5_32, -1, 1, 0},
+    /* 33 */ {6, s_5_33, 32, 1, 0},
+    /* 34 */ {4, s_5_34, -1, 1, 0},
+    /* 35 */ {2, s_5_35, -1, 1, 0}
 };
 
-static symbol s_6_0[6] = { 0xD0, 0xBE, 0xD1, 0x81, 0xD1, 0x82 };
-static symbol s_6_1[8] = { 0xD0, 0xBE, 0xD1, 0x81, 0xD1, 0x82, 0xD1, 0x8C };
+static symbol s_6_0[6] = {0xD0, 0xBE, 0xD1, 0x81, 0xD1, 0x82};
+static symbol s_6_1[8] = {0xD0, 0xBE, 0xD1, 0x81, 0xD1, 0x82, 0xD1, 0x8C};
 
 static struct among a_6[2] =
 {
-/*  0 */ { 6, s_6_0, -1, 1, 0},
-/*  1 */ { 8, s_6_1, -1, 1, 0}
+    /*  0 */ {6, s_6_0, -1, 1, 0},
+    /*  1 */ {8, s_6_1, -1, 1, 0}
 };
 
-static symbol s_7_0[6] = { 0xD0, 0xB5, 0xD0, 0xB9, 0xD1, 0x88 };
-static symbol s_7_1[2] = { 0xD1, 0x8C };
-static symbol s_7_2[8] = { 0xD0, 0xB5, 0xD0, 0xB9, 0xD1, 0x88, 0xD0, 0xB5 };
-static symbol s_7_3[2] = { 0xD0, 0xBD };
+static symbol s_7_0[6] = {0xD0, 0xB5, 0xD0, 0xB9, 0xD1, 0x88};
+static symbol s_7_1[2] = {0xD1, 0x8C};
+static symbol s_7_2[8] = {0xD0, 0xB5, 0xD0, 0xB9, 0xD1, 0x88, 0xD0, 0xB5};
+static symbol s_7_3[2] = {0xD0, 0xBD};
 
 static struct among a_7[4] =
 {
-/*  0 */ { 6, s_7_0, -1, 1, 0},
-/*  1 */ { 2, s_7_1, -1, 3, 0},
-/*  2 */ { 8, s_7_2, -1, 1, 0},
-/*  3 */ { 2, s_7_3, -1, 2, 0}
+    /*  0 */ {6, s_7_0, -1, 1, 0},
+    /*  1 */ {2, s_7_1, -1, 3, 0},
+    /*  2 */ {8, s_7_2, -1, 1, 0},
+    /*  3 */ {2, s_7_3, -1, 2, 0}
 };
 
-static unsigned char g_v[] = { 33, 65, 8, 232 };
-
-static symbol s_0[] = { 0xD0, 0xB0 };
-static symbol s_1[] = { 0xD1, 0x8F };
-static symbol s_2[] = { 0xD0, 0xB0 };
-static symbol s_3[] = { 0xD1, 0x8F };
-static symbol s_4[] = { 0xD0, 0xB0 };
-static symbol s_5[] = { 0xD1, 0x8F };
-static symbol s_6[] = { 0xD0, 0xBD };
-static symbol s_7[] = { 0xD0, 0xBD };
-static symbol s_8[] = { 0xD0, 0xBD };
-static symbol s_9[] = { 0xD0, 0xB8 };
-
-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 61 */
-        while(1) { /* gopast, line 62 */
-            if (!(in_grouping_U(z, g_v, 1072, 1103))) goto lab1;
-            break;
-        lab1:
-            {   int c = skip_utf8(z->p, z->c, 0, z->l, 1);
-                if (c < 0) goto lab0;
-                z->c = c; /* gopast, line 62 */
-            }
-        }
-        z->I[0] = z->c; /* setmark pV, line 62 */
-        while(1) { /* gopast, line 62 */
-            if (!(out_grouping_U(z, g_v, 1072, 1103))) goto lab2;
-            break;
-        lab2:
-            {   int c = skip_utf8(z->p, z->c, 0, z->l, 1);
-                if (c < 0) goto lab0;
-                z->c = c; /* gopast, line 62 */
-            }
-        }
-        while(1) { /* gopast, line 63 */
-            if (!(in_grouping_U(z, g_v, 1072, 1103))) goto lab3;
-            break;
-        lab3:
-            {   int c = skip_utf8(z->p, z->c, 0, z->l, 1);
-                if (c < 0) goto lab0;
-                z->c = c; /* gopast, line 63 */
-            }
-        }
-        while(1) { /* gopast, line 63 */
-            if (!(out_grouping_U(z, g_v, 1072, 1103))) goto lab4;
-            break;
-        lab4:
-            {   int c = skip_utf8(z->p, z->c, 0, z->l, 1);
-                if (c < 0) goto lab0;
-                z->c = c; /* gopast, line 63 */
-            }
-        }
-        z->I[1] = z->c; /* setmark p2, line 63 */
-    lab0:
-        z->c = c;
-    }
-    return 1;
+static unsigned char g_v[] = {33, 65, 8, 232};
+
+static symbol s_0[] = {0xD0, 0xB0};
+static symbol s_1[] = {0xD1, 0x8F};
+static symbol s_2[] = {0xD0, 0xB0};
+static symbol s_3[] = {0xD1, 0x8F};
+static symbol s_4[] = {0xD0, 0xB0};
+static symbol s_5[] = {0xD1, 0x8F};
+static symbol s_6[] = {0xD0, 0xBD};
+static symbol s_7[] = {0xD0, 0xBD};
+static symbol s_8[] = {0xD0, 0xBD};
+static symbol s_9[] = {0xD0, 0xB8};
+
+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 61 */
+
+       while (1)
+       {                       /* gopast, line 62 */
+           if (!(in_grouping_U(z, g_v, 1072, 1103)))
+               goto lab1;
+           break;
+   lab1:
+           {
+               int         c = skip_utf8(z->p, z->c, 0, z->l, 1);
+
+               if (c < 0)
+                   goto lab0;
+               z->c = c;       /* gopast, line 62 */
+           }
+       }
+       z->I[0] = z->c;         /* setmark pV, line 62 */
+       while (1)
+       {                       /* gopast, line 62 */
+           if (!(out_grouping_U(z, g_v, 1072, 1103)))
+               goto lab2;
+           break;
+   lab2:
+           {
+               int         c = skip_utf8(z->p, z->c, 0, z->l, 1);
+
+               if (c < 0)
+                   goto lab0;
+               z->c = c;       /* gopast, line 62 */
+           }
+       }
+       while (1)
+       {                       /* gopast, line 63 */
+           if (!(in_grouping_U(z, g_v, 1072, 1103)))
+               goto lab3;
+           break;
+   lab3:
+           {
+               int         c = skip_utf8(z->p, z->c, 0, z->l, 1);
+
+               if (c < 0)
+                   goto lab0;
+               z->c = c;       /* gopast, line 63 */
+           }
+       }
+       while (1)
+       {                       /* gopast, line 63 */
+           if (!(out_grouping_U(z, g_v, 1072, 1103)))
+               goto lab4;
+           break;
+   lab4:
+           {
+               int         c = skip_utf8(z->p, z->c, 0, z->l, 1);
+
+               if (c < 0)
+                   goto lab0;
+               z->c = c;       /* gopast, line 63 */
+           }
+       }
+       z->I[1] = z->c;         /* setmark p2, line 63 */
+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 72 */
-    among_var = find_among_b(z, a_0, 9); /* substring, line 72 */
-    if (!(among_var)) return 0;
-    z->bra = z->c; /* ], line 72 */
-    switch(among_var) {
-        case 0: return 0;
-        case 1:
-            {   int m = z->l - z->c; (void) m; /* or, line 76 */
-                if (!(eq_s_b(z, 2, s_0))) goto lab1;
-                goto lab0;
-            lab1:
-                z->c = z->l - m;
-                if (!(eq_s_b(z, 2, s_1))) return 0;
-            }
-        lab0:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 76 */
-                if (ret < 0) return ret;
-            }
-            break;
-        case 2:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 83 */
-                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 72 */
+   among_var = find_among_b(z, a_0, 9);        /* substring, line 72 */
+   if (!(among_var))
+       return 0;
+   z->bra = z->c;              /* ], line 72 */
+   switch (among_var)
+   {
+       case 0:
+           return 0;
+       case 1:
+           {
+               int         m = z->l - z->c;
+
+               (void) m;       /* or, line 76 */
+               if (!(eq_s_b(z, 2, s_0)))
+                   goto lab1;
+               goto lab0;
+       lab1:
+               z->c = z->l - m;
+               if (!(eq_s_b(z, 2, s_1)))
+                   return 0;
+           }
+   lab0:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 76 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+       case 2:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 83 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+   }
+   return 1;
 }
 
-static int r_adjective(struct SN_env * z) {
-    int among_var;
-    z->ket = z->c; /* [, line 88 */
-    among_var = find_among_b(z, a_1, 26); /* substring, line 88 */
-    if (!(among_var)) return 0;
-    z->bra = z->c; /* ], line 88 */
-    switch(among_var) {
-        case 0: return 0;
-        case 1:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 97 */
-                if (ret < 0) return ret;
-            }
-            break;
-    }
-    return 1;
+static int
+r_adjective(struct SN_env * z)
+{
+   int         among_var;
+
+   z->ket = z->c;              /* [, line 88 */
+   among_var = find_among_b(z, a_1, 26);       /* substring, line 88 */
+   if (!(among_var))
+       return 0;
+   z->bra = z->c;              /* ], line 88 */
+   switch (among_var)
+   {
+       case 0:
+           return 0;
+       case 1:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 97 */
+               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 102 */
-        if (ret < 0) return ret;
-    }
-    {   int m = z->l - z->c; (void) m; /* try, line 109 */
-        z->ket = z->c; /* [, line 110 */
-        among_var = find_among_b(z, a_2, 8); /* substring, line 110 */
-        if (!(among_var)) { z->c = z->l - m; goto lab0; }
-        z->bra = z->c; /* ], line 110 */
-        switch(among_var) {
-            case 0: { z->c = z->l - m; goto lab0; }
-            case 1:
-                {   int m = z->l - z->c; (void) m; /* or, line 115 */
-                    if (!(eq_s_b(z, 2, s_2))) goto lab2;
-                    goto lab1;
-                lab2:
-                    z->c = z->l - m;
-                    if (!(eq_s_b(z, 2, s_3))) { z->c = z->l - m; goto lab0; }
-                }
-            lab1:
-                {   int ret;
-                    ret = slice_del(z); /* delete, line 115 */
-                    if (ret < 0) return ret;
-                }
-                break;
-            case 2:
-                {   int ret;
-                    ret = slice_del(z); /* delete, line 122 */
-                    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 102 */
+       if (ret < 0)
+           return ret;
+   }
+   {
+       int         m = z->l - z->c;
+
+       (void) m;               /* try, line 109 */
+       z->ket = z->c;          /* [, line 110 */
+       among_var = find_among_b(z, a_2, 8);    /* substring, line 110 */
+       if (!(among_var))
+       {
+           z->c = z->l - m;
+           goto lab0;
+       }
+       z->bra = z->c;          /* ], line 110 */
+       switch (among_var)
+       {
+           case 0:
+               {
+                   z->c = z->l - m;
+                   goto lab0;
+               }
+           case 1:
+               {
+                   int         m = z->l - z->c;
+
+                   (void) m;   /* or, line 115 */
+                   if (!(eq_s_b(z, 2, s_2)))
+                       goto lab2;
+                   goto lab1;
+           lab2:
+                   z->c = z->l - m;
+                   if (!(eq_s_b(z, 2, s_3)))
+                   {
+                       z->c = z->l - m;
+                       goto lab0;
+                   }
+               }
+       lab1:
+               {
+                   int         ret;
+
+                   ret = slice_del(z); /* delete, line 115 */
+                   if (ret < 0)
+                       return ret;
+               }
+               break;
+           case 2:
+               {
+                   int         ret;
+
+                   ret = slice_del(z); /* delete, line 122 */
+                   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 129 */
-    among_var = find_among_b(z, a_3, 2); /* substring, line 129 */
-    if (!(among_var)) return 0;
-    z->bra = z->c; /* ], line 129 */
-    switch(among_var) {
-        case 0: return 0;
-        case 1:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 132 */
-                if (ret < 0) return ret;
-            }
-            break;
-    }
-    return 1;
+static int
+r_reflexive(struct SN_env * z)
+{
+   int         among_var;
+
+   z->ket = z->c;              /* [, line 129 */
+   among_var = find_among_b(z, a_3, 2);        /* substring, line 129 */
+   if (!(among_var))
+       return 0;
+   z->bra = z->c;              /* ], line 129 */
+   switch (among_var)
+   {
+       case 0:
+           return 0;
+       case 1:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 132 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+   }
+   return 1;
 }
 
-static int r_verb(struct SN_env * z) {
-    int among_var;
-    z->ket = z->c; /* [, line 137 */
-    among_var = find_among_b(z, a_4, 46); /* substring, line 137 */
-    if (!(among_var)) return 0;
-    z->bra = z->c; /* ], line 137 */
-    switch(among_var) {
-        case 0: return 0;
-        case 1:
-            {   int m = z->l - z->c; (void) m; /* or, line 143 */
-                if (!(eq_s_b(z, 2, s_4))) goto lab1;
-                goto lab0;
-            lab1:
-                z->c = z->l - m;
-                if (!(eq_s_b(z, 2, s_5))) return 0;
-            }
-        lab0:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 143 */
-                if (ret < 0) return ret;
-            }
-            break;
-        case 2:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 151 */
-                if (ret < 0) return ret;
-            }
-            break;
-    }
-    return 1;
+static int
+r_verb(struct SN_env * z)
+{
+   int         among_var;
+
+   z->ket = z->c;              /* [, line 137 */
+   among_var = find_among_b(z, a_4, 46);       /* substring, line 137 */
+   if (!(among_var))
+       return 0;
+   z->bra = z->c;              /* ], line 137 */
+   switch (among_var)
+   {
+       case 0:
+           return 0;
+       case 1:
+           {
+               int         m = z->l - z->c;
+
+               (void) m;       /* or, line 143 */
+               if (!(eq_s_b(z, 2, s_4)))
+                   goto lab1;
+               goto lab0;
+       lab1:
+               z->c = z->l - m;
+               if (!(eq_s_b(z, 2, s_5)))
+                   return 0;
+           }
+   lab0:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 143 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+       case 2:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 151 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+   }
+   return 1;
 }
 
-static int r_noun(struct SN_env * z) {
-    int among_var;
-    z->ket = z->c; /* [, line 160 */
-    among_var = find_among_b(z, a_5, 36); /* substring, line 160 */
-    if (!(among_var)) return 0;
-    z->bra = z->c; /* ], line 160 */
-    switch(among_var) {
-        case 0: return 0;
-        case 1:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 167 */
-                if (ret < 0) return ret;
-            }
-            break;
-    }
-    return 1;
+static int
+r_noun(struct SN_env * z)
+{
+   int         among_var;
+
+   z->ket = z->c;              /* [, line 160 */
+   among_var = find_among_b(z, a_5, 36);       /* substring, line 160 */
+   if (!(among_var))
+       return 0;
+   z->bra = z->c;              /* ], line 160 */
+   switch (among_var)
+   {
+       case 0:
+           return 0;
+       case 1:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 167 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+   }
+   return 1;
 }
 
-static int r_derivational(struct SN_env * z) {
-    int among_var;
-    z->ket = z->c; /* [, line 176 */
-    among_var = find_among_b(z, a_6, 2); /* substring, line 176 */
-    if (!(among_var)) return 0;
-    z->bra = z->c; /* ], line 176 */
-    {   int ret = r_R2(z);
-        if (ret == 0) return 0; /* call R2, line 176 */
-        if (ret < 0) return ret;
-    }
-    switch(among_var) {
-        case 0: return 0;
-        case 1:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 179 */
-                if (ret < 0) return ret;
-            }
-            break;
-    }
-    return 1;
+static int
+r_derivational(struct SN_env * z)
+{
+   int         among_var;
+
+   z->ket = z->c;              /* [, line 176 */
+   among_var = find_among_b(z, a_6, 2);        /* substring, line 176 */
+   if (!(among_var))
+       return 0;
+   z->bra = z->c;              /* ], line 176 */
+   {
+       int         ret = r_R2(z);
+
+       if (ret == 0)
+           return 0;           /* call R2, line 176 */
+       if (ret < 0)
+           return ret;
+   }
+   switch (among_var)
+   {
+       case 0:
+           return 0;
+       case 1:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 179 */
+               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 184 */
-    among_var = find_among_b(z, a_7, 4); /* substring, line 184 */
-    if (!(among_var)) return 0;
-    z->bra = z->c; /* ], line 184 */
-    switch(among_var) {
-        case 0: return 0;
-        case 1:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 188 */
-                if (ret < 0) return ret;
-            }
-            z->ket = z->c; /* [, line 189 */
-            if (!(eq_s_b(z, 2, s_6))) return 0;
-            z->bra = z->c; /* ], line 189 */
-            if (!(eq_s_b(z, 2, s_7))) return 0;
-            {   int ret;
-                ret = slice_del(z); /* delete, line 189 */
-                if (ret < 0) return ret;
-            }
-            break;
-        case 2:
-            if (!(eq_s_b(z, 2, s_8))) return 0;
-            {   int ret;
-                ret = slice_del(z); /* delete, line 192 */
-                if (ret < 0) return ret;
-            }
-            break;
-        case 3:
-            {   int ret;
-                ret = slice_del(z); /* delete, line 194 */
-                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 184 */
+   among_var = find_among_b(z, a_7, 4);        /* substring, line 184 */
+   if (!(among_var))
+       return 0;
+   z->bra = z->c;              /* ], line 184 */
+   switch (among_var)
+   {
+       case 0:
+           return 0;
+       case 1:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 188 */
+               if (ret < 0)
+                   return ret;
+           }
+           z->ket = z->c;      /* [, line 189 */
+           if (!(eq_s_b(z, 2, s_6)))
+               return 0;
+           z->bra = z->c;      /* ], line 189 */
+           if (!(eq_s_b(z, 2, s_7)))
+               return 0;
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 189 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+       case 2:
+           if (!(eq_s_b(z, 2, s_8)))
+               return 0;
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 192 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+       case 3:
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 194 */
+               if (ret < 0)
+                   return ret;
+           }
+           break;
+   }
+   return 1;
 }
 
-extern int russian_UTF_8_stem(struct SN_env * z) {
-    {   int c = z->c; /* do, line 201 */
-        {   int ret = r_mark_regions(z);
-            if (ret == 0) goto lab0; /* call mark_regions, line 201 */
-            if (ret < 0) return ret;
-        }
-    lab0:
-        z->c = c;
-    }
-    z->lb = z->c; z->c = z->l; /* backwards, line 202 */
-
-    {   int m3; /* setlimit, line 202 */
-        int m = z->l - z->c; (void) m;
-        if (z->c < z->I[0]) return 0;
-        z->c = z->I[0]; /* tomark, line 202 */
-        m3 = z->lb; z->lb = z->c;
-        z->c = z->l - m;
-        {   int m = z->l - z->c; (void) m; /* do, line 203 */
-            {   int m = z->l - z->c; (void) m; /* or, line 204 */
-                {   int ret = r_perfective_gerund(z);
-                    if (ret == 0) goto lab3; /* call perfective_gerund, line 204 */
-                    if (ret < 0) return ret;
-                }
-                goto lab2;
-            lab3:
-                z->c = z->l - m;
-                {   int m = z->l - z->c; (void) m; /* try, line 205 */
-                    {   int ret = r_reflexive(z);
-                        if (ret == 0) { z->c = z->l - m; goto lab4; } /* call reflexive, line 205 */
-                        if (ret < 0) return ret;
-                    }
-                lab4:
-                    ;
-                }
-                {   int m = z->l - z->c; (void) m; /* or, line 206 */
-                    {   int ret = r_adjectival(z);
-                        if (ret == 0) goto lab6; /* call adjectival, line 206 */
-                        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 206 */
-                        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 206 */
-                        if (ret < 0) return ret;
-                    }
-                }
-            lab5:
-                ;
-            }
-        lab2:
-        lab1:
-            z->c = z->l - m;
-        }
-        {   int m = z->l - z->c; (void) m; /* try, line 209 */
-            z->ket = z->c; /* [, line 209 */
-            if (!(eq_s_b(z, 2, s_9))) { z->c = z->l - m; goto lab8; }
-            z->bra = z->c; /* ], line 209 */
-            {   int ret;
-                ret = slice_del(z); /* delete, line 209 */
-                if (ret < 0) return ret;
-            }
-        lab8:
-            ;
-        }
-        {   int m = z->l - z->c; (void) m; /* do, line 212 */
-            {   int ret = r_derivational(z);
-                if (ret == 0) goto lab9; /* call derivational, line 212 */
-                if (ret < 0) return ret;
-            }
-        lab9:
-            z->c = z->l - m;
-        }
-        {   int m = z->l - z->c; (void) m; /* do, line 213 */
-            {   int ret = r_tidy_up(z);
-                if (ret == 0) goto lab10; /* call tidy_up, line 213 */
-                if (ret < 0) return ret;
-            }
-        lab10:
-            z->c = z->l - m;
-        }
-        z->lb = m3;
-    }
-    z->c = z->lb;
-    return 1;
+extern int
+russian_UTF_8_stem(struct SN_env * z)
+{
+   {
+       int         c = z->c;   /* do, line 201 */
+
+       {
+           int         ret = r_mark_regions(z);
+
+           if (ret == 0)
+               goto lab0;      /* call mark_regions, line 201 */
+           if (ret < 0)
+               return ret;
+       }
+lab0:
+       z->c = c;
+   }
+   z->lb = z->c;
+   z->c = z->l;                /* backwards, line 202 */
+
+   {
+       int         m3;         /* setlimit, line 202 */
+       int         m = z->l - z->c;
+
+       (void) m;
+       if (z->c < z->I[0])
+           return 0;
+       z->c = z->I[0];         /* tomark, line 202 */
+       m3 = z->lb;
+       z->lb = z->c;
+       z->c = z->l - m;
+       {
+           int         m = z->l - z->c;
+
+           (void) m;           /* do, line 203 */
+           {
+               int         m = z->l - z->c;
+
+               (void) m;       /* or, line 204 */
+               {
+                   int         ret = r_perfective_gerund(z);
+
+                   if (ret == 0)
+                       goto lab3;      /* call perfective_gerund, line 204 */
+                   if (ret < 0)
+                       return ret;
+               }
+               goto lab2;
+       lab3:
+               z->c = z->l - m;
+               {
+                   int         m = z->l - z->c;
+
+                   (void) m;   /* try, line 205 */
+                   {
+                       int         ret = r_reflexive(z);
+
+                       if (ret == 0)
+                       {
+                           z->c = z->l - m;
+                           goto lab4;
+                       }       /* call reflexive, line 205 */
+                       if (ret < 0)
+                           return ret;
+                   }
+           lab4:
+                   ;
+               }
+               {
+                   int         m = z->l - z->c;
+
+                   (void) m;   /* or, line 206 */
+                   {
+                       int         ret = r_adjectival(z);
+
+                       if (ret == 0)
+                           goto lab6;  /* call adjectival, line 206 */
+                       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 206 */
+                       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 206 */
+                       if (ret < 0)
+                           return ret;
+                   }
+               }
+       lab5:
+               ;
+           }
+   lab2:
+   lab1:
+           z->c = z->l - m;
+       }
+       {
+           int         m = z->l - z->c;
+
+           (void) m;           /* try, line 209 */
+           z->ket = z->c;      /* [, line 209 */
+           if (!(eq_s_b(z, 2, s_9)))
+           {
+               z->c = z->l - m;
+               goto lab8;
+           }
+           z->bra = z->c;      /* ], line 209 */
+           {
+               int         ret;
+
+               ret = slice_del(z);     /* delete, line 209 */
+               if (ret < 0)
+                   return ret;
+           }
+   lab8:
+           ;
+       }
+       {
+           int         m = z->l - z->c;
+
+           (void) m;           /* do, line 212 */
+           {
+               int         ret = r_derivational(z);
+
+               if (ret == 0)
+                   goto lab9;  /* call derivational, line 212 */
+               if (ret < 0)
+                   return ret;
+           }
+   lab9:
+           z->c = z->l - m;
+       }
+       {
+           int         m = z->l - z->c;
+
+           (void) m;           /* do, line 213 */
+           {
+               int         ret = r_tidy_up(z);
+
+               if (ret == 0)
+                   goto lab10; /* call tidy_up, line 213 */
+               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_UTF_8_create_env(void) { return SN_create_env(0, 2, 0); }
-
-extern void russian_UTF_8_close_env(struct SN_env * z) { SN_close_env(z); }
+extern struct SN_env *russian_UTF_8_create_env(void)
+{
+   return SN_create_env(0, 2, 0);
+}
 
+extern void russian_UTF_8_close_env(struct SN_env * z)
+{
+   SN_close_env(z);
+}
index 4ef774ddccbb38590bbcd54e6f5f8dc7f28010d0..0beb0b9719a92ae8dad05fe9c87f3087ef38a106 100644 (file)
@@ -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_UTF_8_create_env(void);
-extern void russian_UTF_8_close_env(struct SN_env * z);
+   extern struct SN_env *russian_UTF_8_create_env(void);
+   extern void russian_UTF_8_close_env(struct SN_env * z);
 
-extern int russian_UTF_8_stem(struct SN_env * z);
+   extern int  russian_UTF_8_stem(struct SN_env * z);
 
 #ifdef __cplusplus
 }
-#endif
 
+#endif
index e6141f83903cd7795de9eadf12c259e9edc03e49..73db8abba69a16f9bce6b404053668fa44c0eb12 100644 (file)
@@ -48,7 +48,7 @@ readstoplist(text *in, StopList * s)
        while (fgets(buf, STOPBUFLEN, hin))
        {
            buf[strlen(buf) - 1] = '\0';
-           pg_verifymbstr( buf, strlen(buf), false );  
+           pg_verifymbstr(buf, strlen(buf), false);
            lowerstr(buf);
            if (*buf == '\0')
                continue;
index d0e18916682629182a3184106c6474f76c67afa8..0526ce9879c29a9cce355dc4627f47cc9b55e2e9 100644 (file)
@@ -301,14 +301,15 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen)
 
    LexizeInit(&ldata, cfg);
 
-   do {
+   do
+   {
        type = DatumGetInt32(FunctionCall3(
-                                              &(prsobj->getlexeme_info),
-                                              PointerGetDatum(prsobj->prs),
-                                              PointerGetDatum(&lemm),
+                                          &(prsobj->getlexeme_info),
+                                          PointerGetDatum(prsobj->prs),
+                                          PointerGetDatum(&lemm),
                                           PointerGetDatum(&lenlemm)));
 
-       if (type>0 && lenlemm >= MAXSTRLEN)
+       if (type > 0 && lenlemm >= MAXSTRLEN)
        {
 #ifdef IGNORE_LONGLEXEME
            ereport(NOTICE,
@@ -324,9 +325,9 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen)
 
        LexizeAddLemm(&ldata, type, lemm, lenlemm);
 
-       while(  (norms = LexizeExec(&ldata, NULL)) != NULL )
+       while ((norms = LexizeExec(&ldata, NULL)) != NULL)
        {
-           TSLexeme *ptr = norms;
+           TSLexeme   *ptr = norms;
 
            prs->pos++;         /* set pos */
 
@@ -338,7 +339,7 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen)
                    prs->words = (TSWORD *) repalloc((void *) prs->words, prs->lenwords * sizeof(TSWORD));
                }
 
-               if ( ptr->flags & TSL_ADDPOS )
+               if (ptr->flags & TSL_ADDPOS)
                    prs->pos++;
                prs->words[prs->curwords].len = strlen(ptr->lexeme);
                prs->words[prs->curwords].word = ptr->lexeme;
@@ -349,8 +350,8 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen)
                prs->curwords++;
            }
            pfree(norms);
-   }
-   } while(type>0);
+       }
+   } while (type > 0);
 
    FunctionCall1(
                  &(prsobj->end_info),
@@ -407,30 +408,35 @@ hlfinditem(HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int buflen)
 }
 
 static void
-addHLParsedLex(HLPRSTEXT *prs, QUERYTYPE * query, ParsedLex *lexs, TSLexeme *norms) {
-   ParsedLex   *tmplexs;
-   TSLexeme *ptr;
+addHLParsedLex(HLPRSTEXT * prs, QUERYTYPE * query, ParsedLex * lexs, TSLexeme * norms)
+{
+   ParsedLex  *tmplexs;
+   TSLexeme   *ptr;
 
-   while( lexs ) {
-       
-       if ( lexs->type > 0 ) 
+   while (lexs)
+   {
+
+       if (lexs->type > 0)
            hladdword(prs, lexs->lemm, lexs->lenlemm, lexs->type);
 
        ptr = norms;
-       while( ptr && ptr->lexeme ) {
+       while (ptr && ptr->lexeme)
+       {
            hlfinditem(prs, query, ptr->lexeme, strlen(ptr->lexeme));
            ptr++;
        }
 
        tmplexs = lexs->next;
-       pfree( lexs );
+       pfree(lexs);
        lexs = tmplexs;
    }
 
-   if ( norms ) {
+   if (norms)
+   {
        ptr = norms;
-       while( ptr->lexeme ) {
-           pfree( ptr->lexeme );
+       while (ptr->lexeme)
+       {
+           pfree(ptr->lexeme);
            ptr++;
        }
        pfree(norms);
@@ -445,8 +451,8 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4
    char       *lemm = NULL;
    WParserInfo *prsobj = findprs(cfg->prs_id);
    LexizeData  ldata;
-   TSLexeme    *norms;
-   ParsedLex   *lexs;
+   TSLexeme   *norms;
+   ParsedLex  *lexs;
 
    prsobj->prs = (void *) DatumGetPointer(
                                           FunctionCall2(
@@ -458,14 +464,15 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4
 
    LexizeInit(&ldata, cfg);
 
-   do {
+   do
+   {
        type = DatumGetInt32(FunctionCall3(
-                                              &(prsobj->getlexeme_info),
-                                              PointerGetDatum(prsobj->prs),
-                                              PointerGetDatum(&lemm),
-                                   PointerGetDatum(&lenlemm)));
+                                          &(prsobj->getlexeme_info),
+                                          PointerGetDatum(prsobj->prs),
+                                          PointerGetDatum(&lemm),
+                                          PointerGetDatum(&lenlemm)));
 
-       if (type>0 && lenlemm >= MAXSTRLEN)
+       if (type > 0 && lenlemm >= MAXSTRLEN)
        {
 #ifdef IGNORE_LONGLEXEME
            ereport(NOTICE,
@@ -481,14 +488,15 @@ hlparsetext(TSCfgInfo * cfg, HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int4
 
        LexizeAddLemm(&ldata, type, lemm, lenlemm);
 
-       do {
-           if ( (norms = LexizeExec(&ldata,&lexs)) != NULL ) 
+       do
+       {
+           if ((norms = LexizeExec(&ldata, &lexs)) != NULL)
                addHLParsedLex(prs, query, lexs, norms);
-           else 
+           else
                addHLParsedLex(prs, query, lexs, NULL);
-       } while( norms );
+       } while (norms);
 
-   } while( type>0 );
+   } while (type > 0);
 
    FunctionCall1(
                  &(prsobj->end_info),
index c90848c6fdfd8f82fff4d68fc37416a9b7de3649..f2e4904eb7b36432fdf4271977a45edbdefeb84b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * lexize stream of lexemes 
+ * lexize stream of lexemes
  * Teodor Sigaev 
  */
 #include "postgres.h"
 #include "dict.h"
 
 void
-LexizeInit(LexizeData *ld, TSCfgInfo *cfg) {
+LexizeInit(LexizeData * ld, TSCfgInfo * cfg)
+{
    ld->cfg = cfg;
    ld->curDictId = InvalidOid;
    ld->posDict = 0;
    ld->towork.head = ld->towork.tail = ld->curSub = NULL;
    ld->waste.head = ld->waste.tail = NULL;
-   ld->lastRes=NULL;
-   ld->tmpRes=NULL;
+   ld->lastRes = NULL;
+   ld->tmpRes = NULL;
 }
 
 static void
-LPLAddTail(ListParsedLex *list, ParsedLex *newpl) {
-   if ( list->tail ) {
+LPLAddTail(ListParsedLex * list, ParsedLex * newpl)
+{
+   if (list->tail)
+   {
        list->tail->next = newpl;
        list->tail = newpl;
-   } else
+   }
+   else
        list->head = list->tail = newpl;
    newpl->next = NULL;
 }
 
-static ParsedLex*
-LPLRemoveHead(ListParsedLex *list) {
-   ParsedLex *res = list->head;
+static ParsedLex *
+LPLRemoveHead(ListParsedLex * list)
+{
+   ParsedLex  *res = list->head;
 
-   if ( list->head ) 
+   if (list->head)
        list->head = list->head->next;
 
-   if ( list->head == NULL )
+   if (list->head == NULL)
        list->tail = NULL;
 
    return res;
@@ -46,10 +51,11 @@ LPLRemoveHead(ListParsedLex *list) {
 
 
 void
-LexizeAddLemm(LexizeData *ld, int type, char *lemm, int lenlemm) {
-   ParsedLex *newpl = (ParsedLex*)palloc( sizeof(ParsedLex) );
+LexizeAddLemm(LexizeData * ld, int type, char *lemm, int lenlemm)
+{
+   ParsedLex  *newpl = (ParsedLex *) palloc(sizeof(ParsedLex));
 
-   newpl = (ParsedLex*)palloc( sizeof(ParsedLex) );
+   newpl = (ParsedLex *) palloc(sizeof(ParsedLex));
    newpl->type = type;
    newpl->lemm = lemm;
    newpl->lenlemm = lenlemm;
@@ -58,20 +64,27 @@ LexizeAddLemm(LexizeData *ld, int type, char *lemm, int lenlemm) {
 }
 
 static void
-RemoveHead(LexizeData *ld) {
+RemoveHead(LexizeData * ld)
+{
    LPLAddTail(&ld->waste, LPLRemoveHead(&ld->towork));
 
    ld->posDict = 0;
 }
 
 static void
-setCorrLex(LexizeData *ld, ParsedLex **correspondLexem) {
-   if ( correspondLexem ) {
+setCorrLex(LexizeData * ld, ParsedLex ** correspondLexem)
+{
+   if (correspondLexem)
+   {
        *correspondLexem = ld->waste.head;
-   } else {
-       ParsedLex   *tmp, *ptr = ld->waste.head;
+   }
+   else
+   {
+       ParsedLex  *tmp,
+                  *ptr = ld->waste.head;
 
-       while(ptr) {
+       while (ptr)
+       {
            tmp = ptr->next;
            pfree(ptr);
            ptr = tmp;
@@ -81,11 +94,14 @@ setCorrLex(LexizeData *ld, ParsedLex **correspondLexem) {
 }
 
 static void
-moveToWaste(LexizeData *ld, ParsedLex *stop) {
-   bool    go = true;
-
-   while( ld->towork.head && go) {
-       if (ld->towork.head == stop) {
+moveToWaste(LexizeData * ld, ParsedLex * stop)
+{
+   bool        go = true;
+
+   while (ld->towork.head && go)
+   {
+       if (ld->towork.head == stop)
+       {
            ld->curSub = stop->next;
            go = false;
        }
@@ -94,110 +110,124 @@ moveToWaste(LexizeData *ld, ParsedLex *stop) {
 }
 
 static void
-setNewTmpRes(LexizeData *ld, ParsedLex *lex, TSLexeme *res) {
-   if ( ld->tmpRes ) {
-       TSLexeme    *ptr;
-       for( ptr=ld->tmpRes; ptr->lexeme; ptr++ ) 
-           pfree( ptr->lexeme );
-       pfree( ld->tmpRes );
+setNewTmpRes(LexizeData * ld, ParsedLex * lex, TSLexeme * res)
+{
+   if (ld->tmpRes)
+   {
+       TSLexeme   *ptr;
+
+       for (ptr = ld->tmpRes; ptr->lexeme; ptr++)
+           pfree(ptr->lexeme);
+       pfree(ld->tmpRes);
    }
    ld->tmpRes = res;
    ld->lastRes = lex;
 }
 
-TSLexeme*
-LexizeExec(LexizeData *ld, ParsedLex **correspondLexem) {
-   int i;
-   ListDictionary  *map;
-   DictInfo *dict;
-   TSLexeme    *res;
-
-   if ( ld->curDictId == InvalidOid ) {
-       /* 
-        * usial mode: dictionary wants only one word,
-        * but we should keep in mind that we should go through
-        * all stack
+TSLexeme *
+LexizeExec(LexizeData * ld, ParsedLex ** correspondLexem)
+{
+   int         i;
+   ListDictionary *map;
+   DictInfo   *dict;
+   TSLexeme   *res;
+
+   if (ld->curDictId == InvalidOid)
+   {
+       /*
+        * usial mode: dictionary wants only one word, but we should keep in
+        * mind that we should go through all stack
         */
 
-       while( ld->towork.head ) {
-           ParsedLex   *curVal = ld->towork.head;
+       while (ld->towork.head)
+       {
+           ParsedLex  *curVal = ld->towork.head;
 
            map = ld->cfg->map + curVal->type;
 
-           if (curVal->type == 0 || curVal->type >= ld->cfg->len || map->len == 0 ) {  
+           if (curVal->type == 0 || curVal->type >= ld->cfg->len || map->len == 0)
+           {
                /* skip this type of lexeme */
                RemoveHead(ld);
                continue;
            }
 
-           for (i = ld->posDict; i < map->len; i++) {
+           for (i = ld->posDict; i < map->len; i++)
+           {
                dict = finddict(DatumGetObjectId(map->dict_id[i]));
 
                ld->dictState.isend = ld->dictState.getnext = false;
                ld->dictState.private = NULL;
-               res = (TSLexeme *) DatumGetPointer( FunctionCall4(
-                                                   &(dict->lexize_info),
-                                                   PointerGetDatum(dict->dictionary),
-                                                   PointerGetDatum(curVal->lemm),
-                                                   Int32GetDatum(curVal->lenlemm),
-                                                   PointerGetDatum(&ld->dictState)
-                                        ));
-
-               if ( ld->dictState.getnext ) {
-                   /* 
-                    * dictinary wants next word, so setup and store
-                    * current position and go to multiword  mode
+               res = (TSLexeme *) DatumGetPointer(FunctionCall4(
+                                                       &(dict->lexize_info),
+                                          PointerGetDatum(dict->dictionary),
+                                              PointerGetDatum(curVal->lemm),
+                                             Int32GetDatum(curVal->lenlemm),
+                                             PointerGetDatum(&ld->dictState)
+                                                                ));
+
+               if (ld->dictState.getnext)
+               {
+                   /*
+                    * dictinary wants next word, so setup and store current
+                    * position and go to multiword  mode
                     */
-                    
+
                    ld->curDictId = DatumGetObjectId(map->dict_id[i]);
-                   ld->posDict = i+1;
+                   ld->posDict = i + 1;
                    ld->curSub = curVal->next;
-                   if ( res )
+                   if (res)
                        setNewTmpRes(ld, curVal, res);
                    return LexizeExec(ld, correspondLexem);
                }
 
-               if (!res)           /* dictionary doesn't know this lexeme */
+               if (!res)       /* dictionary doesn't know this lexeme */
                    continue;
-               
+
                RemoveHead(ld);
                setCorrLex(ld, correspondLexem);
                return res;
            }
 
            RemoveHead(ld);
-       } 
-   } else { /* curDictId is valid */
+       }
+   }
+   else
+   {                           /* curDictId is valid */
        dict = finddict(ld->curDictId);
-       
+
        /*
         * Dictionary ld->curDictId asks  us about following words
         */
 
-       while( ld->curSub ) {
-           ParsedLex   *curVal = ld->curSub;
+       while (ld->curSub)
+       {
+           ParsedLex  *curVal = ld->curSub;
 
            map = ld->cfg->map + curVal->type;
 
-           if (curVal->type != 0) {
-               bool dictExists = false;
+           if (curVal->type != 0)
+           {
+               bool        dictExists = false;
 
-               if (curVal->type >= ld->cfg->len || map->len == 0 ) {   
+               if (curVal->type >= ld->cfg->len || map->len == 0)
+               {
                    /* skip this type of lexeme */
                    ld->curSub = curVal->next;
                    continue;
                }
 
                /*
-                * We should be sure that current type of lexeme is recognized by
-                * our dictinonary: we just check is it exist in 
-                * list of dictionaries ?
+                * We should be sure that current type of lexeme is recognized
+                * by our dictinonary: we just check is it exist in list of
+                * dictionaries ?
                 */
-               for(i=0;i < map->len && !dictExists; i++) 
-                   if ( ld->curDictId == DatumGetObjectId(map->dict_id[i]) )
+               for (i = 0; i < map->len && !dictExists; i++)
+                   if (ld->curDictId == DatumGetObjectId(map->dict_id[i]))
                        dictExists = true;
 
-               if ( !dictExists ) {
+               if (!dictExists)
+               {
                    /*
                     * Dictionary can't work with current tpe of lexeme,
                     * return to basic mode and redo all stored lexemes
@@ -205,38 +235,43 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem) {
                    ld->curDictId = InvalidOid;
                    return LexizeExec(ld, correspondLexem);
                }
-           } 
-   
-           ld->dictState.isend = (curVal->type==0) ? true : false;
+           }
+
+           ld->dictState.isend = (curVal->type == 0) ? true : false;
            ld->dictState.getnext = false;
 
-           res = (TSLexeme *) DatumGetPointer( FunctionCall4(
-                                               &(dict->lexize_info),
-                                               PointerGetDatum(dict->dictionary),
-                                               PointerGetDatum(curVal->lemm),
-                                               Int32GetDatum(curVal->lenlemm),
-                                               PointerGetDatum(&ld->dictState)
-                                        ));
+           res = (TSLexeme *) DatumGetPointer(FunctionCall4(
+                                                       &(dict->lexize_info),
+                                          PointerGetDatum(dict->dictionary),
+                                              PointerGetDatum(curVal->lemm),
+                                             Int32GetDatum(curVal->lenlemm),
+                                             PointerGetDatum(&ld->dictState)
+                                                            ));
 
-           if ( ld->dictState.getnext ) {
+           if (ld->dictState.getnext)
+           {
                /* Dictionary wants one more */
                ld->curSub = curVal->next;
-               if ( res )
+               if (res)
                    setNewTmpRes(ld, curVal, res);
                continue;
            }
 
-           if ( res || ld->tmpRes ) {
+           if (res || ld->tmpRes)
+           {
                /*
-                * Dictionary normalizes lexemes,
-                * so we remove from stack all used lexemes ,
-                * return to basic mode and redo end of stack (if it exists)
+                * Dictionary normalizes lexemes, so we remove from stack all
+                * used lexemes , return to basic mode and redo end of stack
+                * (if it exists)
                 */
-               if ( res ) {
-                   moveToWaste( ld, ld->curSub );
-               } else {
+               if (res)
+               {
+                   moveToWaste(ld, ld->curSub);
+               }
+               else
+               {
                    res = ld->tmpRes;
-                   moveToWaste( ld, ld->lastRes );
+                   moveToWaste(ld, ld->lastRes);
                }
 
                /* reset to initial state */
@@ -248,14 +283,15 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem) {
                return res;
            }
 
-           /* Dict don't want next lexem and didn't recognize anything,
-              redo from ld->towork.head */
+           /*
+            * Dict don't want next lexem and didn't recognize anything, redo
+            * from ld->towork.head
+            */
            ld->curDictId = InvalidOid;
            return LexizeExec(ld, correspondLexem);
-       }   
+       }
    }
 
    setCorrLex(ld, correspondLexem);
    return NULL;
 }
-
index e8be69f45860bca3df6068c8440cf3ec4415237d..203c977e4eab3006ddf7cb679d9f57fcdfb7640e 100644 (file)
@@ -70,54 +70,59 @@ char2wchar(wchar_t *to, const char *from, size_t len)
 
    return mbstowcs(to, from, len);
 }
-
-#endif /* WIN32 */
+#endif   /* WIN32 */
 
 int
-_t_isalpha( const char *ptr ) {
-   wchar_t character;
+_t_isalpha(const char *ptr)
+{
+   wchar_t     character;
 
    char2wchar(&character, ptr, 1);
 
-   return iswalpha( (wint_t)character );   
+   return iswalpha((wint_t) character);
 }
 
 int
-_t_isprint( const char *ptr ) {
-   wchar_t character;
+_t_isprint(const char *ptr)
+{
+   wchar_t     character;
 
    char2wchar(&character, ptr, 1);
 
-   return iswprint( (wint_t)character );   
+   return iswprint((wint_t) character);
 }
-
-#endif /* TS_USE_WIDE */
+#endif   /* TS_USE_WIDE */
 
 char *
 lowerstr(char *str)
 {
-   char       *ptr = str;
+   char       *ptr = str;
 
 #ifdef TS_USE_WIDE
+
    /*
     * 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. From
     * backend/utils/adt/oracle_compat.c Teodor
     */
-   if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c()) {
-           wchar_t *wstr, *wptr;
-           int len = strlen(str);
-
-           wptr = wstr = (wchar_t *) palloc(sizeof(wchar_t) * (len+1));
-           char2wchar(wstr, str, len+1);
-           while (*wptr) {
-               *wptr = towlower((wint_t) *wptr);
-               wptr++;
-           }
-           wchar2char(str, wstr, len);
-           pfree( wstr );
-   } else
+   if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c())
+   {
+       wchar_t    *wstr,
+                  *wptr;
+       int         len = strlen(str);
+
+       wptr = wstr = (wchar_t *) palloc(sizeof(wchar_t) * (len + 1));
+       char2wchar(wstr, str, len + 1);
+       while (*wptr)
+       {
+           *wptr = towlower((wint_t) *wptr);
+           wptr++;
+       }
+       wchar2char(str, wstr, len);
+       pfree(wstr);
+   }
+   else
 #endif
        while (*ptr)
        {
@@ -126,4 +131,3 @@ lowerstr(char *str)
        }
    return str;
 }
-
index 2c0c52b23f9005a928183bce6029065c73bb83f6..e2e22481370162bed9789b5acfec480302eb44c9 100644 (file)
 
 size_t     wchar2char(char *to, const wchar_t *from, size_t len);
 size_t     char2wchar(wchar_t *to, const char *from, size_t len);
-#else    /* WIN32 */
+#else                          /* WIN32 */
 
 /* correct mbstowcs */
 #define char2wchar mbstowcs
 #define wchar2char wcstombs
 #endif   /* WIN32 */
 
-#define    t_isdigit(x)    ( pg_mblen(x)==1 && isdigit( TOUCHAR(x) ) )
-#define    t_isspace(x)    ( pg_mblen(x)==1 && isspace( TOUCHAR(x) ) )
-extern int _t_isalpha( const char *ptr );
-#define    t_isalpha(x)    ( (pg_mblen(x)==1) ? isalpha( TOUCHAR(x) ) : _t_isalpha(x) )
-extern int _t_isprint( const char *ptr );
-#define    t_isprint(x)    ( (pg_mblen(x)==1) ? isprint( TOUCHAR(x) ) : _t_isprint(x) )
+#define t_isdigit(x)   ( pg_mblen(x)==1 && isdigit( TOUCHAR(x) ) )
+#define t_isspace(x)   ( pg_mblen(x)==1 && isspace( TOUCHAR(x) ) )
+extern int _t_isalpha(const char *ptr);
+
+#define t_isalpha(x)   ( (pg_mblen(x)==1) ? isalpha( TOUCHAR(x) ) : _t_isalpha(x) )
+extern int _t_isprint(const char *ptr);
+
+#define t_isprint(x)   ( (pg_mblen(x)==1) ? isprint( TOUCHAR(x) ) : _t_isprint(x) )
 /*
- * t_iseq() should be called only for ASCII symbols 
+ * t_iseq() should be called only for ASCII symbols
  */
-#define t_iseq(x,c)    ( (pg_mblen(x)==1) ? ( TOUCHAR(x) == ((unsigned char)(c)) ) : false ) 
+#define t_iseq(x,c) ( (pg_mblen(x)==1) ? ( TOUCHAR(x) == ((unsigned char)(c)) ) : false )
 
 #define COPYCHAR(d,s)  do {                \
    int lll = pg_mblen( s );            \
                            \
-   while( lll-- )                  \
+   while( lll-- )                  \
        TOUCHAR((d)+lll) = TOUCHAR((s)+lll);    \
 } while(0)
 
-       
-#else /* not def TS_USE_WIDE */
-
-#define t_isdigit(x)   isdigit( TOUCHAR(x) )
-#define t_isspace(x)   isspace( TOUCHAR(x) )
-#define t_isalpha(x)   isalpha( TOUCHAR(x) )
-#define t_isprint(x)   isprint( TOUCHAR(x) )
-#define t_iseq(x,c)    ( TOUCHAR(x) == ((unsigned char)(c)) )
+#else                          /* not def TS_USE_WIDE */
 
-#define COPYCHAR(d,s)  TOUCHAR(d) = TOUCHAR(s) 
+#define t_isdigit(x)   isdigit( TOUCHAR(x) )
+#define t_isspace(x)   isspace( TOUCHAR(x) )
+#define t_isalpha(x)   isalpha( TOUCHAR(x) )
+#define t_isprint(x)   isprint( TOUCHAR(x) )
+#define t_iseq(x,c) ( TOUCHAR(x) == ((unsigned char)(c)) )
 
+#define COPYCHAR(d,s)  TOUCHAR(d) = TOUCHAR(s)
 #endif
 
-charlowerstr(char *str);
+char      *lowerstr(char *str);
 
 #endif   /* __TSLOCALE_H__ */
index 3a90fe5a192db9f8241bdd18655e4ab3f6348e12..17d1ccb050558cb7a50e5517f06214b9ceab8ffb 100644 (file)
@@ -477,7 +477,8 @@ ts_stat_sql(text *txt, text *ws)
        buf = VARDATA(ws);
        while (buf - VARDATA(ws) < VARSIZE(ws) - VARHDRSZ)
        {
-           if ( pg_mblen(buf) == 1 ) {
+           if (pg_mblen(buf) == 1)
+           {
                switch (*buf)
                {
                    case 'A':
@@ -500,7 +501,7 @@ ts_stat_sql(text *txt, text *ws)
                        stat->weight |= 0;
                }
            }
-           buf+=pg_mblen(buf);
+           buf += pg_mblen(buf);
        }
    }
 
index 7e8dd8a772bb0960eb602dee71a901362374e265..a4a9d57d64556017a594b1950b6e780832cc8ed7 100644 (file)
@@ -165,13 +165,13 @@ uniqueentry(WordEntryIN * a, int4 l, char *buf, int4 *outbuflen)
 }
 
 #define WAITWORD       1
-#define WAITENDWORD    2
+#define WAITENDWORD        2
 #define WAITNEXTCHAR   3
 #define WAITENDCMPLX   4
-#define WAITPOSINFO    5
+#define WAITPOSINFO        5
 #define INPOSINFO      6
 #define WAITPOSDELIM   7
-#define    WAITCHARCMPLX   8
+#define WAITCHARCMPLX  8
 
 #define RESIZEPRSBUF \
 do { \
@@ -200,9 +200,9 @@ gettoken_tsvector(TI_IN_STATE * state)
        {
            if (*(state->prsbuf) == '\0')
                return 0;
-           else if ( t_iseq(state->prsbuf, '\'') )
+           else if (t_iseq(state->prsbuf, '\''))
                state->state = WAITENDCMPLX;
-           else if ( t_iseq(state->prsbuf, '\\') )
+           else if (t_iseq(state->prsbuf, '\\'))
            {
                state->state = WAITNEXTCHAR;
                oldstate = WAITENDWORD;
@@ -214,7 +214,7 @@ gettoken_tsvector(TI_IN_STATE * state)
            else if (!t_isspace(state->prsbuf))
            {
                COPYCHAR(state->curpos, state->prsbuf);
-               state->curpos+=pg_mblen(state->prsbuf);
+               state->curpos += pg_mblen(state->prsbuf);
                state->state = WAITENDWORD;
            }
        }
@@ -228,18 +228,18 @@ gettoken_tsvector(TI_IN_STATE * state)
            {
                RESIZEPRSBUF;
                COPYCHAR(state->curpos, state->prsbuf);
-               state->curpos+=pg_mblen(state->prsbuf);
+               state->curpos += pg_mblen(state->prsbuf);
                state->state = oldstate;
            }
        }
        else if (state->state == WAITENDWORD)
        {
-           if ( t_iseq(state->prsbuf, '\\') )
+           if (t_iseq(state->prsbuf, '\\'))
            {
                state->state = WAITNEXTCHAR;
                oldstate = WAITENDWORD;
            }
-           else if ( t_isspace(state->prsbuf) || *(state->prsbuf) == '\0' ||
+           else if (t_isspace(state->prsbuf) || *(state->prsbuf) == '\0' ||
                     (state->oprisdelim && ISOPERATOR(state->prsbuf)))
            {
                RESIZEPRSBUF;
@@ -250,7 +250,7 @@ gettoken_tsvector(TI_IN_STATE * state)
                *(state->curpos) = '\0';
                return 1;
            }
-           else if ( t_iseq(state->prsbuf,':') )
+           else if (t_iseq(state->prsbuf, ':'))
            {
                if (state->curpos == state->word)
                    ereport(ERROR,
@@ -266,15 +266,16 @@ gettoken_tsvector(TI_IN_STATE * state)
            {
                RESIZEPRSBUF;
                COPYCHAR(state->curpos, state->prsbuf);
-               state->curpos+=pg_mblen(state->prsbuf);
+               state->curpos += pg_mblen(state->prsbuf);
            }
        }
        else if (state->state == WAITENDCMPLX)
        {
-           if ( t_iseq(state->prsbuf, '\'') ) {
-               state->state = WAITCHARCMPLX; 
+           if (t_iseq(state->prsbuf, '\''))
+           {
+               state->state = WAITCHARCMPLX;
            }
-           else if ( t_iseq(state->prsbuf, '\\') )
+           else if (t_iseq(state->prsbuf, '\\'))
            {
                state->state = WAITNEXTCHAR;
                oldstate = WAITENDCMPLX;
@@ -287,18 +288,20 @@ gettoken_tsvector(TI_IN_STATE * state)
            {
                RESIZEPRSBUF;
                COPYCHAR(state->curpos, state->prsbuf);
-               state->curpos+=pg_mblen(state->prsbuf);
+               state->curpos += pg_mblen(state->prsbuf);
            }
        }
        else if (state->state == WAITCHARCMPLX)
        {
-           if ( t_iseq(state->prsbuf, '\'') ) 
+           if (t_iseq(state->prsbuf, '\''))
            {
                RESIZEPRSBUF;
                COPYCHAR(state->curpos, state->prsbuf);
-               state->curpos+=pg_mblen(state->prsbuf);
+               state->curpos += pg_mblen(state->prsbuf);
                state->state = WAITENDCMPLX;
-           } else {
+           }
+           else
+           {
                RESIZEPRSBUF;
                *(state->curpos) = '\0';
                if (state->curpos == state->word)
@@ -312,12 +315,12 @@ gettoken_tsvector(TI_IN_STATE * state)
                }
                else
                    state->state = WAITPOSINFO;
-               continue; /* recheck current character */
+               continue;       /* recheck current character */
            }
        }
        else if (state->state == WAITPOSINFO)
        {
-           if ( t_iseq(state->prsbuf, ':') )
+           if (t_iseq(state->prsbuf, ':'))
                state->state = INPOSINFO;
            else
                return 1;
@@ -353,9 +356,9 @@ gettoken_tsvector(TI_IN_STATE * state)
        }
        else if (state->state == WAITPOSDELIM)
        {
-           if ( t_iseq(state->prsbuf, ',') )
+           if (t_iseq(state->prsbuf, ','))
                state->state = INPOSINFO;
-           else if ( t_iseq(state->prsbuf, 'a') || t_iseq(state->prsbuf, 'A') || t_iseq(state->prsbuf, '*') )
+           else if (t_iseq(state->prsbuf, 'a') || t_iseq(state->prsbuf, 'A') || t_iseq(state->prsbuf, '*'))
            {
                if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]))
                    ereport(ERROR,
@@ -363,7 +366,7 @@ gettoken_tsvector(TI_IN_STATE * state)
                             errmsg("syntax error")));
                WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 3);
            }
-           else if ( t_iseq(state->prsbuf, 'b') || t_iseq(state->prsbuf, 'B') )
+           else if (t_iseq(state->prsbuf, 'b') || t_iseq(state->prsbuf, 'B'))
            {
                if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]))
                    ereport(ERROR,
@@ -371,7 +374,7 @@ gettoken_tsvector(TI_IN_STATE * state)
                             errmsg("syntax error")));
                WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 2);
            }
-           else if ( t_iseq(state->prsbuf, 'c') || t_iseq(state->prsbuf, 'C') )
+           else if (t_iseq(state->prsbuf, 'c') || t_iseq(state->prsbuf, 'C'))
            {
                if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]))
                    ereport(ERROR,
@@ -379,7 +382,7 @@ gettoken_tsvector(TI_IN_STATE * state)
                             errmsg("syntax error")));
                WEP_SETWEIGHT(state->pos[*(uint16 *) (state->pos)], 1);
            }
-           else if ( t_iseq(state->prsbuf, 'd') || t_iseq(state->prsbuf, 'D') )
+           else if (t_iseq(state->prsbuf, 'd') || t_iseq(state->prsbuf, 'D'))
            {
                if (WEP_GETWEIGHT(state->pos[*(uint16 *) (state->pos)]))
                    ereport(ERROR,
@@ -400,7 +403,7 @@ gettoken_tsvector(TI_IN_STATE * state)
            elog(ERROR, "internal error");
 
        /* get next char */
-       state->prsbuf+=pg_mblen(state->prsbuf);
+       state->prsbuf += pg_mblen(state->prsbuf);
    }
 
    return 0;
@@ -423,7 +426,7 @@ tsvector_in(PG_FUNCTION_ARGS)
 
    SET_FUNCOID();
 
-   pg_verifymbstr( buf, strlen(buf), false );
+   pg_verifymbstr(buf, strlen(buf), false);
    state.prsbuf = buf;
    state.len = 32;
    state.word = (char *) palloc(state.len);
@@ -517,13 +520,14 @@ tsvector_out(PG_FUNCTION_ARGS)
                lenbuf = 0,
                pp;
    WordEntry  *ptr = ARRPTR(out);
-   char       *curbegin, *curin,
+   char       *curbegin,
+              *curin,
               *curout;
 
    lenbuf = out->size * 2 /* '' */ + out->size - 1 /* space */ + 2 /* \0 */ ;
    for (i = 0; i < out->size; i++)
    {
-       lenbuf += ptr[i].len * 2 * pg_database_encoding_max_length()/* for escape */ ;
+       lenbuf += ptr[i].len * 2 * pg_database_encoding_max_length() /* for escape */ ;
        if (ptr[i].haspos)
            lenbuf += 7 * POSDATALEN(out, &(ptr[i]));
    }
@@ -535,10 +539,11 @@ tsvector_out(PG_FUNCTION_ARGS)
        if (i != 0)
            *curout++ = ' ';
        *curout++ = '\'';
-       while ( curin-curbegin < ptr->len )
+       while (curin - curbegin < ptr->len)
        {
-           int len = pg_mblen(curin);
-           if ( t_iseq(curin, '\'') )
+           int         len = pg_mblen(curin);
+
+           if (t_iseq(curin, '\''))
            {
                int4        pos = curout - outbuf;
 
@@ -546,7 +551,7 @@ tsvector_out(PG_FUNCTION_ARGS)
                curout = outbuf + pos;
                *curout++ = '\'';
            }
-           while(len--)
+           while (len--)
                *curout++ = *curin++;
        }
        *curout++ = '\'';
@@ -983,36 +988,49 @@ silly_cmp_tsvector(const tsvector * a, const tsvector * b)
    {
        WordEntry  *aptr = ARRPTR(a);
        WordEntry  *bptr = ARRPTR(b);
-       int         i   = 0;
-       int         res;
+       int         i = 0;
+       int         res;
 
 
-       for(i=0;isize;i++) {
-           if ( aptr->haspos != bptr->haspos ) {
-               return ( aptr->haspos > bptr->haspos ) ? -1 : 1;
-           } else if ( aptr->len != bptr->len ) {
-               return ( aptr->len > bptr->len ) ? -1 : 1;
-           } else if ( (res=strncmp(STRPTR(a) + aptr->pos, STRPTR(b) + bptr->pos, bptr->len))!= 0 ) {
+       for (i = 0; i < a->size; i++)
+       {
+           if (aptr->haspos != bptr->haspos)
+           {
+               return (aptr->haspos > bptr->haspos) ? -1 : 1;
+           }
+           else if (aptr->len != bptr->len)
+           {
+               return (aptr->len > bptr->len) ? -1 : 1;
+           }
+           else if ((res = strncmp(STRPTR(a) + aptr->pos, STRPTR(b) + bptr->pos, bptr->len)) != 0)
+           {
                return res;
-           } else if ( aptr->haspos ) {
-               WordEntryPos    *ap = POSDATAPTR(a, aptr);
-               WordEntryPos    *bp = POSDATAPTR(b, bptr);
-               int             j;
-
-               if ( POSDATALEN(a, aptr) != POSDATALEN(b, bptr) )
-                   return ( POSDATALEN(a, aptr) > POSDATALEN(b, bptr) ) ? -1 : 1;
-
-               for(j=0;j
-                   if ( WEP_GETPOS(*ap) != WEP_GETPOS(*bp) ) {
-                       return ( WEP_GETPOS(*ap) > WEP_GETPOS(*bp) ) ? -1 : 1;
-                   } else if ( WEP_GETWEIGHT(*ap) != WEP_GETWEIGHT(*bp) ) {
-                       return ( WEP_GETWEIGHT(*ap) > WEP_GETWEIGHT(*bp) ) ? -1 : 1;
+           }
+           else if (aptr->haspos)
+           {
+               WordEntryPos *ap = POSDATAPTR(a, aptr);
+               WordEntryPos *bp = POSDATAPTR(b, bptr);
+               int         j;
+
+               if (POSDATALEN(a, aptr) != POSDATALEN(b, bptr))
+                   return (POSDATALEN(a, aptr) > POSDATALEN(b, bptr)) ? -1 : 1;
+
+               for (j = 0; j < POSDATALEN(a, aptr); j++)
+               {
+                   if (WEP_GETPOS(*ap) != WEP_GETPOS(*bp))
+                   {
+                       return (WEP_GETPOS(*ap) > WEP_GETPOS(*bp)) ? -1 : 1;
+                   }
+                   else if (WEP_GETWEIGHT(*ap) != WEP_GETWEIGHT(*bp))
+                   {
+                       return (WEP_GETWEIGHT(*ap) > WEP_GETWEIGHT(*bp)) ? -1 : 1;
                    }
                    ap++, bp++;
                }
            }
 
-           aptr++; bptr++;
+           aptr++;
+           bptr++;
        }
    }
 
index df03436a0a98c5b2b340d4f33e07d89a3e8f4d9a..48bae42de0de7d87007fa593caa8565783225821 100644 (file)
@@ -49,17 +49,17 @@ typedef uint16 WordEntryPos;
 
 /*
  * Structure of tsvector datatype:
- * 1) int4     len - varlena's length 
+ * 1) int4 len - varlena's length
  * 2) int4     size - number of lexemes or WordEntry array, which is the same
  * 3) Array of WordEntry - sorted array, comparison based on word's length
  *                     and strncmp(). WordEntry->pos points number of
  *                     bytes from end of WordEntry array to start of
  *                     corresponding lexeme.
  * 4) Lexeme's storage:
- *   SHORTALIGNED(lexeme) and position information if it exists 
- *       Position information: first int2 - is a number of positions and it 
- *    follows array of WordEntryPos
- */ 
+ *   SHORTALIGNED(lexeme) and position information if it exists
+ *   Position information: first int2 - is a number of positions and it
+ *   follows array of WordEntryPos
+ */
 
 typedef struct
 {
index 2efb49375249cb01e2cc20836127443207785df6..fced41ec5e8bac0d71f8e1b8a6ce90ce3084dc2d 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/contrib/tsearch2/wordparser/parser.c,v 1.10 2006/03/11 04:38:30 momjian Exp $ */
+/* $PostgreSQL: pgsql/contrib/tsearch2/wordparser/parser.c,v 1.11 2006/10/04 00:29:47 momjian Exp $ */
 
 #include "postgres.h"
 
@@ -458,7 +458,7 @@ static TParserStateActionItem actionTPS_InVerVersion[] = {
 
 static TParserStateActionItem actionTPS_InSVerVersion[] = {
    {p_isEOF, 0, A_POP, TPS_Null, 0, NULL},
-   {p_isdigit, 0, A_BINGO|A_CLRALL, TPS_InUnsignedInt, SPACE, NULL},
+   {p_isdigit, 0, A_BINGO | A_CLRALL, TPS_InUnsignedInt, SPACE, NULL},
    {NULL, 0, A_NEXT, TPS_Null, 0, NULL}
 };
 
@@ -613,7 +613,7 @@ static TParserStateActionItem actionTPS_InTagEnd[] = {
 static TParserStateActionItem actionTPS_InCommentFirst[] = {
    {p_isEOF, 0, A_POP, TPS_Null, 0, NULL},
    {p_iseqC, '-', A_NEXT, TPS_InCommentLast, 0, NULL},
-   /* */
+   /*  */
    {p_iseqC, 'D', A_NEXT, TPS_InTag, 0, NULL},
    {p_iseqC, 'd', A_NEXT, TPS_InTag, 0, NULL},
    {NULL, 0, A_POP, TPS_Null, 0, NULL}
@@ -753,10 +753,10 @@ static TParserStateActionItem actionTPS_InPathFirstFirst[] = {
 };
 
 static TParserStateActionItem actionTPS_InPathSecond[] = {
-   {p_isEOF, 0, A_BINGO|A_CLEAR, TPS_Base, FILEPATH, NULL},
-   {p_iseqC, '/', A_NEXT|A_PUSH, TPS_InFileFirst, 0, NULL},
-   {p_iseqC, '/', A_BINGO|A_CLEAR, TPS_Base, FILEPATH, NULL},
-   {p_isspace, 0, A_BINGO|A_CLEAR, TPS_Base, FILEPATH, NULL},
+   {p_isEOF, 0, A_BINGO | A_CLEAR, TPS_Base, FILEPATH, NULL},
+   {p_iseqC, '/', A_NEXT | A_PUSH, TPS_InFileFirst, 0, NULL},
+   {p_iseqC, '/', A_BINGO | A_CLEAR, TPS_Base, FILEPATH, NULL},
+   {p_isspace, 0, A_BINGO | A_CLEAR, TPS_Base, FILEPATH, NULL},
    {NULL, 0, A_POP, TPS_Null, 0, NULL}
 };
 
index eb9908173017d30ec1e81ce8acb4f15ccd405ca8..efe449451fd9554ccb960c0c21238973981e145c 100644 (file)
@@ -347,8 +347,8 @@ typedef struct
 
 typedef struct
 {
-   int          cur;
-   int          len;
+   int         cur;
+   int         len;
    LexemeEntry *list;
 }  PrsStorage;
 
index cc830322193ce34ebe2ec6bfa47e1ef26491eec4..11349eff0b01efaab496c25c345c20943f7b9b1a 100644 (file)
@@ -671,7 +671,7 @@ xpath_table(PG_FUNCTION_ARGS)
                                 * document */
    int         had_values;     /* To determine end of nodeset results */
 
-   StringInfoData  query_buf;
+   StringInfoData query_buf;
 
    /* We only have a valid tuple description in table function mode */
    if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
index d3b06d8ae63147bd45d71ee5c75f771934146a6f..d0f4b3d3825a34bab3d3563a08ff9adbae33c115 100644 (file)
@@ -16,7 +16,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.110 2006/07/14 14:52:16 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.111 2006/10/04 00:29:47 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1294,7 +1294,7 @@ slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
    {
        if (tuple == NULL)      /* internal error */
            elog(ERROR, "cannot extract system attribute from virtual tuple");
-       if (slot->tts_mintuple) /* internal error */
+       if (slot->tts_mintuple) /* internal error */
            elog(ERROR, "cannot extract system attribute from minimal tuple");
        return heap_getsysattr(tuple, attnum, tupleDesc, isnull);
    }
@@ -1480,7 +1480,7 @@ slot_attisnull(TupleTableSlot *slot, int attnum)
    {
        if (tuple == NULL)      /* internal error */
            elog(ERROR, "cannot extract system attribute from virtual tuple");
-       if (slot->tts_mintuple) /* internal error */
+       if (slot->tts_mintuple) /* internal error */
            elog(ERROR, "cannot extract system attribute from minimal tuple");
        return heap_attisnull(tuple, attnum);
    }
index 82117e5fe6ea15c4b4f1f12464dc793055fde185..ab2d8b4771d232ee624f418a0070d345e2d8d39a 100644 (file)
@@ -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.98 2006/08/12 02:52:03 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.99 2006/10/04 00:29:47 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -127,8 +127,8 @@ printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
    }
 
    /*
-    * If we are supposed to emit row descriptions,
-    * then send the tuple descriptor of the tuples.
+    * If we are supposed to emit row descriptions, then send the tuple
+    * descriptor of the tuples.
     */
    if (myState->sendDescrip)
        SendRowDescriptionMessage(typeinfo,
index 8506070f1014563f2a3558f65cf2753c58eb1744..0bcda36c06a2ae7b503316abf1e6e2480f61c6bb 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.1 2006/07/03 22:45:36 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.2 2006/10/04 00:29:47 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -59,7 +59,7 @@ transformRelOptions(Datum oldOptions, List *defList,
    /* Copy any oldOptions that aren't to be replaced */
    if (oldOptions != (Datum) 0)
    {
-       ArrayType *array = DatumGetArrayTypeP(oldOptions);
+       ArrayType  *array = DatumGetArrayTypeP(oldOptions);
        Datum      *oldoptions;
        int         noldoptions;
        int         i;
@@ -71,15 +71,15 @@ transformRelOptions(Datum oldOptions, List *defList,
 
        for (i = 0; i < noldoptions; i++)
        {
-           text   *oldoption = DatumGetTextP(oldoptions[i]);
-           char   *text_str = (char *) VARATT_DATA(oldoption);
-           int     text_len = VARATT_SIZE(oldoption) - VARHDRSZ;
+           text       *oldoption = DatumGetTextP(oldoptions[i]);
+           char       *text_str = (char *) VARATT_DATA(oldoption);
+           int         text_len = VARATT_SIZE(oldoption) - VARHDRSZ;
 
            /* Search for a match in defList */
            foreach(cell, defList)
            {
-               DefElem    *def = lfirst(cell);
-               int     kw_len = strlen(def->defname);
+               DefElem    *def = lfirst(cell);
+               int         kw_len = strlen(def->defname);
 
                if (text_len > kw_len && text_str[kw_len] == '=' &&
                    pg_strncasecmp(text_str, def->defname, kw_len) == 0)
@@ -96,33 +96,33 @@ transformRelOptions(Datum oldOptions, List *defList,
    }
 
    /*
-    * If CREATE/SET, add new options to array; if RESET, just check that
-    * the user didn't say RESET (option=val).  (Must do this because the
-    * grammar doesn't enforce it.)
+    * If CREATE/SET, add new options to array; if RESET, just check that the
+    * user didn't say RESET (option=val).  (Must do this because the grammar
+    * doesn't enforce it.)
     */
    foreach(cell, defList)
    {
-       DefElem    *def = lfirst(cell);
+       DefElem    *def = lfirst(cell);
 
        if (isReset)
        {
            if (def->arg != NULL)
                ereport(ERROR,
                        (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("RESET must not include values for parameters")));
+                   errmsg("RESET must not include values for parameters")));
        }
        else
        {
-           text   *t;
+           text       *t;
            const char *value;
-           Size    len;
+           Size        len;
 
            if (ignoreOids && pg_strcasecmp(def->defname, "oids") == 0)
                continue;
 
            /*
-            * Flatten the DefElem into a text string like "name=arg".
-            * If we have just "name", assume "name=true" is meant.
+            * Flatten the DefElem into a text string like "name=arg". If we
+            * have just "name", assume "name=true" is meant.
             */
            if (def->arg != NULL)
                value = defGetString(def);
@@ -163,10 +163,10 @@ transformRelOptions(Datum oldOptions, List *defList,
  * containing the corresponding value, or NULL if the keyword does not appear.
  */
 void
-parseRelOptions(Datum options, int numkeywords, const char * const *keywords,
+parseRelOptions(Datum options, int numkeywords, const char *const * keywords,
                char **values, bool validate)
 {
-   ArrayType *array;
+   ArrayType  *array;
    Datum      *optiondatums;
    int         noptions;
    int         i;
@@ -187,21 +187,21 @@ parseRelOptions(Datum options, int numkeywords, const char * const *keywords,
 
    for (i = 0; i < noptions; i++)
    {
-       text   *optiontext = DatumGetTextP(optiondatums[i]);
-       char   *text_str = (char *) VARATT_DATA(optiontext);
-       int     text_len = VARATT_SIZE(optiontext) - VARHDRSZ;
-       int     j;
+       text       *optiontext = DatumGetTextP(optiondatums[i]);
+       char       *text_str = (char *) VARATT_DATA(optiontext);
+       int         text_len = VARATT_SIZE(optiontext) - VARHDRSZ;
+       int         j;
 
        /* Search for a match in keywords */
        for (j = 0; j < numkeywords; j++)
        {
-           int     kw_len = strlen(keywords[j]);
+           int         kw_len = strlen(keywords[j]);
 
            if (text_len > kw_len && text_str[kw_len] == '=' &&
                pg_strncasecmp(text_str, keywords[j], kw_len) == 0)
            {
-               char   *value;
-               int     value_len;
+               char       *value;
+               int         value_len;
 
                if (values[j] && validate)
                    ereport(ERROR,
@@ -218,8 +218,8 @@ parseRelOptions(Datum options, int numkeywords, const char * const *keywords,
        }
        if (j >= numkeywords && validate)
        {
-           char *s;
-           char *p;
+           char       *s;
+           char       *p;
 
            s = DatumGetCString(DirectFunctionCall1(textout, optiondatums[i]));
            p = strchr(s, '=');
@@ -240,17 +240,17 @@ bytea *
 default_reloptions(Datum reloptions, bool validate,
                   int minFillfactor, int defaultFillfactor)
 {
-   static const char * const default_keywords[1] = { "fillfactor" };
-   char   *values[1];
-   int32   fillfactor;
+   static const char *const default_keywords[1] = {"fillfactor"};
+   char       *values[1];
+   int32       fillfactor;
    StdRdOptions *result;
 
    parseRelOptions(reloptions, 1, default_keywords, values, validate);
 
    /*
     * If no options, we can just return NULL rather than doing anything.
-    * (defaultFillfactor is thus not used, but we require callers to pass
-    * it anyway since we would need it if more options were added.)
+    * (defaultFillfactor is thus not used, but we require callers to pass it
+    * anyway since we would need it if more options were added.)
     */
    if (values[0] == NULL)
        return NULL;
index 911cf629832d0a8cf0cc5d3e57ab157f1be45612..33a8b44a14da4c2ede9f1e7a3892f8c7b0d42eb6 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginarrayproc.c
- *    support functions for GIN's indexing of any array
+ *   support functions for GIN's indexing of any array
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.5 2006/09/10 20:14:20 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/gin/ginarrayproc.c,v 1.6 2006/10/04 00:29:47 momjian Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
 #define GinContainedStrategy   3
 #define GinEqualStrategy       4
 
-#define    ARRAYCHECK(x) do {                                  \
+#define ARRAYCHECK(x) do {                                 \
    if ( ARR_HASNULL(x) )                                   \
-       ereport(ERROR,                                      \
-           (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),       \
-            errmsg("array must not contain nulls")));      \
-} while(0) 
+       ereport(ERROR,                                      \
+           (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),       \
+            errmsg("array must not contain nulls")));      \
+} while(0)
 
 
 /*
  * Function used as extractValue and extractQuery both
  */
 Datum
-ginarrayextract(PG_FUNCTION_ARGS) {
-   ArrayType   *array;
-   uint32  *nentries = (uint32*)PG_GETARG_POINTER(1); 
-   Datum   *entries = NULL;
-   int16   elmlen;
-   bool    elmbyval;
-   char    elmalign;
+ginarrayextract(PG_FUNCTION_ARGS)
+{
+   ArrayType  *array;
+   uint32     *nentries = (uint32 *) PG_GETARG_POINTER(1);
+   Datum      *entries = NULL;
+   int16       elmlen;
+   bool        elmbyval;
+   char        elmalign;
 
-   /* we should guarantee that array will not be destroyed during all operation */
+   /*
+    * we should guarantee that array will not be destroyed during all
+    * operation
+    */
    array = PG_GETARG_ARRAYTYPE_P_COPY(0);
 
    ARRAYCHECK(array);
 
    get_typlenbyvalalign(ARR_ELEMTYPE(array),
-        &elmlen, &elmbyval, &elmalign);
+                        &elmlen, &elmbyval, &elmalign);
 
    deconstruct_array(array,
-       ARR_ELEMTYPE(array),
-       elmlen, elmbyval, elmalign,
-       &entries, NULL, (int*)nentries);
+                     ARR_ELEMTYPE(array),
+                     elmlen, elmbyval, elmalign,
+                     &entries, NULL, (int *) nentries);
 
    /* we should not free array, entries[i] points into it */
    PG_RETURN_POINTER(entries);
 }
 
 Datum
-ginarrayconsistent(PG_FUNCTION_ARGS) {
-   bool    *check = (bool*)PG_GETARG_POINTER(0);
-   StrategyNumber  strategy = PG_GETARG_UINT16(1);
-   ArrayType   *query = PG_GETARG_ARRAYTYPE_P(2);
-   int res, i, nentries;
+ginarrayconsistent(PG_FUNCTION_ARGS)
+{
+   bool       *check = (bool *) PG_GETARG_POINTER(0);
+   StrategyNumber strategy = PG_GETARG_UINT16(1);
+   ArrayType  *query = PG_GETARG_ARRAYTYPE_P(2);
+   int         res,
+               i,
+               nentries;
 
    /* ARRAYCHECK was already done by previous ginarrayextract call */
 
-   switch( strategy ) {
+   switch (strategy)
+   {
        case GinOverlapStrategy:
        case GinContainedStrategy:
-           /* at least one element in check[] is true, so result = true */ 
+           /* at least one element in check[] is true, so result = true */
            res = TRUE;
            break;
        case GinContainsStrategy:
        case GinEqualStrategy:
-           nentries=ArrayGetNItems(ARR_NDIM(query), ARR_DIMS(query));
+           nentries = ArrayGetNItems(ARR_NDIM(query), ARR_DIMS(query));
            res = TRUE;
-           for(i=0;i
-               if ( !check[i] ) {
+           for (i = 0; i < nentries; i++)
+               if (!check[i])
+               {
                    res = FALSE;
                    break;
                }
index bc3e02973f9641c75478a658aef6407c67175564..fc44a5a0c7f88b1f88452a41674ae0ee9851cf4d 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginbtree.c
- *    page utilities routines for the postgres inverted index access method.
+ *   page utilities routines for the postgres inverted index access method.
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginbtree.c,v 1.4 2006/07/14 14:52:16 momjian Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/ginbtree.c,v 1.5 2006/10/04 00:29:47 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
  * Locks buffer by needed method for search.
  */
 static int
-ginTraverseLock(Buffer buffer, bool searchMode) {
-   Page    page;
-   int access=GIN_SHARE;
+ginTraverseLock(Buffer buffer, bool searchMode)
+{
+   Page        page;
+   int         access = GIN_SHARE;
 
    LockBuffer(buffer, GIN_SHARE);
-   page = BufferGetPage( buffer );
-   if ( GinPageIsLeaf(page) ) {
-       if ( searchMode == FALSE ) {
+   page = BufferGetPage(buffer);
+   if (GinPageIsLeaf(page))
+   {
+       if (searchMode == FALSE)
+       {
            /* we should relock our page */
            LockBuffer(buffer, GIN_UNLOCK);
            LockBuffer(buffer, GIN_EXCLUSIVE);
 
            /* But root can become non-leaf during relock */
-           if ( !GinPageIsLeaf(page) ) {
-               /* resore old lock type (very rare) */ 
+           if (!GinPageIsLeaf(page))
+           {
+               /* resore old lock type (very rare) */
                LockBuffer(buffer, GIN_UNLOCK);
                LockBuffer(buffer, GIN_SHARE);
-           } else
+           }
+           else
                access = GIN_EXCLUSIVE;
        }
    }
@@ -45,9 +50,10 @@ ginTraverseLock(Buffer buffer, bool searchMode) {
    return access;
 }
 
-GinBtreeStack*
-ginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno) {
-   GinBtreeStack   *stack = (GinBtreeStack*)palloc(sizeof(GinBtreeStack));
+GinBtreeStack *
+ginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno)
+{
+   GinBtreeStack *stack = (GinBtreeStack *) palloc(sizeof(GinBtreeStack));
 
    stack->blkno = blkno;
    stack->buffer = ReadBuffer(btree->index, stack->blkno);
@@ -62,63 +68,73 @@ ginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno) {
 /*
  * Locates leaf page contained tuple
  */
-GinBtreeStack* 
-ginFindLeafPage(GinBtree btree, GinBtreeStack *stack) {
-   bool isfirst=TRUE;
+GinBtreeStack *
+ginFindLeafPage(GinBtree btree, GinBtreeStack *stack)
+{
+   bool        isfirst = TRUE;
    BlockNumber rootBlkno;
 
-   if ( !stack ) 
+   if (!stack)
        stack = ginPrepareFindLeafPage(btree, GIN_ROOT_BLKNO);
    rootBlkno = stack->blkno;
 
-   for(;;) {
-       Page page;
+   for (;;)
+   {
+       Page        page;
        BlockNumber child;
-       int access=GIN_SHARE;
+       int         access = GIN_SHARE;
 
        stack->off = InvalidOffsetNumber;
-   
-       page = BufferGetPage( stack->buffer );
 
-       if ( isfirst ) {
-           if ( GinPageIsLeaf(page) && !btree->searchMode )
+       page = BufferGetPage(stack->buffer);
+
+       if (isfirst)
+       {
+           if (GinPageIsLeaf(page) && !btree->searchMode)
                access = GIN_EXCLUSIVE;
            isfirst = FALSE;
-       } else
+       }
+       else
            access = ginTraverseLock(stack->buffer, btree->searchMode);
 
-       /* ok, page is correctly locked, we should check to move right ..,
-           root never has a right link, so small optimization */
-       while( btree->fullScan==FALSE && stack->blkno != rootBlkno && btree->isMoveRight(btree, page) ) {
+       /*
+        * ok, page is correctly locked, we should check to move right ..,
+        * root never has a right link, so small optimization
+        */
+       while (btree->fullScan == FALSE && stack->blkno != rootBlkno && btree->isMoveRight(btree, page))
+       {
            BlockNumber rightlink = GinPageGetOpaque(page)->rightlink;
 
-           if ( rightlink==InvalidBlockNumber )
+           if (rightlink == InvalidBlockNumber)
                /* rightmost page */
                break;
 
            stack->blkno = rightlink;
            LockBuffer(stack->buffer, GIN_UNLOCK);
            stack->buffer = ReleaseAndReadBuffer(stack->buffer, btree->index, stack->blkno);
-           LockBuffer(stack->buffer, access);  
-           page = BufferGetPage( stack->buffer );
+           LockBuffer(stack->buffer, access);
+           page = BufferGetPage(stack->buffer);
        }
 
-       if ( GinPageIsLeaf(page) ) /* we found, return locked page */ 
+       if (GinPageIsLeaf(page))    /* we found, return locked page */
            return stack;
 
        /* now we have correct buffer, try to find child */
        child = btree->findChildPage(btree, stack);
 
        LockBuffer(stack->buffer, GIN_UNLOCK);
-       Assert( child != InvalidBlockNumber ); 
-       Assert( stack->blkno != child );
+       Assert(child != InvalidBlockNumber);
+       Assert(stack->blkno != child);
 
-       if ( btree->searchMode ) { 
+       if (btree->searchMode)
+       {
            /* in search mode we may forget path to leaf */
            stack->blkno = child;
-           stack->buffer = ReleaseAndReadBuffer( stack->buffer, btree->index, stack->blkno );
-       } else {
-           GinBtreeStack   *ptr = (GinBtreeStack*)palloc(sizeof(GinBtreeStack));
+           stack->buffer = ReleaseAndReadBuffer(stack->buffer, btree->index, stack->blkno);
+       }
+       else
+       {
+           GinBtreeStack *ptr = (GinBtreeStack *) palloc(sizeof(GinBtreeStack));
 
            ptr->parent = stack;
            stack = ptr;
@@ -133,93 +149,110 @@ ginFindLeafPage(GinBtree btree, GinBtreeStack *stack) {
 }
 
 void
-freeGinBtreeStack( GinBtreeStack *stack ) {
-   while(stack) {
-       GinBtreeStack   *tmp = stack->parent;
-       if ( stack->buffer != InvalidBuffer )
+freeGinBtreeStack(GinBtreeStack *stack)
+{
+   while (stack)
+   {
+       GinBtreeStack *tmp = stack->parent;
+
+       if (stack->buffer != InvalidBuffer)
            ReleaseBuffer(stack->buffer);
 
-       pfree( stack );
+       pfree(stack);
        stack = tmp;
    }
 }
 
 /*
- * Try to find parent for current stack position, returns correct 
+ * Try to find parent for current stack position, returns correct
  * parent and child's offset in  stack->parent.
  * Function should never release root page to prevent conflicts
  * with vacuum process
  */
 void
-findParents( GinBtree btree, GinBtreeStack *stack, 
-           BlockNumber rootBlkno) {
-
-   Page    page;
-   Buffer  buffer;
-   BlockNumber blkno, leftmostBlkno;
+findParents(GinBtree btree, GinBtreeStack *stack,
+           BlockNumber rootBlkno)
+{
+
+   Page        page;
+   Buffer      buffer;
+   BlockNumber blkno,
+               leftmostBlkno;
    OffsetNumber offset;
-   GinBtreeStack   *root = stack->parent;
-   GinBtreeStack   *ptr;
+   GinBtreeStack *root = stack->parent;
+   GinBtreeStack *ptr;
 
-   if ( !root ) {
+   if (!root)
+   {
        /* XLog mode... */
-       root = (GinBtreeStack*)palloc(sizeof(GinBtreeStack));
+       root = (GinBtreeStack *) palloc(sizeof(GinBtreeStack));
        root->blkno = rootBlkno;
        root->buffer = ReadBuffer(btree->index, rootBlkno);
        LockBuffer(root->buffer, GIN_EXCLUSIVE);
        root->parent = NULL;
-   } else { 
-       /* find root, we should not release root page until update is finished!! */
-       while( root->parent ) {
-           ReleaseBuffer( root->buffer );
+   }
+   else
+   {
+       /*
+        * find root, we should not release root page until update is
+        * finished!!
+        */
+       while (root->parent)
+       {
+           ReleaseBuffer(root->buffer);
            root = root->parent;
        }
 
-       Assert( root->blkno == rootBlkno );
-       Assert( BufferGetBlockNumber(root->buffer) == rootBlkno );
+       Assert(root->blkno == rootBlkno);
+       Assert(BufferGetBlockNumber(root->buffer) == rootBlkno);
        LockBuffer(root->buffer, GIN_EXCLUSIVE);
    }
    root->off = InvalidOffsetNumber;
 
    page = BufferGetPage(root->buffer);
-   Assert( !GinPageIsLeaf(page) );
+   Assert(!GinPageIsLeaf(page));
 
    /* check trivial case */
-   if ( (root->off = btree->findChildPtr(btree, page, stack->blkno, InvalidOffsetNumber)) != InvalidOffsetNumber ) {
+   if ((root->off = btree->findChildPtr(btree, page, stack->blkno, InvalidOffsetNumber)) != InvalidOffsetNumber)
+   {
        stack->parent = root;
        return;
    }
 
    leftmostBlkno = blkno = btree->getLeftMostPage(btree, page);
-   LockBuffer(root->buffer, GIN_UNLOCK );
-   Assert( blkno!=InvalidBlockNumber );
+   LockBuffer(root->buffer, GIN_UNLOCK);
+   Assert(blkno != InvalidBlockNumber);
 
 
-   for(;;) {
+   for (;;)
+   {
        buffer = ReadBuffer(btree->index, blkno);
        LockBuffer(buffer, GIN_EXCLUSIVE);
        page = BufferGetPage(buffer);
-       if ( GinPageIsLeaf(page) )
+       if (GinPageIsLeaf(page))
            elog(ERROR, "Lost path");
 
        leftmostBlkno = btree->getLeftMostPage(btree, page);
 
-       while( (offset = btree->findChildPtr(btree, page, stack->blkno, InvalidOffsetNumber))==InvalidOffsetNumber ) {
+       while ((offset = btree->findChildPtr(btree, page, stack->blkno, InvalidOffsetNumber)) == InvalidOffsetNumber)
+       {
            blkno = GinPageGetOpaque(page)->rightlink;
-           LockBuffer(buffer,GIN_UNLOCK);
+           LockBuffer(buffer, GIN_UNLOCK);
            ReleaseBuffer(buffer);
-           if ( blkno == InvalidBlockNumber )
+           if (blkno == InvalidBlockNumber)
                break;
            buffer = ReadBuffer(btree->index, blkno);
            LockBuffer(buffer, GIN_EXCLUSIVE);
            page = BufferGetPage(buffer);
        }
 
-       if ( blkno != InvalidBlockNumber ) {
-           ptr = (GinBtreeStack*)palloc(sizeof(GinBtreeStack));
+       if (blkno != InvalidBlockNumber)
+       {
+           ptr = (GinBtreeStack *) palloc(sizeof(GinBtreeStack));
            ptr->blkno = blkno;
            ptr->buffer = buffer;
-           ptr->parent = root; /* it's may be wrong, but in next call we will correct */
+           ptr->parent = root; /* it's may be wrong, but in next call we will
+                                * correct */
            ptr->off = offset;
            stack->parent = ptr;
            return;
@@ -233,79 +266,94 @@ findParents( GinBtree btree, GinBtreeStack *stack,
  * Insert value (stored in GinBtree) to tree descibed by stack
  */
 void
-ginInsertValue(GinBtree btree, GinBtreeStack *stack) {
-   GinBtreeStack   *parent = stack;
-   BlockNumber     rootBlkno = InvalidBuffer;  
-   Page            page, rpage, lpage;
+ginInsertValue(GinBtree btree, GinBtreeStack *stack)
+{
+   GinBtreeStack *parent = stack;
+   BlockNumber rootBlkno = InvalidBuffer;
+   Page        page,
+               rpage,
+               lpage;
 
    /* remember root BlockNumber */
-   while( parent ) {
+   while (parent)
+   {
        rootBlkno = parent->blkno;
        parent = parent->parent;
    }
 
-   while( stack ) {
+   while (stack)
+   {
        XLogRecData *rdata;
-       BlockNumber savedRightLink;
+       BlockNumber savedRightLink;
 
-       page = BufferGetPage( stack->buffer );
+       page = BufferGetPage(stack->buffer);
        savedRightLink = GinPageGetOpaque(page)->rightlink;
 
-       if ( btree->isEnoughSpace( btree, stack->buffer, stack->off ) ) {
+       if (btree->isEnoughSpace(btree, stack->buffer, stack->off))
+       {
            START_CRIT_SECTION();
-           btree->placeToPage( btree, stack->buffer, stack->off, &rdata );
+           btree->placeToPage(btree, stack->buffer, stack->off, &rdata);
 
-           if (!btree->index->rd_istemp) {
-               XLogRecPtr  recptr;
+           if (!btree->index->rd_istemp)
+           {
+               XLogRecPtr  recptr;
 
                recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_INSERT, rdata);
                PageSetLSN(page, recptr);
                PageSetTLI(page, ThisTimeLineID);
-           } 
+           }
 
-           MarkBufferDirty( stack->buffer );
+           MarkBufferDirty(stack->buffer);
            UnlockReleaseBuffer(stack->buffer);
            END_CRIT_SECTION();
 
            freeGinBtreeStack(stack->parent);
            return;
-       } else {
-           Buffer rbuffer = GinNewBuffer(btree->index);
-           Page    newlpage;
+       }
+       else
+       {
+           Buffer      rbuffer = GinNewBuffer(btree->index);
+           Page        newlpage;
 
-           /* newlpage is a pointer to memory page, it does'nt assosiates with buffer,
-               stack->buffer shoud be untouched */
-           newlpage = btree->splitPage( btree, stack->buffer, rbuffer, stack->off, &rdata );
+           /*
+            * newlpage is a pointer to memory page, it does'nt assosiates
+            * with buffer, stack->buffer shoud be untouched
+            */
+           newlpage = btree->splitPage(btree, stack->buffer, rbuffer, stack->off, &rdata);
 
 
-           ((ginxlogSplit*)(rdata->data))->rootBlkno = rootBlkno;
+           ((ginxlogSplit *) (rdata->data))->rootBlkno = rootBlkno;
 
            parent = stack->parent;
 
-           if ( parent == NULL ) {
-               /* split root, so we need to allocate new left page and
-                   place pointer on root to left and right page */
-               Buffer  lbuffer = GinNewBuffer(btree->index);
+           if (parent == NULL)
+           {
+               /*
+                * split root, so we need to allocate new left page and place
+                * pointer on root to left and right page
+                */
+               Buffer      lbuffer = GinNewBuffer(btree->index);
 
-               ((ginxlogSplit*)(rdata->data))->isRootSplit = TRUE;
-               ((ginxlogSplit*)(rdata->data))->rrlink = InvalidBlockNumber;
+               ((ginxlogSplit *) (rdata->data))->isRootSplit = TRUE;
+               ((ginxlogSplit *) (rdata->data))->rrlink = InvalidBlockNumber;
 
 
-               page = BufferGetPage( stack->buffer );
-               lpage = BufferGetPage( lbuffer );
-               rpage = BufferGetPage( rbuffer );
+               page = BufferGetPage(stack->buffer);
+               lpage = BufferGetPage(lbuffer);
+               rpage = BufferGetPage(rbuffer);
 
                GinPageGetOpaque(rpage)->rightlink = InvalidBlockNumber;
                GinPageGetOpaque(newlpage)->rightlink = BufferGetBlockNumber(rbuffer);
-               ((ginxlogSplit*)(rdata->data))->lblkno = BufferGetBlockNumber(lbuffer);
+               ((ginxlogSplit *) (rdata->data))->lblkno = BufferGetBlockNumber(lbuffer);
 
                START_CRIT_SECTION();
 
-               GinInitBuffer( stack->buffer, GinPageGetOpaque(newlpage)->flags & ~GIN_LEAF );
-               PageRestoreTempPage( newlpage, lpage );     
-               btree->fillRoot( btree, stack->buffer, lbuffer, rbuffer );
-               if (!btree->index->rd_istemp) {
-                   XLogRecPtr  recptr;
+               GinInitBuffer(stack->buffer, GinPageGetOpaque(newlpage)->flags & ~GIN_LEAF);
+               PageRestoreTempPage(newlpage, lpage);
+               btree->fillRoot(btree, stack->buffer, lbuffer, rbuffer);
+               if (!btree->index->rd_istemp)
+               {
+                   XLogRecPtr  recptr;
 
                    recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_SPLIT, rdata);
                    PageSetLSN(page, recptr);
@@ -324,23 +372,26 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack) {
                UnlockReleaseBuffer(stack->buffer);
 
                END_CRIT_SECTION();
-               
+
                return;
-           } else {
+           }
+           else
+           {
                /* split non-root page */
-               ((ginxlogSplit*)(rdata->data))->isRootSplit = FALSE;
-               ((ginxlogSplit*)(rdata->data))->rrlink = savedRightLink;
+               ((ginxlogSplit *) (rdata->data))->isRootSplit = FALSE;
+               ((ginxlogSplit *) (rdata->data))->rrlink = savedRightLink;
 
-               lpage = BufferGetPage( stack->buffer );
-               rpage = BufferGetPage( rbuffer );
+               lpage = BufferGetPage(stack->buffer);
+               rpage = BufferGetPage(rbuffer);
 
                GinPageGetOpaque(rpage)->rightlink = savedRightLink;
                GinPageGetOpaque(newlpage)->rightlink = BufferGetBlockNumber(rbuffer);
 
                START_CRIT_SECTION();
-               PageRestoreTempPage( newlpage, lpage );     
-               if (!btree->index->rd_istemp) {
-                   XLogRecPtr  recptr;
+               PageRestoreTempPage(newlpage, lpage);
+               if (!btree->index->rd_istemp)
+               {
+                   XLogRecPtr  recptr;
 
                    recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_SPLIT, rdata);
                    PageSetLSN(lpage, recptr);
@@ -350,7 +401,7 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack) {
                }
                MarkBufferDirty(rbuffer);
                UnlockReleaseBuffer(rbuffer);
-               MarkBufferDirty( stack->buffer );
+               MarkBufferDirty(stack->buffer);
                END_CRIT_SECTION();
            }
        }
@@ -361,31 +412,33 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack) {
        LockBuffer(parent->buffer, GIN_EXCLUSIVE);
 
        /* move right if it's needed */
-       page = BufferGetPage( parent->buffer );
-       while( (parent->off=btree->findChildPtr(btree, page, stack->blkno, parent->off)) == InvalidOffsetNumber ) {
+       page = BufferGetPage(parent->buffer);
+       while ((parent->off = btree->findChildPtr(btree, page, stack->blkno, parent->off)) == InvalidOffsetNumber)
+       {
            BlockNumber rightlink = GinPageGetOpaque(page)->rightlink;
 
            LockBuffer(parent->buffer, GIN_UNLOCK);
 
-           if ( rightlink==InvalidBlockNumber ) { 
-               /* rightmost page, but we don't find parent, we should
-                  use plain search... */
+           if (rightlink == InvalidBlockNumber)
+           {
+               /*
+                * rightmost page, but we don't find parent, we should use
+                * plain search...
+                */
                findParents(btree, stack, rootBlkno);
-               parent=stack->parent;
-               page = BufferGetPage( parent->buffer );
+               parent = stack->parent;
+               page = BufferGetPage(parent->buffer);
                break;
            }
 
            parent->blkno = rightlink;
            parent->buffer = ReleaseAndReadBuffer(parent->buffer, btree->index, parent->blkno);
-           LockBuffer(parent->buffer, GIN_EXCLUSIVE);  
-           page = BufferGetPage( parent->buffer );
+           LockBuffer(parent->buffer, GIN_EXCLUSIVE);
+           page = BufferGetPage(parent->buffer);
        }
 
        UnlockReleaseBuffer(stack->buffer);
-       pfree( stack );
+       pfree(stack);
        stack = parent;
    }
 }
-
-
index 5bcd91af1412b0ae4abaf3e1141d4b7e647c00b5..3db9e332a75c01964ef11c2b770e216789317560 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginbulk.c
- *    routines for fast build of inverted index 
+ *   routines for fast build of inverted index
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginbulk.c,v 1.5 2006/08/29 14:05:44 teodor Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/ginbulk.c,v 1.6 2006/10/04 00:29:47 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
@@ -22,7 +22,8 @@
 #define DEF_NPTR   4
 
 void
-ginInitBA(BuildAccumulator *accum) {
+ginInitBA(BuildAccumulator *accum)
+{
    accum->maxdepth = 1;
    accum->stackpos = 0;
    accum->entries = NULL;
@@ -31,11 +32,13 @@ ginInitBA(BuildAccumulator *accum) {
    accum->entryallocator = NULL;
 }
 
-static EntryAccumulator*
-EAAllocate( BuildAccumulator *accum ) {
-   if ( accum->entryallocator == NULL || accum->length>=DEF_NENTRY ) {
-       accum->entryallocator = palloc(sizeof(EntryAccumulator)*DEF_NENTRY);
-       accum->allocatedMemory += sizeof(EntryAccumulator)*DEF_NENTRY;
+static EntryAccumulator *
+EAAllocate(BuildAccumulator *accum)
+{
+   if (accum->entryallocator == NULL || accum->length >= DEF_NENTRY)
+   {
+       accum->entryallocator = palloc(sizeof(EntryAccumulator) * DEF_NENTRY);
+       accum->allocatedMemory += sizeof(EntryAccumulator) * DEF_NENTRY;
        accum->length = 0;
    }
 
@@ -48,24 +51,27 @@ EAAllocate( BuildAccumulator *accum ) {
  * item pointer are ordered
  */
 static void
-ginInsertData(BuildAccumulator *accum, EntryAccumulator *entry, ItemPointer heapptr) {
-   if ( entry->number >= entry->length ) {
+ginInsertData(BuildAccumulator *accum, EntryAccumulator *entry, ItemPointer heapptr)
+{
+   if (entry->number >= entry->length)
+   {
        accum->allocatedMemory += sizeof(ItemPointerData) * entry->length;
        entry->length *= 2;
-       entry->list    = (ItemPointerData*)repalloc(entry->list,
-                                           sizeof(ItemPointerData)*entry->length);
+       entry->list = (ItemPointerData *) repalloc(entry->list,
+                                   sizeof(ItemPointerData) * entry->length);
    }
 
-   if ( entry->shouldSort==FALSE ) {  
-       int res = compareItemPointers( entry->list + entry->number - 1, heapptr );
+   if (entry->shouldSort == FALSE)
+   {
+       int         res = compareItemPointers(entry->list + entry->number - 1, heapptr);
 
-       Assert( res != 0 );
+       Assert(res != 0);
 
-       if ( res > 0 )
-           entry->shouldSort=TRUE;
+       if (res > 0)
+           entry->shouldSort = TRUE;
    }
 
-   entry->list[ entry->number ] = *heapptr;
+   entry->list[entry->number] = *heapptr;
    entry->number++;
 }
 
@@ -74,7 +80,8 @@ ginInsertData(BuildAccumulator *accum, EntryAccumulator *entry, ItemPointer heap
  * to avoid computing the datum size twice.
  */
 static Datum
-getDatumCopy(BuildAccumulator *accum, Datum value) {
+getDatumCopy(BuildAccumulator *accum, Datum value)
+{
    Form_pg_attribute *att = accum->ginstate->tupdesc->attrs;
    Datum       res;
 
@@ -100,51 +107,58 @@ getDatumCopy(BuildAccumulator *accum, Datum value) {
  * Find/store one entry from indexed value.
  */
 static void
-ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr,  Datum entry) {
-   EntryAccumulator    *ea = accum->entries, *pea = NULL;
-   int res = 0;
-   uint32  depth = 1;
-
-   while( ea ) {
+ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr, Datum entry)
+{
+   EntryAccumulator *ea = accum->entries,
+              *pea = NULL;
+   int         res = 0;
+   uint32      depth = 1;
+
+   while (ea)
+   {
        res = compareEntries(accum->ginstate, entry, ea->value);
-       if ( res == 0 ) 
-           break;  /* found */
-       else {
+       if (res == 0)
+           break;              /* found */
+       else
+       {
            pea = ea;
-           if ( res < 0 ) 
+           if (res < 0)
                ea = ea->left;
            else
                ea = ea->right;
        }
        depth++;
    }
-   
-   if ( depth > accum->maxdepth )
+
+   if (depth > accum->maxdepth)
        accum->maxdepth = depth;
 
-   if ( ea == NULL ) {
+   if (ea == NULL)
+   {
        ea = EAAllocate(accum);
 
        ea->left = ea->right = NULL;
-       ea->value  = getDatumCopy(accum, entry);
+       ea->value = getDatumCopy(accum, entry);
        ea->length = DEF_NPTR;
        ea->number = 1;
        ea->shouldSort = FALSE;
-       ea->list   = (ItemPointerData*)palloc(sizeof(ItemPointerData)*DEF_NPTR);
+       ea->list = (ItemPointerData *) palloc(sizeof(ItemPointerData) * DEF_NPTR);
        ea->list[0] = *heapptr;
-       accum->allocatedMemory += sizeof(ItemPointerData)*DEF_NPTR;
+       accum->allocatedMemory += sizeof(ItemPointerData) * DEF_NPTR;
 
-       if ( pea == NULL )
+       if (pea == NULL)
            accum->entries = ea;
-       else {
-           Assert( res != 0 );
-           if ( res < 0 ) 
+       else
+       {
+           Assert(res != 0);
+           if (res < 0)
                pea->left = ea;
            else
                pea->right = ea;
        }
-   } else
-       ginInsertData( accum, ea, heapptr );
+   }
+   else
+       ginInsertData(accum, ea, heapptr);
 }
 
 /*
@@ -152,22 +166,23 @@ ginInsertEntry(BuildAccumulator *accum, ItemPointer heapptr,  Datum entry) {
  * then calls itself for each parts
  */
 static void
-ginChooseElem(BuildAccumulator *accum, ItemPointer heapptr, Datum *entries, uint32 nentry, 
-   uint32 low, uint32 high, uint32 offset) {
-   uint32 pos;
-   uint32 middle = (low+high)>>1;
-
-   pos = (low+middle)>>1; 
-   if ( low!=middle && pos>=offset && pos-offset < nentry ) 
-       ginInsertEntry( accum, heapptr, entries[ pos-offset ]);
-   pos = (high+middle+1)>>1; 
-   if ( middle+1 != high && pos>=offset && pos-offset < nentry ) 
-       ginInsertEntry( accum, heapptr, entries[ pos-offset ]);
-
-   if ( low!=middle )
-       ginChooseElem(accum, heapptr, entries, nentry, low, middle, offset );
-   if ( high!=middle+1 )
-       ginChooseElem(accum, heapptr, entries, nentry, middle+1, high, offset );
+ginChooseElem(BuildAccumulator *accum, ItemPointer heapptr, Datum *entries, uint32 nentry,
+             uint32 low, uint32 high, uint32 offset)
+{
+   uint32      pos;
+   uint32      middle = (low + high) >> 1;
+
+   pos = (low + middle) >> 1;
+   if (low != middle && pos >= offset && pos - offset < nentry)
+       ginInsertEntry(accum, heapptr, entries[pos - offset]);
+   pos = (high + middle + 1) >> 1;
+   if (middle + 1 != high && pos >= offset && pos - offset < nentry)
+       ginInsertEntry(accum, heapptr, entries[pos - offset]);
+
+   if (low != middle)
+       ginChooseElem(accum, heapptr, entries, nentry, low, middle, offset);
+   if (high != middle + 1)
+       ginChooseElem(accum, heapptr, entries, nentry, middle + 1, high, offset);
 }
 
 /*
@@ -176,56 +191,71 @@ ginChooseElem(BuildAccumulator *accum, ItemPointer heapptr, Datum *entries, uint
  * next middle on left part and middle of right part.
  */
 void
-ginInsertRecordBA( BuildAccumulator *accum, ItemPointer heapptr, Datum *entries, uint32 nentry ) {
-   uint32 i, nbit=0, offset;
+ginInsertRecordBA(BuildAccumulator *accum, ItemPointer heapptr, Datum *entries, uint32 nentry)
+{
+   uint32      i,
+               nbit = 0,
+               offset;
 
-   if (nentry==0)
+   if (nentry == 0)
        return;
 
-   i=nentry-1;
-   for(;i>0;i>>=1) nbit++;
+   i = nentry - 1;
+   for (; i > 0; i >>= 1)
+       nbit++;
 
-   nbit  = 1<<nbit;
-   offset = (nbit-nentry)/2;
+   nbit = 1 << nbit;
+   offset = (nbit - nentry) / 2;
 
-   ginInsertEntry( accum, heapptr, entries[ (nbit>>1)-offset ]);
+   ginInsertEntry(accum, heapptr, entries[(nbit >> 1) - offset]);
    ginChooseElem(accum, heapptr, entries, nentry, 0, nbit, offset);
 }
 
-static int 
-qsortCompareItemPointers( const void *a, const void *b ) {
-   int res = compareItemPointers( (ItemPointer)a, (ItemPointer)b );
-   Assert( res!=0 );
+static int
+qsortCompareItemPointers(const void *a, const void *b)
+{
+   int         res = compareItemPointers((ItemPointer) a, (ItemPointer) b);
+
+   Assert(res != 0);
    return res;
 }
 
 /*
- * walk on binary tree and returns ordered nodes 
- */ 
-static EntryAccumulator*
-walkTree( BuildAccumulator *accum ) {
-   EntryAccumulator    *entry = accum->stack[ accum->stackpos ];
+ * walk on binary tree and returns ordered nodes
+ */
+static EntryAccumulator *
+walkTree(BuildAccumulator *accum)
+{
+   EntryAccumulator *entry = accum->stack[accum->stackpos];
 
-   if ( entry->list != NULL ) {
+   if (entry->list != NULL)
+   {
        /* return entry itself: we already was at left sublink */
        return entry;
-   } else if ( entry->right && entry->right != accum->stack[ accum->stackpos+1 ] ) {
+   }
+   else if (entry->right && entry->right != accum->stack[accum->stackpos + 1])
+   {
        /* go on right sublink */
        accum->stackpos++;
        entry = entry->right;
 
        /* find most-left value */
-       for(;;) {
-           accum->stack[ accum->stackpos ] = entry;
-           if ( entry->left ) {
+       for (;;)
+       {
+           accum->stack[accum->stackpos] = entry;
+           if (entry->left)
+           {
                accum->stackpos++;
                entry = entry->left;
-           } else 
+           }
+           else
                break;
        }
-   } else {
+   }
+   else
+   {
        /* we already return all left subtree, itself and  right subtree */
-       if ( accum->stackpos == 0 )
+       if (accum->stackpos == 0)
            return 0;
        accum->stackpos--;
        return walkTree(accum);
@@ -234,47 +264,53 @@ walkTree( BuildAccumulator *accum ) {
    return entry;
 }
 
-ItemPointerData*
-ginGetEntry(BuildAccumulator *accum, Datum *value, uint32 *n) {
-   EntryAccumulator    *entry;
+ItemPointerData *
+ginGetEntry(BuildAccumulator *accum, Datum *value, uint32 *n)
+{
+   EntryAccumulator *entry;
    ItemPointerData *list;
 
 
-   if ( accum->stack == NULL ) {
+   if (accum->stack == NULL)
+   {
        /* first call */
-       accum->stack = palloc0(sizeof(EntryAccumulator*)*(accum->maxdepth+1));
+       accum->stack = palloc0(sizeof(EntryAccumulator *) * (accum->maxdepth + 1));
        entry = accum->entries;
 
-       if ( entry == NULL )
+       if (entry == NULL)
            return NULL;
 
        /* find most-left value */
-       for(;;) {
-           accum->stack[ accum->stackpos ] = entry;
-           if ( entry->left ) { 
+       for (;;)
+       {
+           accum->stack[accum->stackpos] = entry;
+           if (entry->left)
+           {
                accum->stackpos++;
                entry = entry->left;
-           } else
+           }
+           else
                break;
        }
-   } else {
-       pfree( accum->stack[ accum->stackpos ]->list );
-       accum->stack[ accum->stackpos ]->list = NULL;
-       entry = walkTree( accum );
+   }
+   else
+   {
+       pfree(accum->stack[accum->stackpos]->list);
+       accum->stack[accum->stackpos]->list = NULL;
+       entry = walkTree(accum);
    }
 
-   if ( entry == NULL )
+   if (entry == NULL)
        return NULL;
 
-   *n      = entry->number;
-   *value  = entry->value;
-   list    = entry->list;
+   *n = entry->number;
+   *value = entry->value;
+   list = entry->list;
 
    Assert(list != NULL);
 
-   if ( entry->shouldSort && entry->number > 1 )
+   if (entry->shouldSort && entry->number > 1)
        qsort(list, *n, sizeof(ItemPointerData), qsortCompareItemPointers);
 
    return list;
 }
-
index 5789dc18f9ba66e265bca14478835d50a6141400..94b07f3ed91bbe6f1a36c841c22a523380d18b08 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * gindatapage.c
- *    page utilities routines for the postgres inverted index access method.
+ *   page utilities routines for the postgres inverted index access method.
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.3 2006/07/16 00:52:05 tgl Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.4 2006/10/04 00:29:47 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
 #include "access/gin.h"
 
 int
-compareItemPointers( ItemPointer a, ItemPointer b ) {
-   if ( GinItemPointerGetBlockNumber(a) == GinItemPointerGetBlockNumber(b) ) {
-       if ( GinItemPointerGetOffsetNumber(a) == GinItemPointerGetOffsetNumber(b) )
+compareItemPointers(ItemPointer a, ItemPointer b)
+{
+   if (GinItemPointerGetBlockNumber(a) == GinItemPointerGetBlockNumber(b))
+   {
+       if (GinItemPointerGetOffsetNumber(a) == GinItemPointerGetOffsetNumber(b))
            return 0;
-       return ( GinItemPointerGetOffsetNumber(a) > GinItemPointerGetOffsetNumber(b) ) ? 1 : -1;
-   } 
+       return (GinItemPointerGetOffsetNumber(a) > GinItemPointerGetOffsetNumber(b)) ? 1 : -1;
+   }
 
-   return ( GinItemPointerGetBlockNumber(a) > GinItemPointerGetBlockNumber(b) ) ? 1 : -1;
+   return (GinItemPointerGetBlockNumber(a) > GinItemPointerGetBlockNumber(b)) ? 1 : -1;
 }
 
 /*
  * Merge two ordered array of itempointer
  */
-void 
-MergeItemPointers(ItemPointerData *dst, ItemPointerData *a, uint32 na, ItemPointerData *b, uint32 nb) {
+void
+MergeItemPointers(ItemPointerData *dst, ItemPointerData *a, uint32 na, ItemPointerData *b, uint32 nb)
+{
    ItemPointerData *dptr = dst;
-   ItemPointerData *aptr = a, *bptr = b;
+   ItemPointerData *aptr = a,
+              *bptr = b;
 
-   while( aptr - a < na && bptr - b < nb ) {
-       if ( compareItemPointers(aptr, bptr) > 0 ) 
+   while (aptr - a < na && bptr - b < nb)
+   {
+       if (compareItemPointers(aptr, bptr) > 0)
            *dptr++ = *bptr++;
        else
            *dptr++ = *aptr++;
    }
 
-   while( aptr - a < na )
+   while (aptr - a < na)
        *dptr++ = *aptr++;
 
-   while( bptr - b < nb )
+   while (bptr - b < nb)
        *dptr++ = *bptr++;
 }
 
 /*
- * Checks, should we move to right link... 
+ * Checks, should we move to right link...
  * Compares inserting itemp pointer with right bound of current page
  */
 static bool
-dataIsMoveRight(GinBtree btree, Page page) {
-   ItemPointer iptr = GinDataPageGetRightBound(page);
+dataIsMoveRight(GinBtree btree, Page page)
+{
+   ItemPointer iptr = GinDataPageGetRightBound(page);
 
-    if ( GinPageRightMost(page) )
-           return FALSE;
+   if (GinPageRightMost(page))
+       return FALSE;
 
-   return ( compareItemPointers( btree->items + btree->curitem, iptr ) > 0 ) ? TRUE : FALSE;
+   return (compareItemPointers(btree->items + btree->curitem, iptr) > 0) ? TRUE : FALSE;
 }
 
 /*
@@ -67,94 +73,113 @@ dataIsMoveRight(GinBtree btree, Page page) {
  * page correctly choosen and searching value SHOULD be on page
  */
 static BlockNumber
-dataLocateItem(GinBtree btree, GinBtreeStack *stack) {
-   OffsetNumber low, high, maxoff;
-   PostingItem *pitem=NULL;
-   int result;
-   Page    page = BufferGetPage( stack->buffer );
-
-   Assert( !GinPageIsLeaf(page) );
-   Assert( GinPageIsData(page) );
-
-   if ( btree->fullScan ) {
+dataLocateItem(GinBtree btree, GinBtreeStack *stack)
+{
+   OffsetNumber low,
+               high,
+               maxoff;
+   PostingItem *pitem = NULL;
+   int         result;
+   Page        page = BufferGetPage(stack->buffer);
+
+   Assert(!GinPageIsLeaf(page));
+   Assert(GinPageIsData(page));
+
+   if (btree->fullScan)
+   {
        stack->off = FirstOffsetNumber;
        stack->predictNumber *= GinPageGetOpaque(page)->maxoff;
        return btree->getLeftMostPage(btree, page);
    }
 
    low = FirstOffsetNumber;
-   maxoff = high = GinPageGetOpaque(page)->maxoff; 
-   Assert( high >= low );
+   maxoff = high = GinPageGetOpaque(page)->maxoff;
+   Assert(high >= low);
 
    high++;
 
-   while (high > low) {
+   while (high > low)
+   {
        OffsetNumber mid = low + ((high - low) / 2);
-       pitem = (PostingItem*)GinDataPageGetItem(page,mid); 
 
-       if ( mid == maxoff )
-           /* Right infinity, page already correctly choosen
-               with a help of dataIsMoveRight */
+       pitem = (PostingItem *) GinDataPageGetItem(page, mid);
+
+       if (mid == maxoff)
+
+           /*
+            * Right infinity, page already correctly choosen with a help of
+            * dataIsMoveRight
+            */
            result = -1;
-       else {
-           pitem = (PostingItem*)GinDataPageGetItem(page,mid);
-           result = compareItemPointers( btree->items + btree->curitem, &( pitem->key ) );
+       else
+       {
+           pitem = (PostingItem *) GinDataPageGetItem(page, mid);
+           result = compareItemPointers(btree->items + btree->curitem, &(pitem->key));
        }
 
-       if ( result == 0 ) {
+       if (result == 0)
+       {
            stack->off = mid;
            return PostingItemGetBlockNumber(pitem);
-       } else if ( result > 0 )
+       }
+       else if (result > 0)
            low = mid + 1;
        else
            high = mid;
    }
 
-   Assert( high>=FirstOffsetNumber && high <= maxoff );
+   Assert(high >= FirstOffsetNumber && high <= maxoff);
 
    stack->off = high;
-   pitem = (PostingItem*)GinDataPageGetItem(page,high);
+   pitem = (PostingItem *) GinDataPageGetItem(page, high);
    return PostingItemGetBlockNumber(pitem);
 }
 
-/* 
+/*
  * Searches correct position for value on leaf page.
- * Page should be corrrectly choosen. 
+ * Page should be corrrectly choosen.
  * Returns true if value found on page.
  */
 static bool
-dataLocateLeafItem(GinBtree btree, GinBtreeStack *stack) {
-   Page page = BufferGetPage( stack->buffer );
-   OffsetNumber low, high;
-   int result;
-
-   Assert( GinPageIsLeaf(page) );
-   Assert( GinPageIsData(page) );
-
-   if ( btree->fullScan ) {
+dataLocateLeafItem(GinBtree btree, GinBtreeStack *stack)
+{
+   Page        page = BufferGetPage(stack->buffer);
+   OffsetNumber low,
+               high;
+   int         result;
+
+   Assert(GinPageIsLeaf(page));
+   Assert(GinPageIsData(page));
+
+   if (btree->fullScan)
+   {
        stack->off = FirstOffsetNumber;
        return TRUE;
    }
 
-   low=FirstOffsetNumber;
+   low = FirstOffsetNumber;
    high = GinPageGetOpaque(page)->maxoff;
 
-   if ( high < low ) {
+   if (high < low)
+   {
        stack->off = FirstOffsetNumber;
        return false;
    }
 
    high++;
 
-   while (high > low) {
+   while (high > low)
+   {
        OffsetNumber mid = low + ((high - low) / 2);
 
-       result = compareItemPointers( btree->items + btree->curitem, (ItemPointer)GinDataPageGetItem(page,mid) );
+       result = compareItemPointers(btree->items + btree->curitem, (ItemPointer) GinDataPageGetItem(page, mid));
 
-       if ( result == 0 ) {
+       if (result == 0)
+       {
            stack->off = mid;
            return true;
-       } else if ( result > 0 )
+       }
+       else if (result > 0)
            low = mid + 1;
        else
            high = mid;
@@ -169,34 +194,41 @@ dataLocateLeafItem(GinBtree btree, GinBtreeStack *stack) {
  * offset of PostingItem
  */
 static OffsetNumber
-dataFindChildPtr(GinBtree btree, Page page, BlockNumber blkno, OffsetNumber storedOff) {
-   OffsetNumber    i, maxoff = GinPageGetOpaque(page)->maxoff;
+dataFindChildPtr(GinBtree btree, Page page, BlockNumber blkno, OffsetNumber storedOff)
+{
+   OffsetNumber i,
+               maxoff = GinPageGetOpaque(page)->maxoff;
    PostingItem *pitem;
 
-   Assert( !GinPageIsLeaf(page) );
-   Assert( GinPageIsData(page) );
+   Assert(!GinPageIsLeaf(page));
+   Assert(GinPageIsData(page));
 
    /* if page isn't changed, we returns storedOff */
-   if ( storedOff>= FirstOffsetNumber && storedOff<=maxoff) {
-       pitem = (PostingItem*)GinDataPageGetItem(page, storedOff);
-       if ( PostingItemGetBlockNumber(pitem) == blkno )    
+   if (storedOff >= FirstOffsetNumber && storedOff <= maxoff)
+   {
+       pitem = (PostingItem *) GinDataPageGetItem(page, storedOff);
+       if (PostingItemGetBlockNumber(pitem) == blkno)
            return storedOff;
 
-       /* we hope, that needed pointer goes to right. It's true
-           if there wasn't a deletion */
-       for( i=storedOff+1 ; i <= maxoff ; i++ ) {
-           pitem = (PostingItem*)GinDataPageGetItem(page, i);
-           if ( PostingItemGetBlockNumber(pitem) == blkno )
+       /*
+        * we hope, that needed pointer goes to right. It's true if there
+        * wasn't a deletion
+        */
+       for (i = storedOff + 1; i <= maxoff; i++)
+       {
+           pitem = (PostingItem *) GinDataPageGetItem(page, i);
+           if (PostingItemGetBlockNumber(pitem) == blkno)
                return i;
        }
 
-       maxoff = storedOff-1;
+       maxoff = storedOff - 1;
    }
 
    /* last chance */
-   for( i=FirstOffsetNumber; i <= maxoff ; i++ ) {
-       pitem = (PostingItem*)GinDataPageGetItem(page, i);
-       if ( PostingItemGetBlockNumber(pitem) == blkno )
+   for (i = FirstOffsetNumber; i <= maxoff; i++)
+   {
+       pitem = (PostingItem *) GinDataPageGetItem(page, i);
+       if (PostingItemGetBlockNumber(pitem) == blkno)
            return i;
    }
 
@@ -207,14 +239,15 @@ dataFindChildPtr(GinBtree btree, Page page, BlockNumber blkno, OffsetNumber stor
  * retunrs blkno of lefmost child
  */
 static BlockNumber
-dataGetLeftMostPage(GinBtree btree, Page page) {
+dataGetLeftMostPage(GinBtree btree, Page page)
+{
    PostingItem *pitem;
 
-   Assert( !GinPageIsLeaf(page) );
-   Assert( GinPageIsData(page) );
-   Assert( GinPageGetOpaque(page)->maxoff >= FirstOffsetNumber );
+   Assert(!GinPageIsLeaf(page));
+   Assert(GinPageIsData(page));
+   Assert(GinPageGetOpaque(page)->maxoff >= FirstOffsetNumber);
 
-   pitem = (PostingItem*)GinDataPageGetItem(page, FirstOffsetNumber);
+   pitem = (PostingItem *) GinDataPageGetItem(page, FirstOffsetNumber);
    return PostingItemGetBlockNumber(pitem);
 }
 
@@ -223,18 +256,22 @@ dataGetLeftMostPage(GinBtree btree, Page page) {
  * correct value! depending on leaf or non-leaf page
  */
 void
-GinDataPageAddItem( Page page, void *data, OffsetNumber offset ) {
+GinDataPageAddItem(Page page, void *data, OffsetNumber offset)
+{
    OffsetNumber maxoff = GinPageGetOpaque(page)->maxoff;
-   char *ptr;
-
-   if ( offset == InvalidOffsetNumber ) {
-       ptr = GinDataPageGetItem(page,maxoff+1);
-   } else {
-       ptr = GinDataPageGetItem(page,offset);
-       if ( maxoff+1-offset != 0 )
-           memmove( ptr+GinSizeOfItem(page), ptr, (maxoff-offset+1) * GinSizeOfItem(page) );
+   char       *ptr;
+
+   if (offset == InvalidOffsetNumber)
+   {
+       ptr = GinDataPageGetItem(page, maxoff + 1);
    }
-   memcpy( ptr, data, GinSizeOfItem(page) );
+   else
+   {
+       ptr = GinDataPageGetItem(page, offset);
+       if (maxoff + 1 - offset != 0)
+           memmove(ptr + GinSizeOfItem(page), ptr, (maxoff - offset + 1) * GinSizeOfItem(page));
+   }
+   memcpy(ptr, data, GinSizeOfItem(page));
 
    GinPageGetOpaque(page)->maxoff++;
 }
@@ -243,15 +280,16 @@ GinDataPageAddItem( Page page, void *data, OffsetNumber offset ) {
  * Deletes posting item from non-leaf page
  */
 void
-PageDeletePostingItem(Page page, OffsetNumber offset) {
-   OffsetNumber    maxoff = GinPageGetOpaque(page)->maxoff;
+PageDeletePostingItem(Page page, OffsetNumber offset)
+{
+   OffsetNumber maxoff = GinPageGetOpaque(page)->maxoff;
 
-   Assert( !GinPageIsLeaf(page) );
-   Assert( offset>=FirstOffsetNumber && offset <= maxoff );
+   Assert(!GinPageIsLeaf(page));
+   Assert(offset >= FirstOffsetNumber && offset <= maxoff);
 
-   if ( offset != maxoff )
-       memmove( GinDataPageGetItem(page,offset), GinDataPageGetItem(page,offset+1),
-           sizeof(PostingItem) * (maxoff-offset) );
+   if (offset != maxoff)
+       memmove(GinDataPageGetItem(page, offset), GinDataPageGetItem(page, offset + 1),
+               sizeof(PostingItem) * (maxoff - offset));
 
    GinPageGetOpaque(page)->maxoff--;
 }
@@ -261,19 +299,24 @@ PageDeletePostingItem(Page page, OffsetNumber offset) {
  * item pointer never deletes!
  */
 static bool
-dataIsEnoughSpace( GinBtree btree, Buffer buf, OffsetNumber off ) {
-   Page page = BufferGetPage(buf);
-
-   Assert( GinPageIsData(page) );
-   Assert( !btree->isDelete );
-
-   if ( GinPageIsLeaf(page) ) {
-       if ( GinPageRightMost(page) && off > GinPageGetOpaque(page)->maxoff ) {
-           if ( (btree->nitem - btree->curitem) * sizeof(ItemPointerData) <= GinDataPageGetFreeSpace(page) )
+dataIsEnoughSpace(GinBtree btree, Buffer buf, OffsetNumber off)
+{
+   Page        page = BufferGetPage(buf);
+
+   Assert(GinPageIsData(page));
+   Assert(!btree->isDelete);
+
+   if (GinPageIsLeaf(page))
+   {
+       if (GinPageRightMost(page) && off > GinPageGetOpaque(page)->maxoff)
+       {
+           if ((btree->nitem - btree->curitem) * sizeof(ItemPointerData) <= GinDataPageGetFreeSpace(page))
                return true;
-       } else if ( sizeof(ItemPointerData) <= GinDataPageGetFreeSpace(page) )
+       }
+       else if (sizeof(ItemPointerData) <= GinDataPageGetFreeSpace(page))
            return true;
-   } else if ( sizeof(PostingItem) <= GinDataPageGetFreeSpace(page) )
+   }
+   else if (sizeof(PostingItem) <= GinDataPageGetFreeSpace(page))
        return true;
 
    return false;
@@ -285,14 +328,17 @@ dataIsEnoughSpace( GinBtree btree, Buffer buf, OffsetNumber off ) {
  * item pointer never deletes!
  */
 static BlockNumber
-dataPrepareData( GinBtree btree, Page page, OffsetNumber off) { 
+dataPrepareData(GinBtree btree, Page page, OffsetNumber off)
+{
    BlockNumber ret = InvalidBlockNumber;
 
-   Assert( GinPageIsData(page) );
+   Assert(GinPageIsData(page));
 
-   if ( !GinPageIsLeaf(page) && btree->rightblkno != InvalidBlockNumber ) {
-       PostingItem *pitem = (PostingItem*)GinDataPageGetItem(page,off);
-       PostingItemSetBlockNumber( pitem, btree->rightblkno );
+   if (!GinPageIsLeaf(page) && btree->rightblkno != InvalidBlockNumber)
+   {
+       PostingItem *pitem = (PostingItem *) GinDataPageGetItem(page, off);
+
+       PostingItemSetBlockNumber(pitem, btree->rightblkno);
        ret = btree->rightblkno;
    }
 
@@ -301,24 +347,25 @@ dataPrepareData( GinBtree btree, Page page, OffsetNumber off) {
    return ret;
 }
 
-/* 
+/*
  * Places keys to page and fills WAL record. In case leaf page and
  * build mode puts all ItemPointers to page.
  */
 static void
-dataPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prdata) {
-   Page page = BufferGetPage(buf);
+dataPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prdata)
+{
+   Page        page = BufferGetPage(buf);
    static XLogRecData rdata[3];
-   int     sizeofitem =  GinSizeOfItem(page);
-   static  ginxlogInsert   data;
+   int         sizeofitem = GinSizeOfItem(page);
+   static ginxlogInsert data;
 
    *prdata = rdata;
-   Assert( GinPageIsData(page) );
+   Assert(GinPageIsData(page));
 
-   data.updateBlkno = dataPrepareData( btree, page, off );
+   data.updateBlkno = dataPrepareData(btree, page, off);
 
    data.node = btree->index->rd_node;
-   data.blkno = BufferGetBlockNumber( buf );
+   data.blkno = BufferGetBlockNumber(buf);
    data.offset = off;
    data.nitem = 1;
    data.isDelete = FALSE;
@@ -337,109 +384,124 @@ dataPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prda
    rdata[1].next = &rdata[2];
 
    rdata[2].buffer = InvalidBuffer;
-   rdata[2].data = (GinPageIsLeaf(page)) ? ((char*)(btree->items+btree->curitem)) : ((char*)&(btree->pitem));
+   rdata[2].data = (GinPageIsLeaf(page)) ? ((char *) (btree->items + btree->curitem)) : ((char *) &(btree->pitem));
    rdata[2].len = sizeofitem;
    rdata[2].next = NULL;
 
-   if ( GinPageIsLeaf(page) ) {
-       if ( GinPageRightMost(page) && off > GinPageGetOpaque(page)->maxoff ) {
+   if (GinPageIsLeaf(page))
+   {
+       if (GinPageRightMost(page) && off > GinPageGetOpaque(page)->maxoff)
+       {
            /* usually, create index... */
-           uint32 savedPos = btree->curitem;
+           uint32      savedPos = btree->curitem;
 
-           while( btree->curitem < btree->nitem ) {
-               GinDataPageAddItem(page, btree->items+btree->curitem, off);
+           while (btree->curitem < btree->nitem)
+           {
+               GinDataPageAddItem(page, btree->items + btree->curitem, off);
                off++;
                btree->curitem++;
            }
-           data.nitem = btree->curitem-savedPos;
+           data.nitem = btree->curitem - savedPos;
            rdata[2].len = sizeofitem * data.nitem;
-       } else {
-           GinDataPageAddItem(page, btree->items+btree->curitem, off);
+       }
+       else
+       {
+           GinDataPageAddItem(page, btree->items + btree->curitem, off);
            btree->curitem++;
        }
-   } else
-           GinDataPageAddItem(page, &(btree->pitem), off);
+   }
+   else
+       GinDataPageAddItem(page, &(btree->pitem), off);
 }
 
 /*
  * split page and fills WAL record. original buffer(lbuf) leaves untouched,
- * returns shadow page of lbuf filled new data. In leaf page and build mode puts all 
+ * returns shadow page of lbuf filled new data. In leaf page and build mode puts all
  * ItemPointers to pages. Also, in build mode splits data by way to full fulled
  * left page
  */
 static Page
-dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRecData **prdata) {
+dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRecData **prdata)
+{
    static ginxlogSplit data;
    static XLogRecData rdata[4];
-   static char vector[2*BLCKSZ];
-   char *ptr;
+   static char vector[2 * BLCKSZ];
+   char       *ptr;
    OffsetNumber separator;
-   ItemPointer bound;
-   Page    lpage = GinPageGetCopyPage( BufferGetPage( lbuf ) );
-   ItemPointerData oldbound = *GinDataPageGetRightBound(lpage);
-   int     sizeofitem =  GinSizeOfItem(lpage);
+   ItemPointer bound;
+   Page        lpage = GinPageGetCopyPage(BufferGetPage(lbuf));
+   ItemPointerData oldbound = *GinDataPageGetRightBound(lpage);
+   int         sizeofitem = GinSizeOfItem(lpage);
    OffsetNumber maxoff = GinPageGetOpaque(lpage)->maxoff;
-   Page    rpage = BufferGetPage( rbuf );
-   Size    pageSize = PageGetPageSize( lpage );
-   Size    freeSpace;
-   uint32  nCopied = 1;
+   Page        rpage = BufferGetPage(rbuf);
+   Size        pageSize = PageGetPageSize(lpage);
+   Size        freeSpace;
+   uint32      nCopied = 1;
 
-   GinInitPage( rpage, GinPageGetOpaque(lpage)->flags, pageSize );
+   GinInitPage(rpage, GinPageGetOpaque(lpage)->flags, pageSize);
    freeSpace = GinDataPageGetFreeSpace(rpage);
 
    *prdata = rdata;
-    data.leftChildBlkno = ( GinPageIsLeaf(lpage) ) ?
-               InvalidOffsetNumber : PostingItemGetBlockNumber( &(btree->pitem) );
-   data.updateBlkno = dataPrepareData( btree, lpage, off );
+   data.leftChildBlkno = (GinPageIsLeaf(lpage)) ?
+       InvalidOffsetNumber : PostingItemGetBlockNumber(&(btree->pitem));
+   data.updateBlkno = dataPrepareData(btree, lpage, off);
 
-   memcpy(vector,  GinDataPageGetItem(lpage, FirstOffsetNumber),
-       maxoff*sizeofitem);
+   memcpy(vector, GinDataPageGetItem(lpage, FirstOffsetNumber),
+          maxoff * sizeofitem);
 
-   if ( GinPageIsLeaf(lpage) && GinPageRightMost(lpage) && off > GinPageGetOpaque(lpage)->maxoff ) {
+   if (GinPageIsLeaf(lpage) && GinPageRightMost(lpage) && off > GinPageGetOpaque(lpage)->maxoff)
+   {
        nCopied = 0;
-       while( btree->curitem < btree->nitem && maxoff*sizeof(ItemPointerData) < 2*(freeSpace - sizeof(ItemPointerData)) ) {
-           memcpy( vector + maxoff*sizeof(ItemPointerData), btree->items+btree->curitem,
-                   sizeof(ItemPointerData) );
+       while (btree->curitem < btree->nitem && maxoff * sizeof(ItemPointerData) < 2 * (freeSpace - sizeof(ItemPointerData)))
+       {
+           memcpy(vector + maxoff * sizeof(ItemPointerData), btree->items + btree->curitem,
+                  sizeof(ItemPointerData));
            maxoff++;
            nCopied++;
            btree->curitem++;
        }
-   } else {
-       ptr = vector + (off-1)*sizeofitem;
-       if ( maxoff+1-off != 0 ) 
-           memmove( ptr+sizeofitem, ptr, (maxoff-off+1) * sizeofitem );
-       if ( GinPageIsLeaf(lpage) ) { 
-           memcpy(ptr,  btree->items+btree->curitem, sizeofitem );
+   }
+   else
+   {
+       ptr = vector + (off - 1) * sizeofitem;
+       if (maxoff + 1 - off != 0)
+           memmove(ptr + sizeofitem, ptr, (maxoff - off + 1) * sizeofitem);
+       if (GinPageIsLeaf(lpage))
+       {
+           memcpy(ptr, btree->items + btree->curitem, sizeofitem);
            btree->curitem++;
-       } else
-           memcpy(ptr,  &(btree->pitem), sizeofitem );
-   
+       }
+       else
+           memcpy(ptr, &(btree->pitem), sizeofitem);
+
        maxoff++;
    }
 
-   /* we suppose that during index creation table scaned from 
-       begin to end, so ItemPointers are monotonically increased.. */ 
-   if ( btree->isBuild && GinPageRightMost(lpage) )
-       separator=freeSpace/sizeofitem;
+   /*
+    * we suppose that during index creation table scaned from begin to end,
+    * so ItemPointers are monotonically increased..
+    */
+   if (btree->isBuild && GinPageRightMost(lpage))
+       separator = freeSpace / sizeofitem;
    else
-       separator=maxoff/2;
+       separator = maxoff / 2;
 
-   GinInitPage( rpage, GinPageGetOpaque(lpage)->flags, pageSize );
-   GinInitPage( lpage, GinPageGetOpaque(rpage)->flags, pageSize );
+   GinInitPage(rpage, GinPageGetOpaque(lpage)->flags, pageSize);
+   GinInitPage(lpage, GinPageGetOpaque(rpage)->flags, pageSize);
 
-   memcpy( GinDataPageGetItem(lpage, FirstOffsetNumber), vector, separator * sizeofitem );
+   memcpy(GinDataPageGetItem(lpage, FirstOffsetNumber), vector, separator * sizeofitem);
    GinPageGetOpaque(lpage)->maxoff = separator;
-   memcpy( GinDataPageGetItem(rpage, FirstOffsetNumber), 
-           vector + separator * sizeofitem, (maxoff-separator) * sizeofitem );
-   GinPageGetOpaque(rpage)->maxoff = maxoff-separator;
-
-   PostingItemSetBlockNumber( &(btree->pitem), BufferGetBlockNumber(lbuf) );
-   if ( GinPageIsLeaf(lpage) ) 
-       btree->pitem.key = *(ItemPointerData*)GinDataPageGetItem(lpage, 
-               GinPageGetOpaque(lpage)->maxoff);
-   else 
-       btree->pitem.key = ((PostingItem*)GinDataPageGetItem(lpage, 
-               GinPageGetOpaque(lpage)->maxoff))->key;
+   memcpy(GinDataPageGetItem(rpage, FirstOffsetNumber),
+        vector + separator * sizeofitem, (maxoff - separator) * sizeofitem);
+   GinPageGetOpaque(rpage)->maxoff = maxoff - separator;
+
+   PostingItemSetBlockNumber(&(btree->pitem), BufferGetBlockNumber(lbuf));
+   if (GinPageIsLeaf(lpage))
+       btree->pitem.key = *(ItemPointerData *) GinDataPageGetItem(lpage,
+                                           GinPageGetOpaque(lpage)->maxoff);
+   else
+       btree->pitem.key = ((PostingItem *) GinDataPageGetItem(lpage,
+                                     GinPageGetOpaque(lpage)->maxoff))->key;
    btree->rightblkno = BufferGetBlockNumber(rbuf);
 
    /* set up right bound for left page */
@@ -452,8 +514,8 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
 
    data.node = btree->index->rd_node;
    data.rootBlkno = InvalidBlockNumber;
-   data.lblkno = BufferGetBlockNumber( lbuf );
-   data.rblkno = BufferGetBlockNumber( rbuf );
+   data.lblkno = BufferGetBlockNumber(lbuf);
+   data.rblkno = BufferGetBlockNumber(rbuf);
    data.separator = separator;
    data.nitem = maxoff;
    data.isData = TRUE;
@@ -468,34 +530,37 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
 
    rdata[1].buffer = InvalidBuffer;
    rdata[1].data = vector;
-   rdata[1].len = MAXALIGN( maxoff * sizeofitem ); 
+   rdata[1].len = MAXALIGN(maxoff * sizeofitem);
    rdata[1].next = NULL;
 
    return lpage;
 }
 
 /*
- * Fills new root by right bound values from child. 
+ * Fills new root by right bound values from child.
  * Also called from ginxlog, should not use btree
  */
 void
-dataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf) {
-   Page    page  = BufferGetPage(root),
-           lpage = BufferGetPage(lbuf),
-           rpage = BufferGetPage(rbuf);
-   PostingItem li, ri;
+dataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
+{
+   Page        page = BufferGetPage(root),
+               lpage = BufferGetPage(lbuf),
+               rpage = BufferGetPage(rbuf);
+   PostingItem li,
+               ri;
 
    li.key = *GinDataPageGetRightBound(lpage);
-   PostingItemSetBlockNumber( &li, BufferGetBlockNumber(lbuf) );
-   GinDataPageAddItem(page, &li, InvalidOffsetNumber );
+   PostingItemSetBlockNumber(&li, BufferGetBlockNumber(lbuf));
+   GinDataPageAddItem(page, &li, InvalidOffsetNumber);
 
    ri.key = *GinDataPageGetRightBound(rpage);
-   PostingItemSetBlockNumber( &ri, BufferGetBlockNumber(rbuf) );
-   GinDataPageAddItem(page, &ri, InvalidOffsetNumber );
+   PostingItemSetBlockNumber(&ri, BufferGetBlockNumber(rbuf));
+   GinDataPageAddItem(page, &ri, InvalidOffsetNumber);
 }
 
 void
-prepareDataScan( GinBtree btree, Relation index) {
+prepareDataScan(GinBtree btree, Relation index)
+{
    memset(btree, 0, sizeof(GinBtreeData));
    btree->index = index;
    btree->isMoveRight = dataIsMoveRight;
@@ -509,21 +574,22 @@ prepareDataScan( GinBtree btree, Relation index) {
    btree->fillRoot = dataFillRoot;
 
    btree->searchMode = FALSE;
-    btree->isDelete = FALSE;
+   btree->isDelete = FALSE;
    btree->fullScan = FALSE;
-   btree->isBuild= FALSE;
+   btree->isBuild = FALSE;
 }
 
-GinPostingTreeScan*
-prepareScanPostingTree( Relation index, BlockNumber rootBlkno, bool searchMode) {
-   GinPostingTreeScan  *gdi = (GinPostingTreeScan*)palloc0( sizeof(GinPostingTreeScan) );
+GinPostingTreeScan *
+prepareScanPostingTree(Relation index, BlockNumber rootBlkno, bool searchMode)
+{
+   GinPostingTreeScan *gdi = (GinPostingTreeScan *) palloc0(sizeof(GinPostingTreeScan));
+
+   prepareDataScan(&gdi->btree, index);
 
-   prepareDataScan( &gdi->btree, index );
-   
    gdi->btree.searchMode = searchMode;
    gdi->btree.fullScan = searchMode;
 
-   gdi->stack = ginPrepareFindLeafPage( &gdi->btree, rootBlkno );
+   gdi->stack = ginPrepareFindLeafPage(&gdi->btree, rootBlkno);
 
    return gdi;
 }
@@ -532,33 +598,35 @@ prepareScanPostingTree( Relation index, BlockNumber rootBlkno, bool searchMode)
  * Inserts array of item pointers, may execute several tree scan (very rare)
  */
 void
-insertItemPointer(GinPostingTreeScan *gdi, ItemPointerData *items, uint32 nitem) {
+insertItemPointer(GinPostingTreeScan *gdi, ItemPointerData *items, uint32 nitem)
+{
    BlockNumber rootBlkno = gdi->stack->blkno;
 
    gdi->btree.items = items;
    gdi->btree.nitem = nitem;
    gdi->btree.curitem = 0;
 
-   while( gdi->btree.curitem < gdi->btree.nitem ) {
+   while (gdi->btree.curitem < gdi->btree.nitem)
+   {
        if (!gdi->stack)
-           gdi->stack = ginPrepareFindLeafPage( &gdi->btree, rootBlkno );
+           gdi->stack = ginPrepareFindLeafPage(&gdi->btree, rootBlkno);
 
-       gdi->stack = ginFindLeafPage( &gdi->btree, gdi->stack );    
+       gdi->stack = ginFindLeafPage(&gdi->btree, gdi->stack);
 
-       if ( gdi->btree.findItem( &(gdi->btree), gdi->stack ) )
-           elog(ERROR,"item pointer (%u,%d) already exists", 
-               ItemPointerGetBlockNumber(gdi->btree.items + gdi->btree.curitem), 
-               ItemPointerGetOffsetNumber(gdi->btree.items + gdi->btree.curitem));
+       if (gdi->btree.findItem(&(gdi->btree), gdi->stack))
+           elog(ERROR, "item pointer (%u,%d) already exists",
+           ItemPointerGetBlockNumber(gdi->btree.items + gdi->btree.curitem),
+                ItemPointerGetOffsetNumber(gdi->btree.items + gdi->btree.curitem));
 
        ginInsertValue(&(gdi->btree), gdi->stack);
 
-       gdi->stack=NULL;
+       gdi->stack = NULL;
    }
 }
 
 Buffer
-scanBeginPostingTree( GinPostingTreeScan *gdi ) {
-   gdi->stack = ginFindLeafPage( &gdi->btree, gdi->stack );
+scanBeginPostingTree(GinPostingTreeScan *gdi)
+{
+   gdi->stack = ginFindLeafPage(&gdi->btree, gdi->stack);
    return gdi->stack->buffer;
 }
-
index 6e3cc75ce081362e26d14d3c04667aa75766f8a6..129c9550969f1944c33977852eb0fd88487dfa9f 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginentrypage.c
- *    page utilities routines for the postgres inverted index access method.
+ *   page utilities routines for the postgres inverted index access method.
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.3 2006/07/14 14:52:16 momjian Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.4 2006/10/04 00:29:47 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
  * 1) Posting list
  *     - itup->t_info & INDEX_SIZE_MASK contains size of tuple as usial
  *     - ItemPointerGetBlockNumber(&itup->t_tid) contains original
- *       size of tuple (without posting list). 
+ *       size of tuple (without posting list).
  *       Macroses: GinGetOrigSizePosting(itup) / GinSetOrigSizePosting(itup,n)
  *     - ItemPointerGetOffsetNumber(&itup->t_tid) contains number
  *       of elements in posting list (number of heap itempointer)
  *       Macroses: GinGetNPosting(itup) / GinSetNPosting(itup,n)
- *      - After usial part of tuple there is a posting list
+ *     - After usial part of tuple there is a posting list
  *       Macros: GinGetPosting(itup)
  * 2) Posting tree
  *     - itup->t_info & INDEX_SIZE_MASK contains size of tuple as usial
- *     - ItemPointerGetBlockNumber(&itup->t_tid) contains block number of 
+ *     - ItemPointerGetBlockNumber(&itup->t_tid) contains block number of
  *       root of posting tree
  *     - ItemPointerGetOffsetNumber(&itup->t_tid) contains magick number GIN_TREE_POSTING
  */
 IndexTuple
-GinFormTuple(GinState *ginstate, Datum key, ItemPointerData *ipd, uint32 nipd) {
-   bool    isnull=FALSE;
+GinFormTuple(GinState *ginstate, Datum key, ItemPointerData *ipd, uint32 nipd)
+{
+   bool        isnull = FALSE;
    IndexTuple  itup;
 
-   itup = index_form_tuple(ginstate->tupdesc, &key, &isnull);  
+   itup = index_form_tuple(ginstate->tupdesc, &key, &isnull);
 
-   GinSetOrigSizePosting( itup, IndexTupleSize(itup) );
+   GinSetOrigSizePosting(itup, IndexTupleSize(itup));
 
-   if ( nipd > 0 ) {
-       uint32 newsize = MAXALIGN(SHORTALIGN(IndexTupleSize(itup)) + sizeof(ItemPointerData)*nipd);
+   if (nipd > 0)
+   {
+       uint32      newsize = MAXALIGN(SHORTALIGN(IndexTupleSize(itup)) + sizeof(ItemPointerData) * nipd);
 
-       if ( newsize >= INDEX_SIZE_MASK )
+       if (newsize >= INDEX_SIZE_MASK)
            return NULL;
 
-       if ( newsize > TOAST_INDEX_TARGET && nipd > 1 )
+       if (newsize > TOAST_INDEX_TARGET && nipd > 1)
            return NULL;
 
-       itup = repalloc( itup, newsize );
+       itup = repalloc(itup, newsize);
 
        /* set new size */
-       itup->t_info &= ~INDEX_SIZE_MASK;  
+       itup->t_info &= ~INDEX_SIZE_MASK;
        itup->t_info |= newsize;
 
-       if ( ipd )
-           memcpy( GinGetPosting(itup), ipd, sizeof(ItemPointerData)*nipd ); 
-       GinSetNPosting(itup, nipd); 
-   } else {
-       GinSetNPosting(itup, 0); 
+       if (ipd)
+           memcpy(GinGetPosting(itup), ipd, sizeof(ItemPointerData) * nipd);
+       GinSetNPosting(itup, nipd);
+   }
+   else
+   {
+       GinSetNPosting(itup, 0);
    }
    return itup;
 }
@@ -74,31 +78,35 @@ GinFormTuple(GinState *ginstate, Datum key, ItemPointerData *ipd, uint32 nipd) {
  * so we don't use right bound, we use rightest key instead.
  */
 static IndexTuple
-getRightMostTuple(Page page) {
+getRightMostTuple(Page page)
+{
    OffsetNumber maxoff = PageGetMaxOffsetNumber(page);
+
    return (IndexTuple) PageGetItem(page, PageGetItemId(page, maxoff));
 }
 
 Datum
-ginGetHighKey(GinState *ginstate, Page page) {
-   IndexTuple  itup;
-   bool    isnull;
+ginGetHighKey(GinState *ginstate, Page page)
+{
+   IndexTuple  itup;
+   bool        isnull;
 
    itup = getRightMostTuple(page);
 
-   return index_getattr(itup, FirstOffsetNumber, ginstate->tupdesc, &isnull); 
+   return index_getattr(itup, FirstOffsetNumber, ginstate->tupdesc, &isnull);
 }
 
-static bool 
-entryIsMoveRight(GinBtree btree, Page page) {
-   Datum highkey;
+static bool
+entryIsMoveRight(GinBtree btree, Page page)
+{
+   Datum       highkey;
 
-   if ( GinPageRightMost(page) )
+   if (GinPageRightMost(page))
        return FALSE;
 
    highkey = ginGetHighKey(btree->ginstate, page);
 
-   if ( compareEntries(btree->ginstate, btree->entryValue, highkey) > 0 )
+   if (compareEntries(btree->ginstate, btree->entryValue, highkey) > 0)
        return TRUE;
 
    return FALSE;
@@ -109,16 +117,20 @@ entryIsMoveRight(GinBtree btree, Page page) {
  * page correctly choosen and searching value SHOULD be on page
  */
 static BlockNumber
-entryLocateEntry(GinBtree btree, GinBtreeStack *stack) {
-   OffsetNumber low, high, maxoff;
-   IndexTuple  itup = NULL;
-   int result;
-   Page page = BufferGetPage( stack->buffer );
-
-   Assert( !GinPageIsLeaf(page) );
-   Assert( !GinPageIsData(page) );
-
-   if ( btree->fullScan ) {
+entryLocateEntry(GinBtree btree, GinBtreeStack *stack)
+{
+   OffsetNumber low,
+               high,
+               maxoff;
+   IndexTuple  itup = NULL;
+   int         result;
+   Page        page = BufferGetPage(stack->buffer);
+
+   Assert(!GinPageIsLeaf(page));
+   Assert(!GinPageIsData(page));
+
+   if (btree->fullScan)
+   {
        stack->off = FirstOffsetNumber;
        stack->predictNumber *= PageGetMaxOffsetNumber(page);
        return btree->getLeftMostPage(btree, page);
@@ -126,39 +138,43 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack) {
 
    low = FirstOffsetNumber;
    maxoff = high = PageGetMaxOffsetNumber(page);
-   Assert( high >= low );
+   Assert(high >= low);
 
    high++;
 
-   while (high > low) {
+   while (high > low)
+   {
        OffsetNumber mid = low + ((high - low) / 2);
 
-       if ( mid == maxoff && GinPageRightMost(page) )
+       if (mid == maxoff && GinPageRightMost(page))
            /* Right infinity */
            result = -1;
-       else {
-           bool    isnull;
+       else
+       {
+           bool        isnull;
 
            itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid));
-           result = compareEntries(btree->ginstate, btree->entryValue, 
-               index_getattr(itup, FirstOffsetNumber, btree->ginstate->tupdesc, &isnull) );
+           result = compareEntries(btree->ginstate, btree->entryValue,
+                                   index_getattr(itup, FirstOffsetNumber, btree->ginstate->tupdesc, &isnull));
        }
 
-       if ( result == 0 ) {
+       if (result == 0)
+       {
            stack->off = mid;
-           Assert( GinItemPointerGetBlockNumber(&(itup)->t_tid) != GIN_ROOT_BLKNO );
+           Assert(GinItemPointerGetBlockNumber(&(itup)->t_tid) != GIN_ROOT_BLKNO);
            return GinItemPointerGetBlockNumber(&(itup)->t_tid);
-       } else if ( result > 0 )
+       }
+       else if (result > 0)
            low = mid + 1;
        else
            high = mid;
    }
 
-   Assert( high>=FirstOffsetNumber && high <= maxoff );
+   Assert(high >= FirstOffsetNumber && high <= maxoff);
 
    stack->off = high;
    itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, high));
-   Assert( GinItemPointerGetBlockNumber(&(itup)->t_tid) != GIN_ROOT_BLKNO );
+   Assert(GinItemPointerGetBlockNumber(&(itup)->t_tid) != GIN_ROOT_BLKNO);
    return GinItemPointerGetBlockNumber(&(itup)->t_tid);
 }
 
@@ -168,15 +184,18 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack) {
  * Returns true if value found on page.
  */
 static bool
-entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack) {
-   Page page = BufferGetPage( stack->buffer );
-   OffsetNumber low, high;
-   IndexTuple  itup;
+entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack)
+{
+   Page        page = BufferGetPage(stack->buffer);
+   OffsetNumber low,
+               high;
+   IndexTuple  itup;
 
-   Assert( GinPageIsLeaf(page) );
-   Assert( !GinPageIsData(page) );
+   Assert(GinPageIsLeaf(page));
+   Assert(!GinPageIsData(page));
 
-   if ( btree->fullScan ) {
+   if (btree->fullScan)
+   {
        stack->off = FirstOffsetNumber;
        return TRUE;
    }
@@ -184,26 +203,30 @@ entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack) {
    low = FirstOffsetNumber;
    high = PageGetMaxOffsetNumber(page);
 
-   if ( high < low ) {
+   if (high < low)
+   {
        stack->off = FirstOffsetNumber;
        return false;
    }
 
    high++;
 
-   while (high > low) {
+   while (high > low)
+   {
        OffsetNumber mid = low + ((high - low) / 2);
-       bool    isnull;
-       int     result;
+       bool        isnull;
+       int         result;
 
        itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid));
        result = compareEntries(btree->ginstate, btree->entryValue,
-           index_getattr(itup, FirstOffsetNumber, btree->ginstate->tupdesc, &isnull) );
+                               index_getattr(itup, FirstOffsetNumber, btree->ginstate->tupdesc, &isnull));
 
-       if ( result == 0 ) {
+       if (result == 0)
+       {
            stack->off = mid;
            return true;
-       } else if ( result > 0 ) 
+       }
+       else if (result > 0)
            low = mid + 1;
        else
            high = mid;
@@ -214,33 +237,40 @@ entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack) {
 }
 
 static OffsetNumber
-entryFindChildPtr(GinBtree btree, Page page, BlockNumber blkno, OffsetNumber storedOff) {
-   OffsetNumber i, maxoff = PageGetMaxOffsetNumber(page);
-   IndexTuple  itup;
+entryFindChildPtr(GinBtree btree, Page page, BlockNumber blkno, OffsetNumber storedOff)
+{
+   OffsetNumber i,
+               maxoff = PageGetMaxOffsetNumber(page);
+   IndexTuple  itup;
 
-   Assert( !GinPageIsLeaf(page) );
-   Assert( !GinPageIsData(page) );
+   Assert(!GinPageIsLeaf(page));
+   Assert(!GinPageIsData(page));
 
    /* if page isn't changed, we returns storedOff */
-   if ( storedOff>= FirstOffsetNumber && storedOff<=maxoff) {
+   if (storedOff >= FirstOffsetNumber && storedOff <= maxoff)
+   {
        itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, storedOff));
-       if ( GinItemPointerGetBlockNumber(&(itup)->t_tid) == blkno )
+       if (GinItemPointerGetBlockNumber(&(itup)->t_tid) == blkno)
            return storedOff;
 
-       /* we hope, that needed pointer goes to right. It's true
-           if there wasn't a deletion */
-       for( i=storedOff+1 ; i <= maxoff ; i++ ) {
+       /*
+        * we hope, that needed pointer goes to right. It's true if there
+        * wasn't a deletion
+        */
+       for (i = storedOff + 1; i <= maxoff; i++)
+       {
            itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, i));
-           if ( GinItemPointerGetBlockNumber(&(itup)->t_tid) == blkno )
+           if (GinItemPointerGetBlockNumber(&(itup)->t_tid) == blkno)
                return i;
        }
-       maxoff = storedOff-1;
+       maxoff = storedOff - 1;
    }
 
    /* last chance */
-   for( i=FirstOffsetNumber; i <= maxoff ; i++ ) { 
+   for (i = FirstOffsetNumber; i <= maxoff; i++)
+   {
        itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, i));
-       if ( GinItemPointerGetBlockNumber(&(itup)->t_tid) == blkno )
+       if (GinItemPointerGetBlockNumber(&(itup)->t_tid) == blkno)
            return i;
    }
 
@@ -248,31 +278,35 @@ entryFindChildPtr(GinBtree btree, Page page, BlockNumber blkno, OffsetNumber sto
 }
 
 static BlockNumber
-entryGetLeftMostPage(GinBtree btree, Page page) {
-   IndexTuple  itup;
+entryGetLeftMostPage(GinBtree btree, Page page)
+{
+   IndexTuple  itup;
 
-   Assert( !GinPageIsLeaf(page) );
-   Assert( !GinPageIsData(page) );
-   Assert( PageGetMaxOffsetNumber(page) >= FirstOffsetNumber );
+   Assert(!GinPageIsLeaf(page));
+   Assert(!GinPageIsData(page));
+   Assert(PageGetMaxOffsetNumber(page) >= FirstOffsetNumber);
 
    itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, FirstOffsetNumber));
-   return GinItemPointerGetBlockNumber(&(itup)->t_tid);    
+   return GinItemPointerGetBlockNumber(&(itup)->t_tid);
 }
 
 static bool
-entryIsEnoughSpace( GinBtree btree, Buffer buf, OffsetNumber off ) {
-   Size itupsz = 0;
-   Page page = BufferGetPage(buf);
+entryIsEnoughSpace(GinBtree btree, Buffer buf, OffsetNumber off)
+{
+   Size        itupsz = 0;
+   Page        page = BufferGetPage(buf);
+
+   Assert(btree->entry);
+   Assert(!GinPageIsData(page));
 
-   Assert( btree->entry );
-   Assert( !GinPageIsData(page) );
+   if (btree->isDelete)
+   {
+       IndexTuple  itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, off));
 
-   if ( btree->isDelete ) {
-       IndexTuple itup = (IndexTuple)PageGetItem(page, PageGetItemId(page, off));
-       itupsz = MAXALIGN( IndexTupleSize( itup ) ) + sizeof(ItemIdData);
+       itupsz = MAXALIGN(IndexTupleSize(itup)) + sizeof(ItemIdData);
    }
 
-   if (  PageGetFreeSpace(page) + itupsz >=  MAXALIGN(IndexTupleSize(btree->entry)) + sizeof(ItemIdData) )
+   if (PageGetFreeSpace(page) + itupsz >= MAXALIGN(IndexTupleSize(btree->entry)) + sizeof(ItemIdData))
        return true;
 
    return false;
@@ -284,19 +318,23 @@ entryIsEnoughSpace( GinBtree btree, Buffer buf, OffsetNumber off ) {
  * if child split is occured
  */
 static BlockNumber
-entryPreparePage( GinBtree btree, Page page, OffsetNumber off) {
+entryPreparePage(GinBtree btree, Page page, OffsetNumber off)
+{
    BlockNumber ret = InvalidBlockNumber;
 
-   Assert( btree->entry );
-   Assert( !GinPageIsData(page) );
+   Assert(btree->entry);
+   Assert(!GinPageIsData(page));
 
-   if ( btree->isDelete ) {
-       Assert( GinPageIsLeaf(page) );
+   if (btree->isDelete)
+   {
+       Assert(GinPageIsLeaf(page));
        PageIndexTupleDelete(page, off);
    }
 
-   if ( !GinPageIsLeaf(page) && btree->rightblkno != InvalidBlockNumber )  {
-       IndexTuple itup = (IndexTuple)PageGetItem(page, PageGetItemId(page, off));
+   if (!GinPageIsLeaf(page) && btree->rightblkno != InvalidBlockNumber)
+   {
+       IndexTuple  itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, off));
+
        ItemPointerSet(&itup->t_tid, btree->rightblkno, InvalidOffsetNumber);
        ret = btree->rightblkno;
    }
@@ -310,22 +348,23 @@ entryPreparePage( GinBtree btree, Page page, OffsetNumber off) {
  * Place tuple on page and fills WAL record
  */
 static void
-entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prdata) {
-   Page page = BufferGetPage(buf);
+entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prdata)
+{
+   Page        page = BufferGetPage(buf);
    static XLogRecData rdata[3];
-   OffsetNumber    placed;
-   static  ginxlogInsert   data;
+   OffsetNumber placed;
+   static ginxlogInsert data;
 
    *prdata = rdata;
-   data.updateBlkno = entryPreparePage( btree, page, off );
+   data.updateBlkno = entryPreparePage(btree, page, off);
 
-   placed = PageAddItem( page, (Item)btree->entry, IndexTupleSize(btree->entry), off, LP_USED);
-   if ( placed != off )
+   placed = PageAddItem(page, (Item) btree->entry, IndexTupleSize(btree->entry), off, LP_USED);
+   if (placed != off)
        elog(ERROR, "failed to add item to index page in \"%s\"",
-           RelationGetRelationName(btree->index));
+            RelationGetRelationName(btree->index));
 
    data.node = btree->index->rd_node;
-   data.blkno = BufferGetBlockNumber( buf );
+   data.blkno = BufferGetBlockNumber(buf);
    data.offset = off;
    data.nitem = 1;
    data.isDelete = btree->isDelete;
@@ -358,87 +397,99 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
  * an equal number!
  */
 static Page
-entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRecData **prdata) {
+entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRecData **prdata)
+{
    static XLogRecData rdata[2];
-   OffsetNumber    i, maxoff, separator=InvalidOffsetNumber;
-   Size    totalsize=0;
-   Size    lsize = 0, size;
-   static char tupstore[ 2*BLCKSZ ];
-   char    *ptr;
-   IndexTuple itup, leftrightmost=NULL;
-   static ginxlogSplit data;
-   Datum   value;
-   bool    isnull;
-   Page    page;
-   Page    lpage = GinPageGetCopyPage( BufferGetPage( lbuf ) );
-   Page    rpage = BufferGetPage( rbuf );
-   Size    pageSize = PageGetPageSize( lpage ); 
+   OffsetNumber i,
+               maxoff,
+               separator = InvalidOffsetNumber;
+   Size        totalsize = 0;
+   Size        lsize = 0,
+               size;
+   static char tupstore[2 * BLCKSZ];
+   char       *ptr;
+   IndexTuple  itup,
+               leftrightmost = NULL;
+   static ginxlogSplit data;
+   Datum       value;
+   bool        isnull;
+   Page        page;
+   Page        lpage = GinPageGetCopyPage(BufferGetPage(lbuf));
+   Page        rpage = BufferGetPage(rbuf);
+   Size        pageSize = PageGetPageSize(lpage);
 
    *prdata = rdata;
-   data.leftChildBlkno = ( GinPageIsLeaf(lpage) ) ? 
-           InvalidOffsetNumber : GinItemPointerGetBlockNumber( &(btree->entry->t_tid) );
-   data.updateBlkno = entryPreparePage( btree, lpage, off );
+   data.leftChildBlkno = (GinPageIsLeaf(lpage)) ?
+       InvalidOffsetNumber : GinItemPointerGetBlockNumber(&(btree->entry->t_tid));
+   data.updateBlkno = entryPreparePage(btree, lpage, off);
 
    maxoff = PageGetMaxOffsetNumber(lpage);
-   ptr = tupstore; 
+   ptr = tupstore;
 
-   for(i=FirstOffsetNumber; i<=maxoff; i++) {
-       if ( i==off ) {
-           size = MAXALIGN( IndexTupleSize(btree->entry) );
+   for (i = FirstOffsetNumber; i <= maxoff; i++)
+   {
+       if (i == off)
+       {
+           size = MAXALIGN(IndexTupleSize(btree->entry));
            memcpy(ptr, btree->entry, size);
-           ptr+=size;
+           ptr += size;
            totalsize += size + sizeof(ItemIdData);
        }
 
-       itup = (IndexTuple)PageGetItem(lpage, PageGetItemId(lpage, i));
-       size = MAXALIGN( IndexTupleSize(itup) );
+       itup = (IndexTuple) PageGetItem(lpage, PageGetItemId(lpage, i));
+       size = MAXALIGN(IndexTupleSize(itup));
        memcpy(ptr, itup, size);
-       ptr+=size;
+       ptr += size;
        totalsize += size + sizeof(ItemIdData);
    }
 
-   if ( off==maxoff+1 ) {
-       size = MAXALIGN( IndexTupleSize(btree->entry) );
+   if (off == maxoff + 1)
+   {
+       size = MAXALIGN(IndexTupleSize(btree->entry));
        memcpy(ptr, btree->entry, size);
-       ptr+=size;
+       ptr += size;
        totalsize += size + sizeof(ItemIdData);
    }
 
-   GinInitPage( rpage, GinPageGetOpaque(lpage)->flags, pageSize ); 
-   GinInitPage( lpage, GinPageGetOpaque(rpage)->flags, pageSize ); 
+   GinInitPage(rpage, GinPageGetOpaque(lpage)->flags, pageSize);
+   GinInitPage(lpage, GinPageGetOpaque(rpage)->flags, pageSize);
 
    ptr = tupstore;
-   maxoff++;   
+   maxoff++;
    lsize = 0;
 
    page = lpage;
-   for(i=FirstOffsetNumber; i<=maxoff; i++) {
-       itup = (IndexTuple)ptr;
-
-       if ( lsize > totalsize/2 ) {
-           if ( separator==InvalidOffsetNumber )
-               separator = i-1;
+   for (i = FirstOffsetNumber; i <= maxoff; i++)
+   {
+       itup = (IndexTuple) ptr;
+
+       if (lsize > totalsize / 2)
+       {
+           if (separator == InvalidOffsetNumber)
+               separator = i - 1;
            page = rpage;
-       } else {
+       }
+       else
+       {
            leftrightmost = itup;
-           lsize += MAXALIGN( IndexTupleSize(itup) ) + sizeof(ItemIdData);
+           lsize += MAXALIGN(IndexTupleSize(itup)) + sizeof(ItemIdData);
        }
 
-       if ( PageAddItem( page, (Item)itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber )
+       if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
            elog(ERROR, "failed to add item to index page in \"%s\"",
-               RelationGetRelationName(btree->index));
-       ptr += MAXALIGN( IndexTupleSize(itup) );
+                RelationGetRelationName(btree->index));
+       ptr += MAXALIGN(IndexTupleSize(itup));
    }
-   
+
    value = index_getattr(leftrightmost, FirstOffsetNumber, btree->ginstate->tupdesc, &isnull);
-   btree->entry = GinFormTuple( btree->ginstate, value, NULL, 0);
-   ItemPointerSet(&(btree->entry)->t_tid, BufferGetBlockNumber( lbuf ), InvalidOffsetNumber);
-   btree->rightblkno = BufferGetBlockNumber( rbuf );
-       
+   btree->entry = GinFormTuple(btree->ginstate, value, NULL, 0);
+   ItemPointerSet(&(btree->entry)->t_tid, BufferGetBlockNumber(lbuf), InvalidOffsetNumber);
+   btree->rightblkno = BufferGetBlockNumber(rbuf);
+
    data.node = btree->index->rd_node;
    data.rootBlkno = InvalidBlockNumber;
-   data.lblkno = BufferGetBlockNumber( lbuf );
-   data.rblkno = BufferGetBlockNumber( rbuf );
+   data.lblkno = BufferGetBlockNumber(lbuf);
+   data.rblkno = BufferGetBlockNumber(rbuf);
    data.separator = separator;
    data.nitem = maxoff;
    data.isData = FALSE;
@@ -458,23 +509,28 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
    return lpage;
 }
 
-/* 
+/*
  * return newly allocate rightmost tuple
  */
 IndexTuple
-ginPageGetLinkItup(Buffer buf) {
-   IndexTuple itup, nitup;
-   Page    page = BufferGetPage(buf);
-
-   itup = getRightMostTuple( page );
-   if ( GinPageIsLeaf(page) && !GinIsPostingTree(itup) ) {
-       nitup = (IndexTuple)palloc( MAXALIGN(GinGetOrigSizePosting(itup)) );
-       memcpy( nitup, itup, GinGetOrigSizePosting(itup) );
+ginPageGetLinkItup(Buffer buf)
+{
+   IndexTuple  itup,
+               nitup;
+   Page        page = BufferGetPage(buf);
+
+   itup = getRightMostTuple(page);
+   if (GinPageIsLeaf(page) && !GinIsPostingTree(itup))
+   {
+       nitup = (IndexTuple) palloc(MAXALIGN(GinGetOrigSizePosting(itup)));
+       memcpy(nitup, itup, GinGetOrigSizePosting(itup));
        nitup->t_info &= ~INDEX_SIZE_MASK;
        nitup->t_info |= GinGetOrigSizePosting(itup);
-   } else {
-       nitup = (IndexTuple)palloc( MAXALIGN(IndexTupleSize(itup)) );
-       memcpy( nitup, itup, IndexTupleSize(itup) );
+   }
+   else
+   {
+       nitup = (IndexTuple) palloc(MAXALIGN(IndexTupleSize(itup)));
+       memcpy(nitup, itup, IndexTupleSize(itup));
    }
 
    ItemPointerSet(&nitup->t_tid, BufferGetBlockNumber(buf), InvalidOffsetNumber);
@@ -486,23 +542,25 @@ ginPageGetLinkItup(Buffer buf) {
  * Also called from ginxlog, should not use btree
  */
 void
-entryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf) {
-   Page page;
-   IndexTuple itup;
+entryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
+{
+   Page        page;
+   IndexTuple  itup;
 
    page = BufferGetPage(root);
 
-   itup = ginPageGetLinkItup( lbuf );
-   if ( PageAddItem( page, (Item)itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber )
+   itup = ginPageGetLinkItup(lbuf);
+   if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
        elog(ERROR, "failed to add item to index root page");
 
-   itup = ginPageGetLinkItup( rbuf );
-   if ( PageAddItem( page, (Item)itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber )
+   itup = ginPageGetLinkItup(rbuf);
+   if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
        elog(ERROR, "failed to add item to index root page");
 }
 
 void
-prepareEntryScan( GinBtree btree, Relation index, Datum value, GinState *ginstate) {
+prepareEntryScan(GinBtree btree, Relation index, Datum value, GinState *ginstate)
+{
    memset(btree, 0, sizeof(GinBtreeData));
 
    btree->isMoveRight = entryIsMoveRight;
@@ -524,4 +582,3 @@ prepareEntryScan( GinBtree btree, Relation index, Datum value, GinState *ginstat
    btree->fullScan = FALSE;
    btree->isBuild = FALSE;
 }
-
index d40612f3ada0551460d428cdb80a8de323bc9d95..090bbe4f256ca03ce67021d43e2b5d77a2c9aaa2 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginget.c
- *    fetch tuples from a GIN scan.
+ *   fetch tuples from a GIN scan.
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.2 2006/07/14 14:52:16 momjian Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.3 2006/10/04 00:29:47 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
 #include "utils/memutils.h"
 
 static OffsetNumber
-findItemInPage( Page page, ItemPointer item, OffsetNumber off ) {
+findItemInPage(Page page, ItemPointer item, OffsetNumber off)
+{
    OffsetNumber maxoff = GinPageGetOpaque(page)->maxoff;
-   int res;
+   int         res;
 
-   for(; off<=maxoff; off++) {
-       res = compareItemPointers( item, (ItemPointer)GinDataPageGetItem(page, off) );
-       Assert( res>= 0 );
+   for (; off <= maxoff; off++)
+   {
+       res = compareItemPointers(item, (ItemPointer) GinDataPageGetItem(page, off));
+       Assert(res >= 0);
 
-       if ( res == 0 )
+       if (res == 0)
            return off;
    }
 
@@ -38,24 +40,29 @@ findItemInPage( Page page, ItemPointer item, OffsetNumber off ) {
  * Stop* functions unlock buffer (but don't release!)
  */
 static void
-startScanEntry( Relation index, GinState *ginstate, GinScanEntry entry, bool firstCall ) {
-   if ( entry->master != NULL ) {
+startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry, bool firstCall)
+{
+   if (entry->master != NULL)
+   {
        entry->isFinished = entry->master->isFinished;
        return;
    }
 
-   if ( firstCall ) {
-       /* at first call we should find entry, and
-          begin scan of posting tree or just store posting list in memory */
+   if (firstCall)
+   {
+       /*
+        * at first call we should find entry, and begin scan of posting tree
+        * or just store posting list in memory
+        */
        GinBtreeData btreeEntry;
-       GinBtreeStack   *stackEntry;
-       Page page;
-       bool    needUnlock = TRUE;
+       GinBtreeStack *stackEntry;
+       Page        page;
+       bool        needUnlock = TRUE;
 
-       prepareEntryScan( &btreeEntry, index, entry->entry, ginstate );
+       prepareEntryScan(&btreeEntry, index, entry->entry, ginstate);
        btreeEntry.searchMode = TRUE;
        stackEntry = ginFindLeafPage(&btreeEntry, NULL);
-       page = BufferGetPage( stackEntry->buffer );
+       page = BufferGetPage(stackEntry->buffer);
 
        entry->isFinished = TRUE;
        entry->buffer = InvalidBuffer;
@@ -65,103 +72,115 @@ startScanEntry( Relation index, GinState *ginstate, GinScanEntry entry, bool fir
        entry->reduceResult = FALSE;
        entry->predictNumberResult = 0;
 
-       if ( btreeEntry.findItem( &btreeEntry, stackEntry ) ) {
-           IndexTuple itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, stackEntry->off));
+       if (btreeEntry.findItem(&btreeEntry, stackEntry))
+       {
+           IndexTuple  itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, stackEntry->off));
 
-           if ( GinIsPostingTree(itup) ) {
+           if (GinIsPostingTree(itup))
+           {
                BlockNumber rootPostingTree = GinGetPostingTree(itup);
                GinPostingTreeScan *gdi;
-               Page    page;
+               Page        page;
 
                LockBuffer(stackEntry->buffer, GIN_UNLOCK);
-               needUnlock  = FALSE;
-               gdi = prepareScanPostingTree( index, rootPostingTree, TRUE );
+               needUnlock = FALSE;
+               gdi = prepareScanPostingTree(index, rootPostingTree, TRUE);
 
-               entry->buffer = scanBeginPostingTree( gdi );
-               IncrBufferRefCount( entry->buffer );
+               entry->buffer = scanBeginPostingTree(gdi);
+               IncrBufferRefCount(entry->buffer);
 
-               page = BufferGetPage( entry->buffer );
-               entry->predictNumberResult = gdi->stack->predictNumber * GinPageGetOpaque(page)->maxoff;  
+               page = BufferGetPage(entry->buffer);
+               entry->predictNumberResult = gdi->stack->predictNumber * GinPageGetOpaque(page)->maxoff;
 
-               freeGinBtreeStack( gdi->stack );
-               pfree( gdi );
+               freeGinBtreeStack(gdi->stack);
+               pfree(gdi);
                entry->isFinished = FALSE;
-           } else if ( GinGetNPosting(itup) > 0 ) {
+           }
+           else if (GinGetNPosting(itup) > 0)
+           {
                entry->nlist = GinGetNPosting(itup);
-               entry->list = (ItemPointerData*)palloc( sizeof(ItemPointerData) * entry->nlist );
-               memcpy( entry->list, GinGetPosting(itup), sizeof(ItemPointerData) * entry->nlist );
+               entry->list = (ItemPointerData *) palloc(sizeof(ItemPointerData) * entry->nlist);
+               memcpy(entry->list, GinGetPosting(itup), sizeof(ItemPointerData) * entry->nlist);
                entry->isFinished = FALSE;
            }
        }
 
-       if ( needUnlock )
+       if (needUnlock)
            LockBuffer(stackEntry->buffer, GIN_UNLOCK);
-       freeGinBtreeStack( stackEntry );
-   } else if ( entry->buffer != InvalidBuffer ) {
+       freeGinBtreeStack(stackEntry);
+   }
+   else if (entry->buffer != InvalidBuffer)
+   {
        /* we should find place were we was stopped */
        BlockNumber blkno;
-       Page page;
+       Page        page;
 
-       LockBuffer( entry->buffer, GIN_SHARE );
+       LockBuffer(entry->buffer, GIN_SHARE);
 
-       if ( !ItemPointerIsValid( &entry->curItem ) )
+       if (!ItemPointerIsValid(&entry->curItem))
            /* start position */
            return;
-       Assert( entry->offset!=InvalidOffsetNumber );
+       Assert(entry->offset != InvalidOffsetNumber);
 
-       page = BufferGetPage( entry->buffer );
+       page = BufferGetPage(entry->buffer);
 
        /* try to find curItem in current buffer */
-       if ( (entry->offset=findItemInPage(page , &entry->curItem, entry->offset))!=InvalidOffsetNumber )
+       if ((entry->offset = findItemInPage(page, &entry->curItem, entry->offset)) != InvalidOffsetNumber)
            return;
 
        /* walk to right */
-       while( (blkno = GinPageGetOpaque( page )->rightlink)!=InvalidBlockNumber ) {
-           LockBuffer( entry->buffer, GIN_UNLOCK );
-           entry->buffer = ReleaseAndReadBuffer( entry->buffer, index, blkno );
-           LockBuffer( entry->buffer, GIN_SHARE );
-           page = BufferGetPage( entry->buffer );
-
-           if ( (entry->offset=findItemInPage(page , &entry->curItem, FirstOffsetNumber))!=InvalidOffsetNumber )
+       while ((blkno = GinPageGetOpaque(page)->rightlink) != InvalidBlockNumber)
+       {
+           LockBuffer(entry->buffer, GIN_UNLOCK);
+           entry->buffer = ReleaseAndReadBuffer(entry->buffer, index, blkno);
+           LockBuffer(entry->buffer, GIN_SHARE);
+           page = BufferGetPage(entry->buffer);
+
+           if ((entry->offset = findItemInPage(page, &entry->curItem, FirstOffsetNumber)) != InvalidOffsetNumber)
                return;
        }
 
-       elog(ERROR,"Logic error: lost previously founded ItemId");
+       elog(ERROR, "Logic error: lost previously founded ItemId");
    }
 }
 
 static void
-stopScanEntry( GinScanEntry entry ) {
-   if ( entry->buffer != InvalidBuffer )
-       LockBuffer( entry->buffer, GIN_UNLOCK );
+stopScanEntry(GinScanEntry entry)
+{
+   if (entry->buffer != InvalidBuffer)
+       LockBuffer(entry->buffer, GIN_UNLOCK);
 }
 
 static void
-startScanKey( Relation index, GinState *ginstate, GinScanKey key ) {
-   uint32 i;
-
-   for(i=0;inentries;i++)
-       startScanEntry( index, ginstate, key->scanEntry+i, key->firstCall );
-   
-   if ( key->firstCall ) { 
-       memset( key->entryRes, TRUE, sizeof(bool) * key->nentries );
+startScanKey(Relation index, GinState *ginstate, GinScanKey key)
+{
+   uint32      i;
+
+   for (i = 0; i < key->nentries; i++)
+       startScanEntry(index, ginstate, key->scanEntry + i, key->firstCall);
+
+   if (key->firstCall)
+   {
+       memset(key->entryRes, TRUE, sizeof(bool) * key->nentries);
        key->isFinished = FALSE;
        key->firstCall = FALSE;
 
-       if ( GinFuzzySearchLimit > 0 ) {
+       if (GinFuzzySearchLimit > 0)
+       {
            /*
-            * If all of keys more than treshold we will try to reduce
-            * result, we hope (and only hope, for intersection operation of array
-            * our supposition isn't true), that total result will not more
-            * than minimal predictNumberResult.
+            * If all of keys more than treshold we will try to reduce result,
+            * we hope (and only hope, for intersection operation of array our
+            * supposition isn't true), that total result will not more than
+            * minimal predictNumberResult.
             */
 
-           for(i=0;inentries;i++)
-               if ( key->scanEntry[i].predictNumberResult <= key->nentries * GinFuzzySearchLimit )
-                   return; 
-           
-           for(i=0;inentries;i++)
-               if ( key->scanEntry[i].predictNumberResult > key->nentries * GinFuzzySearchLimit ) { 
+           for (i = 0; i < key->nentries; i++)
+               if (key->scanEntry[i].predictNumberResult <= key->nentries * GinFuzzySearchLimit)
+                   return;
+
+           for (i = 0; i < key->nentries; i++)
+               if (key->scanEntry[i].predictNumberResult > key->nentries * GinFuzzySearchLimit)
+               {
                    key->scanEntry[i].predictNumberResult /= key->nentries;
                    key->scanEntry[i].reduceResult = TRUE;
                }
@@ -170,50 +189,60 @@ startScanKey( Relation index, GinState *ginstate, GinScanKey key ) {
 }
 
 static void
-stopScanKey( GinScanKey key ) {
-   uint32 i;
+stopScanKey(GinScanKey key)
+{
+   uint32      i;
 
-   for(i=0;inentries;i++)
-       stopScanEntry( key->scanEntry+i );
+   for (i = 0; i < key->nentries; i++)
+       stopScanEntry(key->scanEntry + i);
 }
 
 static void
-startScan( IndexScanDesc scan ) {
-   uint32 i;
-   GinScanOpaque   so = (GinScanOpaque) scan->opaque;
+startScan(IndexScanDesc scan)
+{
+   uint32      i;
+   GinScanOpaque so = (GinScanOpaque) scan->opaque;
 
-   for(i=0; inkeys; i++) 
-       startScanKey( scan->indexRelation, &so->ginstate, so->keys + i ); 
+   for (i = 0; i < so->nkeys; i++)
+       startScanKey(scan->indexRelation, &so->ginstate, so->keys + i);
 }
 
 static void
-stopScan( IndexScanDesc scan ) {
-   uint32 i;
-   GinScanOpaque   so = (GinScanOpaque) scan->opaque;
+stopScan(IndexScanDesc scan)
+{
+   uint32      i;
+   GinScanOpaque so = (GinScanOpaque) scan->opaque;
 
-   for(i=0; inkeys; i++) 
-       stopScanKey( so->keys + i ); 
+   for (i = 0; i < so->nkeys; i++)
+       stopScanKey(so->keys + i);
 }
 
 
 static void
-entryGetNextItem( Relation index, GinScanEntry entry ) {
-   Page page = BufferGetPage( entry->buffer );
+entryGetNextItem(Relation index, GinScanEntry entry)
+{
+   Page        page = BufferGetPage(entry->buffer);
 
    entry->offset++;
-   if ( entry->offset <= GinPageGetOpaque( page )->maxoff && GinPageGetOpaque( page )->maxoff >= FirstOffsetNumber ) { 
-       entry->curItem = *(ItemPointerData*)GinDataPageGetItem(page, entry->offset);
-   } else {
-       BlockNumber blkno = GinPageGetOpaque( page )->rightlink;
-           
-       LockBuffer( entry->buffer, GIN_UNLOCK );
-       if ( blkno == InvalidBlockNumber ) {
-           ReleaseBuffer( entry->buffer );
+   if (entry->offset <= GinPageGetOpaque(page)->maxoff && GinPageGetOpaque(page)->maxoff >= FirstOffsetNumber)
+   {
+       entry->curItem = *(ItemPointerData *) GinDataPageGetItem(page, entry->offset);
+   }
+   else
+   {
+       BlockNumber blkno = GinPageGetOpaque(page)->rightlink;
+
+       LockBuffer(entry->buffer, GIN_UNLOCK);
+       if (blkno == InvalidBlockNumber)
+       {
+           ReleaseBuffer(entry->buffer);
            entry->buffer = InvalidBuffer;
            entry->isFinished = TRUE;
-       } else {
-           entry->buffer = ReleaseAndReadBuffer( entry->buffer, index, blkno );
-           LockBuffer( entry->buffer, GIN_SHARE );
+       }
+       else
+       {
+           entry->buffer = ReleaseAndReadBuffer(entry->buffer, index, blkno);
+           LockBuffer(entry->buffer, GIN_SHARE);
            entry->offset = InvalidOffsetNumber;
            entryGetNextItem(index, entry);
        }
@@ -221,29 +250,37 @@ entryGetNextItem( Relation index, GinScanEntry entry ) {
 }
 
 #define gin_rand() (((double) random()) / ((double) MAX_RANDOM_VALUE))
-#define dropItem(e)    ( gin_rand() > ((double)GinFuzzySearchLimit)/((double)((e)->predictNumberResult)) ) 
+#define dropItem(e) ( gin_rand() > ((double)GinFuzzySearchLimit)/((double)((e)->predictNumberResult)) )
 
 /*
- * Sets entry->curItem to new found heap item pointer for one 
+ * Sets entry->curItem to new found heap item pointer for one
  * entry of one scan key
  */
 static bool
-entryGetItem( Relation index, GinScanEntry entry ) {
-   if ( entry->master ) {
+entryGetItem(Relation index, GinScanEntry entry)
+{
+   if (entry->master)
+   {
        entry->isFinished = entry->master->isFinished;
        entry->curItem = entry->master->curItem;
-   } else if ( entry->list ) {
+   }
+   else if (entry->list)
+   {
        entry->offset++;
-       if ( entry->offset <= entry->nlist ) 
-           entry->curItem = entry->list[ entry->offset - 1 ];
-       else {
-           ItemPointerSet( &entry->curItem, InvalidBlockNumber, InvalidOffsetNumber );
+       if (entry->offset <= entry->nlist)
+           entry->curItem = entry->list[entry->offset - 1];
+       else
+       {
+           ItemPointerSet(&entry->curItem, InvalidBlockNumber, InvalidOffsetNumber);
            entry->isFinished = TRUE;
        }
-   } else {
-       do {
+   }
+   else
+   {
+       do
+       {
            entryGetNextItem(index, entry);
-       } while ( entry->isFinished == FALSE && entry->reduceResult == TRUE && dropItem(entry) ); 
+       } while (entry->isFinished == FALSE && entry->reduceResult == TRUE && dropItem(entry));
    }
 
    return entry->isFinished;
@@ -254,155 +291,180 @@ entryGetItem( Relation index, GinScanEntry entry ) {
  * returns isFinished!
  */
 static bool
-keyGetItem( Relation index, GinState *ginstate, MemoryContext tempCtx, GinScanKey key ) { 
-   uint32 i;
-   GinScanEntry    entry;
-   bool res;
-   MemoryContext   oldCtx;
-
-   if ( key->isFinished )
+keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx, GinScanKey key)
+{
+   uint32      i;
+   GinScanEntry entry;
+   bool        res;
+   MemoryContext oldCtx;
+
+   if (key->isFinished)
        return TRUE;
 
-   do {
-       /* move forward from previously value and set new curItem,
-          which is minimal from entries->curItems */
-       ItemPointerSetMax( &key->curItem );
-       for(i=0;inentries;i++) {
-           entry = key->scanEntry+i;
-   
-           if ( key->entryRes[i] ) {
-               if ( entry->isFinished == FALSE && entryGetItem(index, entry) == FALSE ) {
-                   if (compareItemPointers( &entry->curItem, &key->curItem ) < 0)
+   do
+   {
+       /*
+        * move forward from previously value and set new curItem, which is
+        * minimal from entries->curItems
+        */
+       ItemPointerSetMax(&key->curItem);
+       for (i = 0; i < key->nentries; i++)
+       {
+           entry = key->scanEntry + i;
+
+           if (key->entryRes[i])
+           {
+               if (entry->isFinished == FALSE && entryGetItem(index, entry) == FALSE)
+               {
+                   if (compareItemPointers(&entry->curItem, &key->curItem) < 0)
                        key->curItem = entry->curItem;
-               } else
+               }
+               else
                    key->entryRes[i] = FALSE;
-           } else if ( entry->isFinished == FALSE ) { 
-               if (compareItemPointers( &entry->curItem, &key->curItem ) < 0)
+           }
+           else if (entry->isFinished == FALSE)
+           {
+               if (compareItemPointers(&entry->curItem, &key->curItem) < 0)
                    key->curItem = entry->curItem;
-           } 
+           }
        }
 
-       if ( ItemPointerIsMax( &key->curItem ) ) {
+       if (ItemPointerIsMax(&key->curItem))
+       {
            /* all entries are finished */
            key->isFinished = TRUE;
            return TRUE;
        }
-   
-       if ( key->nentries == 1 ) {
+
+       if (key->nentries == 1)
+       {
            /* we can do not call consistentFn !! */
            key->entryRes[0] = TRUE;
            return FALSE;
        }
 
        /* setting up array for consistentFn */
-       for(i=0;inentries;i++) {
-           entry = key->scanEntry+i;
-   
-           if ( entry->isFinished == FALSE && compareItemPointers( &entry->curItem, &key->curItem )==0 )
+       for (i = 0; i < key->nentries; i++)
+       {
+           entry = key->scanEntry + i;
+
+           if (entry->isFinished == FALSE && compareItemPointers(&entry->curItem, &key->curItem) == 0)
                key->entryRes[i] = TRUE;
            else
                key->entryRes[i] = FALSE;
        }
 
        oldCtx = MemoryContextSwitchTo(tempCtx);
-       res = DatumGetBool( FunctionCall3(
-                                   &ginstate->consistentFn,
-                                   PointerGetDatum( key->entryRes ),
-                                   UInt16GetDatum( key->strategy ),
-                                   key->query
-                       ));
+       res = DatumGetBool(FunctionCall3(
+                                        &ginstate->consistentFn,
+                                        PointerGetDatum(key->entryRes),
+                                        UInt16GetDatum(key->strategy),
+                                        key->query
+                                        ));
        MemoryContextSwitchTo(oldCtx);
        MemoryContextReset(tempCtx);
-   } while( !res );
-                   
+   } while (!res);
+
    return FALSE;
 }
 
 /*
- * Get heap item pointer from scan 
- * returns true if found 
+ * Get heap item pointer from scan
+ * returns true if found
  */
 static bool
-scanGetItem( IndexScanDesc scan, ItemPointerData *item ) {
-   uint32 i;
-   GinScanOpaque   so = (GinScanOpaque) scan->opaque;
-
-   ItemPointerSetMin( item ); 
-   for(i=0;inkeys;i++) {
-       GinScanKey key = so->keys+i;
-
-       if ( keyGetItem( scan->indexRelation, &so->ginstate, so->tempCtx, key )==FALSE ) {
-           if ( compareItemPointers( item, &key->curItem ) < 0 )
+scanGetItem(IndexScanDesc scan, ItemPointerData *item)
+{
+   uint32      i;
+   GinScanOpaque so = (GinScanOpaque) scan->opaque;
+
+   ItemPointerSetMin(item);
+   for (i = 0; i < so->nkeys; i++)
+   {
+       GinScanKey  key = so->keys + i;
+
+       if (keyGetItem(scan->indexRelation, &so->ginstate, so->tempCtx, key) == FALSE)
+       {
+           if (compareItemPointers(item, &key->curItem) < 0)
                *item = key->curItem;
-       } else
-           return FALSE; /* finshed one of keys */
+       }
+       else
+           return FALSE;       /* finshed one of keys */
    }
-               
-   for(i=1;i<=so->nkeys;i++) {
-       GinScanKey key = so->keys+i-1;
 
-       for(;;) {
-           int cmp = compareItemPointers( item, &key->curItem );
+   for (i = 1; i <= so->nkeys; i++)
+   {
+       GinScanKey  key = so->keys + i - 1;
+
+       for (;;)
+       {
+           int         cmp = compareItemPointers(item, &key->curItem);
 
-           if ( cmp == 0 )
+           if (cmp == 0)
                break;
-           else if ( cmp > 0 ) {
-               if ( keyGetItem( scan->indexRelation, &so->ginstate, so->tempCtx, key )==TRUE )
-                   return FALSE; /* finshed one of keys */
-           } else { /* returns to begin */
+           else if (cmp > 0)
+           {
+               if (keyGetItem(scan->indexRelation, &so->ginstate, so->tempCtx, key) == TRUE)
+                   return FALSE;       /* finshed one of keys */
+           }
+           else
+           {                   /* returns to begin */
                *item = key->curItem;
-               i=0;
+               i = 0;
                break;
            }
        }
    }
 
-   return TRUE;    
+   return TRUE;
 }
 
 #define GinIsNewKey(s)     ( ((GinScanOpaque) scan->opaque)->keys == NULL )
 
-Datum 
-gingetmulti(PG_FUNCTION_ARGS) {
-    IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
+Datum
+gingetmulti(PG_FUNCTION_ARGS)
+{
+   IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
    ItemPointer tids = (ItemPointer) PG_GETARG_POINTER(1);
-   int32       max_tids = PG_GETARG_INT32(2);
-   int32      *returned_tids = (int32 *) PG_GETARG_POINTER(3);
+   int32       max_tids = PG_GETARG_INT32(2);
+   int32      *returned_tids = (int32 *) PG_GETARG_POINTER(3);
 
-   if ( GinIsNewKey(scan) )
-       newScanKey( scan );
+   if (GinIsNewKey(scan))
+       newScanKey(scan);
 
-   startScan( scan );
+   startScan(scan);
 
    *returned_tids = 0;
 
-   do {
-       if ( scanGetItem( scan, tids + *returned_tids ) ) 
+   do
+   {
+       if (scanGetItem(scan, tids + *returned_tids))
            (*returned_tids)++;
        else
            break;
-   } while ( *returned_tids < max_tids );
+   } while (*returned_tids < max_tids);
 
-   stopScan( scan );
+   stopScan(scan);
 
    PG_RETURN_BOOL(*returned_tids == max_tids);
 }
 
 Datum
-gingettuple(PG_FUNCTION_ARGS) {
+gingettuple(PG_FUNCTION_ARGS)
+{
    IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
    ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
-   bool res;
+   bool        res;
 
-   if ( dir != ForwardScanDirection )
+   if (dir != ForwardScanDirection)
        elog(ERROR, "Gin doesn't support other scan directions than forward");
-   
-   if ( GinIsNewKey(scan) )
-       newScanKey( scan );
 
-   startScan( scan );
+   if (GinIsNewKey(scan))
+       newScanKey(scan);
+
+   startScan(scan);
    res = scanGetItem(scan, &scan->xs_ctup.t_self);
-   stopScan( scan );
+   stopScan(scan);
 
    PG_RETURN_BOOL(res);
 }
index 60107a5770969e1c0c56125cc18c37351abf557f..e4f87e720da820a8edc5f7b0f2740d9eaf6daa37 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * gininsert.c
- *    insert routines for the postgres inverted index access method.
+ *   insert routines for the postgres inverted index access method.
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.4 2006/07/14 14:52:16 momjian Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.5 2006/10/04 00:29:47 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
 #include "miscadmin.h"
 #include "utils/memutils.h"
 
-typedef struct {
-   GinState            ginstate;
-   double              indtuples;
-   MemoryContext       tmpCtx;
-   MemoryContext       funcCtx;
-   BuildAccumulator    accum;
+typedef struct
+{
+   GinState    ginstate;
+   double      indtuples;
+   MemoryContext tmpCtx;
+   MemoryContext funcCtx;
+   BuildAccumulator accum;
 } GinBuildState;
 
 /*
@@ -32,24 +33,26 @@ typedef struct {
  * suppose that items[] fits to page
  */
 static BlockNumber
-createPostingTree( Relation index, ItemPointerData *items, uint32 nitems ) {
+createPostingTree(Relation index, ItemPointerData *items, uint32 nitems)
+{
    BlockNumber blkno;
-   Buffer buffer = GinNewBuffer(index);
-   Page page;
+   Buffer      buffer = GinNewBuffer(index);
+   Page        page;
 
    START_CRIT_SECTION();
 
-   GinInitBuffer( buffer, GIN_DATA|GIN_LEAF );
+   GinInitBuffer(buffer, GIN_DATA | GIN_LEAF);
    page = BufferGetPage(buffer);
    blkno = BufferGetBlockNumber(buffer);
 
-   memcpy( GinDataPageGetData(page), items, sizeof(ItemPointerData) * nitems );
+   memcpy(GinDataPageGetData(page), items, sizeof(ItemPointerData) * nitems);
    GinPageGetOpaque(page)->maxoff = nitems;
 
-   if (!index->rd_istemp) {
-       XLogRecPtr  recptr;
+   if (!index->rd_istemp)
+   {
+       XLogRecPtr  recptr;
        XLogRecData rdata[2];
-       ginxlogCreatePostingTree    data;
+       ginxlogCreatePostingTree data;
 
        data.node = index->rd_node;
        data.blkno = blkno;
@@ -71,7 +74,7 @@ createPostingTree( Relation index, ItemPointerData *items, uint32 nitems ) {
        PageSetLSN(page, recptr);
        PageSetTLI(page, ThisTimeLineID);
 
-   } 
+   }
 
    MarkBufferDirty(buffer);
    UnlockReleaseBuffer(buffer);
@@ -89,21 +92,25 @@ createPostingTree( Relation index, ItemPointerData *items, uint32 nitems ) {
  * GinFormTuple().
  */
 static IndexTuple
-addItemPointersToTuple(Relation index, GinState *ginstate, GinBtreeStack *stack, 
-       IndexTuple old, ItemPointerData *items, uint32 nitem, bool isBuild) {
-   bool isnull;
-   Datum key = index_getattr(old, FirstOffsetNumber, ginstate->tupdesc, &isnull);
-   IndexTuple res = GinFormTuple(ginstate, key, NULL, nitem + GinGetNPosting(old));
-
-   if ( res ) {
+addItemPointersToTuple(Relation index, GinState *ginstate, GinBtreeStack *stack,
+         IndexTuple old, ItemPointerData *items, uint32 nitem, bool isBuild)
+{
+   bool        isnull;
+   Datum       key = index_getattr(old, FirstOffsetNumber, ginstate->tupdesc, &isnull);
+   IndexTuple  res = GinFormTuple(ginstate, key, NULL, nitem + GinGetNPosting(old));
+
+   if (res)
+   {
        /* good, small enough */
-       MergeItemPointers( GinGetPosting(res),
-           GinGetPosting(old), GinGetNPosting(old),
-           items,  nitem
-       );
-       
+       MergeItemPointers(GinGetPosting(res),
+                         GinGetPosting(old), GinGetNPosting(old),
+                         items, nitem
+           );
+
        GinSetNPosting(res, nitem + GinGetNPosting(old));
-   } else {
+   }
+   else
+   {
        BlockNumber postingRoot;
        GinPostingTreeScan *gdi;
 
@@ -112,7 +119,7 @@ addItemPointersToTuple(Relation index, GinState *ginstate, GinBtreeStack *stack,
        postingRoot = createPostingTree(index, GinGetPosting(old), GinGetNPosting(old));
        GinSetPostingTree(res, postingRoot);
 
-       gdi = prepareScanPostingTree(index, postingRoot, FALSE); 
+       gdi = prepareScanPostingTree(index, postingRoot, FALSE);
        gdi->btree.isBuild = isBuild;
 
        insertItemPointer(gdi, items, nitem);
@@ -124,36 +131,39 @@ addItemPointersToTuple(Relation index, GinState *ginstate, GinBtreeStack *stack,
 }
 
 /*
- * Inserts only one entry to the index, but it can adds more that 1 
- * ItemPointer. 
+ * Inserts only one entry to the index, but it can adds more that 1
+ * ItemPointer.
  */
 static void
-ginEntryInsert( Relation index, GinState *ginstate, Datum value, ItemPointerData *items, uint32 nitem, bool isBuild) {
-   GinBtreeData    btree;
+ginEntryInsert(Relation index, GinState *ginstate, Datum value, ItemPointerData *items, uint32 nitem, bool isBuild)
+{
+   GinBtreeData btree;
    GinBtreeStack *stack;
-   IndexTuple itup;
-   Page page;
+   IndexTuple  itup;
+   Page        page;
 
-   prepareEntryScan( &btree, index, value, ginstate );
+   prepareEntryScan(&btree, index, value, ginstate);
 
    stack = ginFindLeafPage(&btree, NULL);
-   page = BufferGetPage( stack->buffer );
+   page = BufferGetPage(stack->buffer);
 
-   if ( btree.findItem( &btree, stack ) ) {
+   if (btree.findItem(&btree, stack))
+   {
        /* found entry */
        itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, stack->off));
 
-       if ( GinIsPostingTree(itup) ) {
+       if (GinIsPostingTree(itup))
+       {
            /* lock root of posting tree */
            GinPostingTreeScan *gdi;
-           BlockNumber rootPostingTree = GinGetPostingTree(itup); 
+           BlockNumber rootPostingTree = GinGetPostingTree(itup);
 
            /* release all stack */
            LockBuffer(stack->buffer, GIN_UNLOCK);
-           freeGinBtreeStack( stack );
+           freeGinBtreeStack(stack);
 
            /* insert into posting tree */
-           gdi = prepareScanPostingTree( index, rootPostingTree, FALSE );
+           gdi = prepareScanPostingTree(index, rootPostingTree, FALSE);
            gdi->btree.isBuild = isBuild;
            insertItemPointer(gdi, items, nitem);
 
@@ -163,23 +173,26 @@ ginEntryInsert( Relation index, GinState *ginstate, Datum value, ItemPointerData
        itup = addItemPointersToTuple(index, ginstate, stack, itup, items, nitem, isBuild);
 
        btree.isDelete = TRUE;
-   } else {
+   }
+   else
+   {
        /* We suppose, that tuple can store at list one itempointer */
-       itup = GinFormTuple( ginstate, value, items, 1);
-       if ( itup==NULL || IndexTupleSize(itup) >= GinMaxItemSize  )
+       itup = GinFormTuple(ginstate, value, items, 1);
+       if (itup == NULL || IndexTupleSize(itup) >= GinMaxItemSize)
            elog(ERROR, "huge tuple");
 
-       if ( nitem>1 ) {
+       if (nitem > 1)
+       {
            IndexTuple  previtup = itup;
 
-           itup =  addItemPointersToTuple(index, ginstate, stack, previtup, items+1, nitem-1, isBuild);
+           itup = addItemPointersToTuple(index, ginstate, stack, previtup, items + 1, nitem - 1, isBuild);
            pfree(previtup);
        }
    }
 
    btree.entry = itup;
    ginInsertValue(&btree, stack);
-   pfree( itup );
+   pfree(itup);
 }
 
 /*
@@ -187,48 +200,53 @@ ginEntryInsert( Relation index, GinState *ginstate, Datum value, ItemPointerData
  * Function isnt use during normal insert
  */
 static uint32
-ginHeapTupleBulkInsert(GinBuildState *buildstate, Datum value, ItemPointer heapptr) {
-   Datum   *entries;
-   uint32 nentries;
+ginHeapTupleBulkInsert(GinBuildState *buildstate, Datum value, ItemPointer heapptr)
+{
+   Datum      *entries;
+   uint32      nentries;
    MemoryContext oldCtx;
 
    oldCtx = MemoryContextSwitchTo(buildstate->funcCtx);
-   entries = extractEntriesSU( buildstate->accum.ginstate, value, &nentries);
+   entries = extractEntriesSU(buildstate->accum.ginstate, value, &nentries);
    MemoryContextSwitchTo(oldCtx);
 
-   if ( nentries==0 )
+   if (nentries == 0)
        /* nothing to insert */
        return 0;
 
-   ginInsertRecordBA( &buildstate->accum, heapptr, entries, nentries);
+   ginInsertRecordBA(&buildstate->accum, heapptr, entries, nentries);
 
    MemoryContextReset(buildstate->funcCtx);
 
    return nentries;
 }
 
-static void 
+static void
 ginBuildCallback(Relation index, HeapTuple htup, Datum *values,
-                   bool *isnull, bool tupleIsAlive, void *state) {
+                bool *isnull, bool tupleIsAlive, void *state)
+{
 
-   GinBuildState   *buildstate = (GinBuildState*)state;
+   GinBuildState *buildstate = (GinBuildState *) state;
    MemoryContext oldCtx;
 
-   if ( *isnull )
+   if (*isnull)
        return;
 
    oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx);
 
    buildstate->indtuples += ginHeapTupleBulkInsert(buildstate, *values, &htup->t_self);
 
-   /* we use only half maintenance_work_mem, because there is some leaks 
-       during insertion and extract values */ 
-   if ( buildstate->accum.allocatedMemory >= maintenance_work_mem*1024L/2L ) { 
-       ItemPointerData *list;
-       Datum entry;
-       uint32  nlist;
+   /*
+    * we use only half maintenance_work_mem, because there is some leaks
+    * during insertion and extract values
+    */
+   if (buildstate->accum.allocatedMemory >= maintenance_work_mem * 1024L / 2L)
+   {
+       ItemPointerData *list;
+       Datum       entry;
+       uint32      nlist;
 
-       while( (list=ginGetEntry(&buildstate->accum, &entry, &nlist)) != NULL )
+       while ((list = ginGetEntry(&buildstate->accum, &entry, &nlist)) != NULL)
            ginEntryInsert(index, &buildstate->ginstate, entry, list, nlist, TRUE);
 
        MemoryContextReset(buildstate->tmpCtx);
@@ -239,22 +257,23 @@ ginBuildCallback(Relation index, HeapTuple htup, Datum *values,
 }
 
 Datum
-ginbuild(PG_FUNCTION_ARGS) {
-   Relation    heap = (Relation) PG_GETARG_POINTER(0);
-   Relation    index = (Relation) PG_GETARG_POINTER(1);
+ginbuild(PG_FUNCTION_ARGS)
+{
+   Relation    heap = (Relation) PG_GETARG_POINTER(0);
+   Relation    index = (Relation) PG_GETARG_POINTER(1);
    IndexInfo  *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2);
    IndexBuildResult *result;
-   double      reltuples;
-   GinBuildState   buildstate;
+   double      reltuples;
+   GinBuildState buildstate;
    Buffer      buffer;
-   ItemPointerData *list;
-   Datum entry;
-   uint32  nlist;
+   ItemPointerData *list;
+   Datum       entry;
+   uint32      nlist;
    MemoryContext oldCtx;
 
    if (RelationGetNumberOfBlocks(index) != 0)
        elog(ERROR, "index \"%s\" already contains data",
-           RelationGetRelationName(index));
+            RelationGetRelationName(index));
 
    initGinState(&buildstate.ginstate, index);
 
@@ -262,10 +281,11 @@ ginbuild(PG_FUNCTION_ARGS) {
    buffer = GinNewBuffer(index);
    START_CRIT_SECTION();
    GinInitBuffer(buffer, GIN_LEAF);
-   if (!index->rd_istemp) {
-       XLogRecPtr  recptr;
+   if (!index->rd_istemp)
+   {
+       XLogRecPtr  recptr;
        XLogRecData rdata;
-       Page        page;
+       Page        page;
 
        rdata.buffer = InvalidBuffer;
        rdata.data = (char *) &(index->rd_node);
@@ -279,7 +299,7 @@ ginbuild(PG_FUNCTION_ARGS) {
        PageSetLSN(page, recptr);
        PageSetTLI(page, ThisTimeLineID);
 
-   } 
+   }
 
    MarkBufferDirty(buffer);
    UnlockReleaseBuffer(buffer);
@@ -293,26 +313,26 @@ ginbuild(PG_FUNCTION_ARGS) {
     * inserted into the index
     */
    buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
-                                               "Gin build temporary context",
-                                               ALLOCSET_DEFAULT_MINSIZE,
-                                               ALLOCSET_DEFAULT_INITSIZE,
-                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                             "Gin build temporary context",
+                                             ALLOCSET_DEFAULT_MINSIZE,
+                                             ALLOCSET_DEFAULT_INITSIZE,
+                                             ALLOCSET_DEFAULT_MAXSIZE);
 
    buildstate.funcCtx = AllocSetContextCreate(buildstate.tmpCtx,
-                                               "Gin build temporary context for user-defined function",
-                                               ALLOCSET_DEFAULT_MINSIZE,
-                                               ALLOCSET_DEFAULT_INITSIZE,
-                                               ALLOCSET_DEFAULT_MAXSIZE);
+                    "Gin build temporary context for user-defined function",
+                                              ALLOCSET_DEFAULT_MINSIZE,
+                                              ALLOCSET_DEFAULT_INITSIZE,
+                                              ALLOCSET_DEFAULT_MAXSIZE);
 
    buildstate.accum.ginstate = &buildstate.ginstate;
-   ginInitBA( &buildstate.accum );
+   ginInitBA(&buildstate.accum);
 
    /* do the heap scan */
    reltuples = IndexBuildHeapScan(heap, index, indexInfo,
-                                   ginBuildCallback, (void *) &buildstate);
+                                  ginBuildCallback, (void *) &buildstate);
 
    oldCtx = MemoryContextSwitchTo(buildstate.tmpCtx);
-   while( (list=ginGetEntry(&buildstate.accum, &entry, &nlist)) != NULL )
+   while ((list = ginGetEntry(&buildstate.accum, &entry, &nlist)) != NULL)
        ginEntryInsert(index, &buildstate.ginstate, entry, list, nlist, TRUE);
    MemoryContextSwitchTo(oldCtx);
 
@@ -333,55 +353,58 @@ ginbuild(PG_FUNCTION_ARGS) {
  * Inserts value during normal insertion
  */
 static uint32
-ginHeapTupleInsert( Relation index, GinState *ginstate, Datum value, ItemPointer item) {
-   Datum   *entries;
-   uint32 i,nentries;
+ginHeapTupleInsert(Relation index, GinState *ginstate, Datum value, ItemPointer item)
+{
+   Datum      *entries;
+   uint32      i,
+               nentries;
 
-   entries = extractEntriesSU( ginstate, value, &nentries);
+   entries = extractEntriesSU(ginstate, value, &nentries);
 
-   if ( nentries==0 )
+   if (nentries == 0)
        /* nothing to insert */
        return 0;
 
-   for(i=0;i
+   for (i = 0; i < nentries; i++)
        ginEntryInsert(index, ginstate, entries[i], item, 1, FALSE);
 
    return nentries;
 }
 
 Datum
-gininsert(PG_FUNCTION_ARGS) {
-   Relation    index = (Relation) PG_GETARG_POINTER(0);
-   Datum      *values = (Datum *) PG_GETARG_POINTER(1);
-   bool       *isnull = (bool *) PG_GETARG_POINTER(2);
+gininsert(PG_FUNCTION_ARGS)
+{
+   Relation    index = (Relation) PG_GETARG_POINTER(0);
+   Datum      *values = (Datum *) PG_GETARG_POINTER(1);
+   bool       *isnull = (bool *) PG_GETARG_POINTER(2);
    ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
+
 #ifdef NOT_USED
-   Relation    heapRel = (Relation) PG_GETARG_POINTER(4);
-   bool        checkUnique = PG_GETARG_BOOL(5);
+   Relation    heapRel = (Relation) PG_GETARG_POINTER(4);
+   bool        checkUnique = PG_GETARG_BOOL(5);
 #endif
-   GinState    ginstate;
+   GinState    ginstate;
    MemoryContext oldCtx;
    MemoryContext insertCtx;
-   uint32 res;
+   uint32      res;
 
-   if ( *isnull )
+   if (*isnull)
        PG_RETURN_BOOL(false);
 
    insertCtx = AllocSetContextCreate(CurrentMemoryContext,
-                                               "Gin insert temporary context",
-                                               ALLOCSET_DEFAULT_MINSIZE,
-                                               ALLOCSET_DEFAULT_INITSIZE,
-                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                     "Gin insert temporary context",
+                                     ALLOCSET_DEFAULT_MINSIZE,
+                                     ALLOCSET_DEFAULT_INITSIZE,
+                                     ALLOCSET_DEFAULT_MAXSIZE);
 
    oldCtx = MemoryContextSwitchTo(insertCtx);
 
    initGinState(&ginstate, index);
 
-   res = ginHeapTupleInsert(index, &ginstate, *values, ht_ctid); 
+   res = ginHeapTupleInsert(index, &ginstate, *values, ht_ctid);
 
    MemoryContextSwitchTo(oldCtx);
    MemoryContextDelete(insertCtx);
 
-   PG_RETURN_BOOL(res>0);
+   PG_RETURN_BOOL(res > 0);
 }
-
index 2093f1ce8a606876e5dc2f23baf1f0d02cc7a10e..b69f409e1cd57efd1095645ba21e6c1b7a55f6c1 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginscan.c
- *    routines to manage scans inverted index relations
+ *   routines to manage scans inverted index relations
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.5 2006/09/14 11:26:49 teodor Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.6 2006/10/04 00:29:48 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
 #include "utils/memutils.h"
 
 
-Datum 
-ginbeginscan(PG_FUNCTION_ARGS) {
-   Relation    rel = (Relation) PG_GETARG_POINTER(0);
-   int         keysz = PG_GETARG_INT32(1);
-   ScanKey     scankey = (ScanKey) PG_GETARG_POINTER(2);
+Datum
+ginbeginscan(PG_FUNCTION_ARGS)
+{
+   Relation    rel = (Relation) PG_GETARG_POINTER(0);
+   int         keysz = PG_GETARG_INT32(1);
+   ScanKey     scankey = (ScanKey) PG_GETARG_POINTER(2);
    IndexScanDesc scan;
 
    scan = RelationGetIndexScan(rel, keysz, scankey);
@@ -32,22 +33,25 @@ ginbeginscan(PG_FUNCTION_ARGS) {
 }
 
 static void
-fillScanKey( GinState *ginstate, GinScanKey key, Datum query, 
-               Datum *entryValues, uint32 nEntryValues, StrategyNumber strategy ) {
-   uint32 i,j;
+fillScanKey(GinState *ginstate, GinScanKey key, Datum query,
+           Datum *entryValues, uint32 nEntryValues, StrategyNumber strategy)
+{
+   uint32      i,
+               j;
 
    key->nentries = nEntryValues;
-   key->entryRes = (bool*)palloc0( sizeof(bool) * nEntryValues ); 
-   key->scanEntry = (GinScanEntry) palloc( sizeof(GinScanEntryData) * nEntryValues );
+   key->entryRes = (bool *) palloc0(sizeof(bool) * nEntryValues);
+   key->scanEntry = (GinScanEntry) palloc(sizeof(GinScanEntryData) * nEntryValues);
    key->strategy = strategy;
    key->query = query;
-   key->firstCall= TRUE;
-   ItemPointerSet( &(key->curItem), InvalidBlockNumber, InvalidOffsetNumber );
+   key->firstCall = TRUE;
+   ItemPointerSet(&(key->curItem), InvalidBlockNumber, InvalidOffsetNumber);
 
-   for(i=0; i
+   for (i = 0; i < nEntryValues; i++)
+   {
        key->scanEntry[i].pval = key->entryRes + i;
        key->scanEntry[i].entry = entryValues[i];
-       ItemPointerSet( &(key->scanEntry[i].curItem), InvalidBlockNumber, InvalidOffsetNumber );
+       ItemPointerSet(&(key->scanEntry[i].curItem), InvalidBlockNumber, InvalidOffsetNumber);
        key->scanEntry[i].offset = InvalidOffsetNumber;
        key->scanEntry[i].buffer = InvalidBuffer;
        key->scanEntry[i].list = NULL;
@@ -55,8 +59,9 @@ fillScanKey( GinState *ginstate, GinScanKey key, Datum query,
 
        /* link to the equals entry in current scan key */
        key->scanEntry[i].master = NULL;
-       for( j=0; j
-           if ( compareEntries( ginstate, entryValues[i], entryValues[j] ) == 0 ) {
+       for (j = 0; j < i; j++)
+           if (compareEntries(ginstate, entryValues[i], entryValues[j]) == 0)
+           {
                key->scanEntry[i].master = key->scanEntry + j;
                break;
            }
@@ -66,23 +71,27 @@ fillScanKey( GinState *ginstate, GinScanKey key, Datum query,
 #ifdef NOT_USED
 
 static void
-resetScanKeys(GinScanKey keys, uint32 nkeys) {
-   uint32  i, j;
+resetScanKeys(GinScanKey keys, uint32 nkeys)
+{
+   uint32      i,
+               j;
 
-   if ( keys == NULL )
+   if (keys == NULL)
        return;
 
-   for(i=0;i
-       GinScanKey key = keys + i;
+   for (i = 0; i < nkeys; i++)
+   {
+       GinScanKey  key = keys + i;
 
        key->firstCall = TRUE;
-       ItemPointerSet( &(key->curItem), InvalidBlockNumber, InvalidOffsetNumber );
+       ItemPointerSet(&(key->curItem), InvalidBlockNumber, InvalidOffsetNumber);
 
-       for(j=0;jnentries;j++) {
-           if ( key->scanEntry[j].buffer != InvalidBuffer )
-               ReleaseBuffer( key->scanEntry[i].buffer );
+       for (j = 0; j < key->nentries; j++)
+       {
+           if (key->scanEntry[j].buffer != InvalidBuffer)
+               ReleaseBuffer(key->scanEntry[i].buffer);
 
-           ItemPointerSet( &(key->scanEntry[j].curItem), InvalidBlockNumber, InvalidOffsetNumber );
+           ItemPointerSet(&(key->scanEntry[j].curItem), InvalidBlockNumber, InvalidOffsetNumber);
            key->scanEntry[j].offset = InvalidOffsetNumber;
            key->scanEntry[j].buffer = InvalidBuffer;
            key->scanEntry[j].list = NULL;
@@ -90,111 +99,121 @@ resetScanKeys(GinScanKey keys, uint32 nkeys) {
        }
    }
 }
-
 #endif
 
 static void
-freeScanKeys(GinScanKey keys, uint32 nkeys, bool removeRes) {
-   uint32  i, j;
+freeScanKeys(GinScanKey keys, uint32 nkeys, bool removeRes)
+{
+   uint32      i,
+               j;
 
-   if ( keys == NULL )
+   if (keys == NULL)
        return;
 
-   for(i=0;i
-       GinScanKey key = keys + i;
+   for (i = 0; i < nkeys; i++)
+   {
+       GinScanKey  key = keys + i;
 
-       for(j=0;jnentries;j++) {
-           if ( key->scanEntry[j].buffer != InvalidBuffer )
-               ReleaseBuffer( key->scanEntry[j].buffer );
-           if ( removeRes && key->scanEntry[j].list ) 
+       for (j = 0; j < key->nentries; j++)
+       {
+           if (key->scanEntry[j].buffer != InvalidBuffer)
+               ReleaseBuffer(key->scanEntry[j].buffer);
+           if (removeRes && key->scanEntry[j].list)
                pfree(key->scanEntry[j].list);
        }
 
-       if ( removeRes )
+       if (removeRes)
            pfree(key->entryRes);
        pfree(key->scanEntry);
    }
-   
+
    pfree(keys);
 }
 
 void
-newScanKey( IndexScanDesc scan ) {
-   ScanKey     scankey = scan->keyData;
+newScanKey(IndexScanDesc scan)
+{
+   ScanKey     scankey = scan->keyData;
    GinScanOpaque so = (GinScanOpaque) scan->opaque;
-   int i;
-   uint32 nkeys = 0;
+   int         i;
+   uint32      nkeys = 0;
 
-   so->keys = (GinScanKey) palloc( scan->numberOfKeys * sizeof(GinScanKeyData) );
+   so->keys = (GinScanKey) palloc(scan->numberOfKeys * sizeof(GinScanKeyData));
 
    if (scan->numberOfKeys < 1)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-               errmsg("GIN indexes do not support whole-index scans")));
+                errmsg("GIN indexes do not support whole-index scans")));
 
-   for(i=0; inumberOfKeys; i++) {
-       Datum*  entryValues;
-       uint32  nEntryValues;
+   for (i = 0; i < scan->numberOfKeys; i++)
+   {
+       Datum      *entryValues;
+       uint32      nEntryValues;
 
-       if ( scankey[i].sk_flags & SK_ISNULL )
+       if (scankey[i].sk_flags & SK_ISNULL)
            elog(ERROR, "Gin doesn't support NULL as scan key");
-       Assert( scankey[i].sk_attno == 1 );
-
-       entryValues = (Datum*)DatumGetPointer(
-                           FunctionCall3(
-                               &so->ginstate.extractQueryFn,
-                               scankey[i].sk_argument,
-                               PointerGetDatum( &nEntryValues ),
-                               UInt16GetDatum(scankey[i].sk_strategy)
-                           )
-                       );
-       if ( entryValues==NULL || nEntryValues == 0 )
+       Assert(scankey[i].sk_attno == 1);
+
+       entryValues = (Datum *) DatumGetPointer(
+                                               FunctionCall3(
+                                               &so->ginstate.extractQueryFn,
+                                                     scankey[i].sk_argument,
+                                             PointerGetDatum(&nEntryValues),
+                                      UInt16GetDatum(scankey[i].sk_strategy)
+                                                             )
+           );
+       if (entryValues == NULL || nEntryValues == 0)
            /* full scan... */
            continue;
 
-       fillScanKey( &so->ginstate, &(so->keys[nkeys]), scankey[i].sk_argument,
-               entryValues, nEntryValues, scankey[i].sk_strategy );
+       fillScanKey(&so->ginstate, &(so->keys[nkeys]), scankey[i].sk_argument,
+                   entryValues, nEntryValues, scankey[i].sk_strategy);
        nkeys++;
    }
 
    so->nkeys = nkeys;
 
-   if ( so->nkeys == 0 )
+   if (so->nkeys == 0)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-               errmsg("GIN index doesn't support search with void query")));
+                errmsg("GIN index doesn't support search with void query")));
 
    pgstat_count_index_scan(&scan->xs_pgstat_info);
 }
 
 Datum
-ginrescan(PG_FUNCTION_ARGS) {
+ginrescan(PG_FUNCTION_ARGS)
+{
    IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
-   ScanKey     scankey = (ScanKey) PG_GETARG_POINTER(1);
-   GinScanOpaque   so;
+   ScanKey     scankey = (ScanKey) PG_GETARG_POINTER(1);
+   GinScanOpaque so;
 
    so = (GinScanOpaque) scan->opaque;
 
-   if ( so == NULL ) {
+   if (so == NULL)
+   {
        /* if called from ginbeginscan */
-       so = (GinScanOpaque)palloc( sizeof(GinScanOpaqueData) );
+       so = (GinScanOpaque) palloc(sizeof(GinScanOpaqueData));
        so->tempCtx = AllocSetContextCreate(CurrentMemoryContext,
-                               "Gin scan temporary context",
-                               ALLOCSET_DEFAULT_MINSIZE,
-                               ALLOCSET_DEFAULT_INITSIZE,
-                               ALLOCSET_DEFAULT_MAXSIZE);
+                                           "Gin scan temporary context",
+                                           ALLOCSET_DEFAULT_MINSIZE,
+                                           ALLOCSET_DEFAULT_INITSIZE,
+                                           ALLOCSET_DEFAULT_MAXSIZE);
        initGinState(&so->ginstate, scan->indexRelation);
        scan->opaque = so;
-   } else {
+   }
+   else
+   {
        freeScanKeys(so->keys, so->nkeys, TRUE);
        freeScanKeys(so->markPos, so->nkeys, FALSE);
    }
 
-   so->markPos=so->keys=NULL;
+   so->markPos = so->keys = NULL;
 
-   if ( scankey && scan->numberOfKeys > 0 ) {
+   if (scankey && scan->numberOfKeys > 0)
+   {
        memmove(scan->keyData, scankey,
-           scan->numberOfKeys * sizeof(ScanKeyData));
+               scan->numberOfKeys * sizeof(ScanKeyData));
    }
 
    PG_RETURN_VOID();
@@ -202,13 +221,15 @@ ginrescan(PG_FUNCTION_ARGS) {
 
 
 Datum
-ginendscan(PG_FUNCTION_ARGS) {
+ginendscan(PG_FUNCTION_ARGS)
+{
    IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
-    GinScanOpaque   so = (GinScanOpaque) scan->opaque;
+   GinScanOpaque so = (GinScanOpaque) scan->opaque;
 
-   if ( so != NULL ) {
-       freeScanKeys(so->keys, so->nkeys, TRUE); 
-       freeScanKeys(so->markPos, so->nkeys, FALSE); 
+   if (so != NULL)
+   {
+       freeScanKeys(so->keys, so->nkeys, TRUE);
+       freeScanKeys(so->markPos, so->nkeys, FALSE);
 
        MemoryContextDelete(so->tempCtx);
 
@@ -219,22 +240,28 @@ ginendscan(PG_FUNCTION_ARGS) {
 }
 
 static GinScanKey
-copyScanKeys( GinScanKey keys, uint32 nkeys ) {
+copyScanKeys(GinScanKey keys, uint32 nkeys)
+{
    GinScanKey  newkeys;
-   uint32 i, j;
+   uint32      i,
+               j;
+
+   newkeys = (GinScanKey) palloc(sizeof(GinScanKeyData) * nkeys);
+   memcpy(newkeys, keys, sizeof(GinScanKeyData) * nkeys);
 
-   newkeys = (GinScanKey)palloc( sizeof(GinScanKeyData) * nkeys );
-   memcpy( newkeys, keys, sizeof(GinScanKeyData) * nkeys );
+   for (i = 0; i < nkeys; i++)
+   {
+       newkeys[i].scanEntry = (GinScanEntry) palloc(sizeof(GinScanEntryData) * keys[i].nentries);
+       memcpy(newkeys[i].scanEntry, keys[i].scanEntry, sizeof(GinScanEntryData) * keys[i].nentries);
 
-   for(i=0;i
-       newkeys[i].scanEntry = (GinScanEntry)palloc(sizeof(GinScanEntryData) * keys[i].nentries );
-       memcpy( newkeys[i].scanEntry, keys[i].scanEntry, sizeof(GinScanEntryData) * keys[i].nentries );
+       for (j = 0; j < keys[i].nentries; j++)
+       {
+           if (keys[i].scanEntry[j].buffer != InvalidBuffer)
+               IncrBufferRefCount(keys[i].scanEntry[j].buffer);
+           if (keys[i].scanEntry[j].master)
+           {
+               int         masterN = keys[i].scanEntry[j].master - keys[i].scanEntry;
 
-       for(j=0;j
-           if ( keys[i].scanEntry[j].buffer != InvalidBuffer )
-               IncrBufferRefCount( keys[i].scanEntry[j].buffer );
-           if ( keys[i].scanEntry[j].master ) {
-               int masterN = keys[i].scanEntry[j].master - keys[i].scanEntry;
                newkeys[i].scanEntry[j].master = newkeys[i].scanEntry + masterN;
            }
        }
@@ -243,24 +270,26 @@ copyScanKeys( GinScanKey keys, uint32 nkeys ) {
    return newkeys;
 }
 
-Datum 
-ginmarkpos(PG_FUNCTION_ARGS) {
+Datum
+ginmarkpos(PG_FUNCTION_ARGS)
+{
    IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
-   GinScanOpaque   so = (GinScanOpaque) scan->opaque;
+   GinScanOpaque so = (GinScanOpaque) scan->opaque;
 
    freeScanKeys(so->markPos, so->nkeys, FALSE);
-   so->markPos = copyScanKeys( so->keys, so->nkeys );
+   so->markPos = copyScanKeys(so->keys, so->nkeys);
 
    PG_RETURN_VOID();
 }
 
-Datum 
-ginrestrpos(PG_FUNCTION_ARGS) {
+Datum
+ginrestrpos(PG_FUNCTION_ARGS)
+{
    IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
-   GinScanOpaque   so = (GinScanOpaque) scan->opaque;
+   GinScanOpaque so = (GinScanOpaque) scan->opaque;
 
    freeScanKeys(so->keys, so->nkeys, FALSE);
-   so->keys = copyScanKeys( so->markPos, so->nkeys );
+   so->keys = copyScanKeys(so->markPos, so->nkeys);
 
    PG_RETURN_VOID();
 }
index 17eca3d239f91b81c96d8f304b8b81ab0870ea75..e64137a10621a259a0566d2e9660773e8fe9c0a5 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginutil.c
- *    utilities routines for the postgres inverted index access method.
+ *   utilities routines for the postgres inverted index access method.
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.6 2006/09/05 18:25:10 teodor Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.7 2006/10/04 00:29:48 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
 #include "access/reloptions.h"
 #include "storage/freespace.h"
 
-void 
-initGinState( GinState *state, Relation index ) {
-   if ( index->rd_att->natts != 1 )
-           elog(ERROR, "numberOfAttributes %d != 1",
-                   index->rd_att->natts);
-   
+void
+initGinState(GinState *state, Relation index)
+{
+   if (index->rd_att->natts != 1)
+       elog(ERROR, "numberOfAttributes %d != 1",
+            index->rd_att->natts);
+
    state->tupdesc = index->rd_att;
 
    fmgr_info_copy(&(state->compareFn),
-           index_getprocinfo(index, 1, GIN_COMPARE_PROC),
-           CurrentMemoryContext);
+                  index_getprocinfo(index, 1, GIN_COMPARE_PROC),
+                  CurrentMemoryContext);
    fmgr_info_copy(&(state->extractValueFn),
-           index_getprocinfo(index, 1, GIN_EXTRACTVALUE_PROC),
-           CurrentMemoryContext);
+                  index_getprocinfo(index, 1, GIN_EXTRACTVALUE_PROC),
+                  CurrentMemoryContext);
    fmgr_info_copy(&(state->extractQueryFn),
-           index_getprocinfo(index, 1, GIN_EXTRACTQUERY_PROC),
-           CurrentMemoryContext);
+                  index_getprocinfo(index, 1, GIN_EXTRACTQUERY_PROC),
+                  CurrentMemoryContext);
    fmgr_info_copy(&(state->consistentFn),
-           index_getprocinfo(index, 1, GIN_CONSISTENT_PROC),
-           CurrentMemoryContext);
+                  index_getprocinfo(index, 1, GIN_CONSISTENT_PROC),
+                  CurrentMemoryContext);
 }
 
 /*
@@ -48,13 +49,16 @@ initGinState( GinState *state, Relation index ) {
  */
 
 Buffer
-GinNewBuffer(Relation index) {
-   Buffer  buffer;
-   bool    needLock;
+GinNewBuffer(Relation index)
+{
+   Buffer      buffer;
+   bool        needLock;
 
    /* First, try to get a page from FSM */
-   for(;;) {
+   for (;;)
+   {
        BlockNumber blkno = GetFreeIndexPage(&index->rd_node);
+
        if (blkno == InvalidBlockNumber)
            break;
 
@@ -64,14 +68,15 @@ GinNewBuffer(Relation index) {
         * We have to guard against the possibility that someone else already
         * recycled this page; the buffer may be locked if so.
         */
-        if (ConditionalLockBuffer(buffer)) {
-           Page        page = BufferGetPage(buffer);
+       if (ConditionalLockBuffer(buffer))
+       {
+           Page        page = BufferGetPage(buffer);
 
            if (PageIsNew(page))
-               return buffer;  /* OK to use, if never initialized */
+               return buffer;  /* OK to use, if never initialized */
 
            if (GinPageIsDeleted(page))
-               return buffer;  /* OK to use */
+               return buffer;  /* OK to use */
 
            LockBuffer(buffer, GIN_UNLOCK);
        }
@@ -95,36 +100,39 @@ GinNewBuffer(Relation index) {
 }
 
 void
-GinInitPage(Page page, uint32 f, Size pageSize) {
+GinInitPage(Page page, uint32 f, Size pageSize)
+{
    GinPageOpaque opaque;
 
    PageInit(page, pageSize, sizeof(GinPageOpaqueData));
 
    opaque = GinPageGetOpaque(page);
-   memset( opaque, 0, sizeof(GinPageOpaqueData) );
-   opaque->flags = f;   
+   memset(opaque, 0, sizeof(GinPageOpaqueData));
+   opaque->flags = f;
    opaque->rightlink = InvalidBlockNumber;
 }
 
 void
-GinInitBuffer(Buffer b, uint32 f) {
-   GinInitPage( BufferGetPage(b), f, BufferGetPageSize(b) );
+GinInitBuffer(Buffer b, uint32 f)
+{
+   GinInitPage(BufferGetPage(b), f, BufferGetPageSize(b));
 }
 
 int
-compareEntries(GinState *ginstate, Datum a, Datum b) {
+compareEntries(GinState *ginstate, Datum a, Datum b)
+{
    return DatumGetInt32(
-       FunctionCall2(
-           &ginstate->compareFn,
-           a, b
-       )
+                        FunctionCall2(
+                                      &ginstate->compareFn,
+                                      a, b
+                                      )
    );
 }
 
-static FmgrInfo* cmpDatumPtr=NULL;
+static FmgrInfo *cmpDatumPtr = NULL;
 
-#if defined(__INTEL_COMPILER) && (defined(__ia64__) || defined(__ia64))   
-/* 
+#if defined(__INTEL_COMPILER) && (defined(__ia64__) || defined(__ia64))
+/*
  * Intel Compiler on Intel Itanium with -O2 has a bug around
  * change static variable by user function called from
  * libc func: it doesn't change. So mark it as volatile.
@@ -132,7 +140,7 @@ static FmgrInfo* cmpDatumPtr=NULL;
  * It's a pity, but it's impossible to define optimization
  * level here.
  */
-#define    VOLATILE    volatile
+#define VOLATILE   volatile
 #else
 #define VOLATILE
 #endif
@@ -140,57 +148,64 @@ static FmgrInfo* cmpDatumPtr=NULL;
 static bool VOLATILE needUnique = FALSE;
 
 static int
-cmpEntries(const void * a, const void * b) {
-   int res = DatumGetInt32(
-       FunctionCall2(
-           cmpDatumPtr,
-           *(Datum*)a,
-           *(Datum*)b
-       )
+cmpEntries(const void *a, const void *b)
+{
+   int         res = DatumGetInt32(
+                                   FunctionCall2(
+                                                 cmpDatumPtr,
+                                                 *(Datum *) a,
+                                                 *(Datum *) b
+                                                 )
    );
 
-   if ( res == 0 ) 
+   if (res == 0)
        needUnique = TRUE;
 
    return res;
 }
 
-Datum*
-extractEntriesS(GinState *ginstate, Datum value, uint32 *nentries) {
-   Datum *entries;
+Datum *
+extractEntriesS(GinState *ginstate, Datum value, uint32 *nentries)
+{
+   Datum      *entries;
 
-       entries = (Datum*)DatumGetPointer(
-                           FunctionCall2(
-                               &ginstate->extractValueFn,
-                               value,
-                               PointerGetDatum( nentries )
-                           )
-           );
+   entries = (Datum *) DatumGetPointer(
+                                       FunctionCall2(
+                                                  &ginstate->extractValueFn,
+                                                     value,
+                                                   PointerGetDatum(nentries)
+                                                     )
+       );
 
-   if ( entries == NULL )
+   if (entries == NULL)
        *nentries = 0;
 
-   if ( *nentries > 1 ) {
+   if (*nentries > 1)
+   {
        cmpDatumPtr = &ginstate->compareFn;
        needUnique = FALSE;
-       qsort(entries, *nentries, sizeof(Datum), cmpEntries); 
+       qsort(entries, *nentries, sizeof(Datum), cmpEntries);
    }
 
    return entries;
 }
 
 
-Datum*
-extractEntriesSU(GinState *ginstate, Datum value, uint32 *nentries) {
-   Datum *entries = extractEntriesS(ginstate, value, nentries);
+Datum *
+extractEntriesSU(GinState *ginstate, Datum value, uint32 *nentries)
+{
+   Datum      *entries = extractEntriesS(ginstate, value, nentries);
 
-   if ( *nentries>1 && needUnique ) {
-       Datum *ptr, *res;
+   if (*nentries > 1 && needUnique)
+   {
+       Datum      *ptr,
+                  *res;
 
        ptr = res = entries;
 
-       while( ptr - entries < *nentries ) {
-           if ( compareEntries(ginstate, *ptr, *res ) != 0 ) 
+       while (ptr - entries < *nentries)
+       {
+           if (compareEntries(ginstate, *ptr, *res) != 0)
                *(++res) = *ptr++;
            else
                ptr++;
@@ -206,13 +221,14 @@ extractEntriesSU(GinState *ginstate, Datum value, uint32 *nentries) {
  * It's analog of PageGetTempPage(), but copies whole page
  */
 Page
-GinPageGetCopyPage( Page page ) {
-   Size    pageSize = PageGetPageSize( page );
-   Page tmppage;
+GinPageGetCopyPage(Page page)
+{
+   Size        pageSize = PageGetPageSize(page);
+   Page        tmppage;
+
+   tmppage = (Page) palloc(pageSize);
+   memcpy(tmppage, page, pageSize);
 
-   tmppage=(Page)palloc( pageSize );
-   memcpy( tmppage, page, pageSize );
-   
    return tmppage;
 }
 
index 31e5f647f070c84ea13bb6d84fd156a41604d65c..e0718862c51f95dbdf270a085a12f7184534cb2f 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * ginvacuum.c
- *    delete & vacuum routines for the postgres GIN
+ *   delete & vacuum routines for the postgres GIN
  *
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.6 2006/09/21 20:31:21 tgl Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.7 2006/10/04 00:29:48 momjian Exp $
  *-------------------------------------------------------------------------
  */
 
 #include "storage/freespace.h"
 #include "commands/vacuum.h"
 
-typedef struct {
-   Relation                index;
-   IndexBulkDeleteResult   *result;
-   IndexBulkDeleteCallback callback;
-   void                    *callback_state;
-   GinState                ginstate;
+typedef struct
+{
+   Relation    index;
+   IndexBulkDeleteResult *result;
+   IndexBulkDeleteCallback callback;
+   void       *callback_state;
+   GinState    ginstate;
 } GinVacuumState;
 
 
 /*
  * Cleans array of ItemPointer (removes dead pointers)
  * Results are always stored in *cleaned, which will be allocated
- * if its needed. In case of *cleaned!=NULL caller is resposible to 
+ * if its needed. In case of *cleaned!=NULL caller is resposible to
  * enough space. *cleaned and items may point to the same
  * memory addres.
  */
 
 static uint32
-ginVacuumPostingList( GinVacuumState *gvs, ItemPointerData *items, uint32 nitem, ItemPointerData **cleaned ) {
-   uint32 i,j=0;
+ginVacuumPostingList(GinVacuumState *gvs, ItemPointerData *items, uint32 nitem, ItemPointerData **cleaned)
+{
+   uint32      i,
+               j = 0;
 
    /*
     * just scan over ItemPointer array
     */
 
-   for(i=0;i
-       if ( gvs->callback(items+i, gvs->callback_state) ) { 
+   for (i = 0; i < nitem; i++)
+   {
+       if (gvs->callback(items + i, gvs->callback_state))
+       {
            gvs->result->tuples_removed += 1;
-           if ( !*cleaned )  {
-               *cleaned = (ItemPointerData*)palloc(sizeof(ItemPointerData)*nitem);
-               if ( i!=0 ) 
-                   memcpy( *cleaned, items, sizeof(ItemPointerData)*i);
+           if (!*cleaned)
+           {
+               *cleaned = (ItemPointerData *) palloc(sizeof(ItemPointerData) * nitem);
+               if (i != 0)
+                   memcpy(*cleaned, items, sizeof(ItemPointerData) * i);
            }
-       } else {
+       }
+       else
+       {
            gvs->result->num_index_tuples += 1;
-           if (i!=j)
+           if (i != j)
                (*cleaned)[j] = items[i];
            j++;
        }
@@ -69,56 +77,65 @@ ginVacuumPostingList( GinVacuumState *gvs, ItemPointerData *items, uint32 nitem,
  * fills WAL record for vacuum leaf page
  */
 static void
-xlogVacuumPage(Relation index, Buffer buffer) {
-   Page    page = BufferGetPage( buffer );
-   XLogRecPtr  recptr;
+xlogVacuumPage(Relation index, Buffer buffer)
+{
+   Page        page = BufferGetPage(buffer);
+   XLogRecPtr  recptr;
    XLogRecData rdata[3];
-   ginxlogVacuumPage   data;
-   char *backup;
-   char itups[BLCKSZ];
-   uint32 len=0;
+   ginxlogVacuumPage data;
+   char       *backup;
+   char        itups[BLCKSZ];
+   uint32      len = 0;
 
-   Assert( GinPageIsLeaf( page ) );
+   Assert(GinPageIsLeaf(page));
 
    if (index->rd_istemp)
-       return; 
+       return;
 
    data.node = index->rd_node;
    data.blkno = BufferGetBlockNumber(buffer);
 
-   if ( GinPageIsData( page ) ) {
-       backup = GinDataPageGetData( page );
-       data.nitem = GinPageGetOpaque( page )->maxoff;
-       if ( data.nitem )
-           len = MAXALIGN( sizeof(ItemPointerData)*data.nitem );
-   } else {
-       char *ptr;
+   if (GinPageIsData(page))
+   {
+       backup = GinDataPageGetData(page);
+       data.nitem = GinPageGetOpaque(page)->maxoff;
+       if (data.nitem)
+           len = MAXALIGN(sizeof(ItemPointerData) * data.nitem);
+   }
+   else
+   {
+       char       *ptr;
        OffsetNumber i;
 
        ptr = backup = itups;
-       for(i=FirstOffsetNumber;i<=PageGetMaxOffsetNumber(page);i++) {
-           IndexTuple itup =  (IndexTuple) PageGetItem(page, PageGetItemId(page, i));
-           memcpy( ptr, itup, IndexTupleSize( itup ) );
-           ptr += MAXALIGN( IndexTupleSize( itup ) );
+       for (i = FirstOffsetNumber; i <= PageGetMaxOffsetNumber(page); i++)
+       {
+           IndexTuple  itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, i));
+
+           memcpy(ptr, itup, IndexTupleSize(itup));
+           ptr += MAXALIGN(IndexTupleSize(itup));
        }
 
        data.nitem = PageGetMaxOffsetNumber(page);
-       len = ptr-backup;
+       len = ptr - backup;
    }
 
    rdata[0].buffer = buffer;
-   rdata[0].buffer_std = ( GinPageIsData( page ) ) ? FALSE : TRUE;
+   rdata[0].buffer_std = (GinPageIsData(page)) ? FALSE : TRUE;
    rdata[0].len = 0;
    rdata[0].data = NULL;
    rdata[0].next = rdata + 1;
 
    rdata[1].buffer = InvalidBuffer;
    rdata[1].len = sizeof(ginxlogVacuumPage);
-   rdata[1].data = (char*)&data;
+   rdata[1].data = (char *) &data;
 
-   if ( len == 0 ) {
+   if (len == 0)
+   {
        rdata[1].next = NULL;
-   } else {
+   }
+   else
+   {
        rdata[1].next = rdata + 2;
 
        rdata[2].buffer = InvalidBuffer;
@@ -133,71 +150,84 @@ xlogVacuumPage(Relation index, Buffer buffer) {
 }
 
 static bool
-ginVacuumPostingTreeLeaves( GinVacuumState *gvs, BlockNumber blkno, bool isRoot, Buffer *rootBuffer ) { 
-   Buffer  buffer = ReadBuffer( gvs->index, blkno );
-   Page    page   = BufferGetPage( buffer );
-   bool    hasVoidPage = FALSE;    
+ginVacuumPostingTreeLeaves(GinVacuumState *gvs, BlockNumber blkno, bool isRoot, Buffer *rootBuffer)
+{
+   Buffer      buffer = ReadBuffer(gvs->index, blkno);
+   Page        page = BufferGetPage(buffer);
+   bool        hasVoidPage = FALSE;
 
-   /* 
+   /*
     * We should be sure that we don't concurrent with inserts, insert process
-    * never release root page until end (but it can unlock it and lock again).
-    * If we lock root with with LockBufferForCleanup, new scan process can't begin,
-    * but previous may run. 
-    * ginmarkpos/start* keeps buffer pinned, so we will wait for it.
-    * We lock only one posting tree in whole index, so, it's concurrent enough..
-    * Side effect: after this is full complete, tree is unused by any other process 
+    * never release root page until end (but it can unlock it and lock
+    * again). If we lock root with with LockBufferForCleanup, new scan
+    * process can't begin, but previous may run. ginmarkpos/start* keeps
+    * buffer pinned, so we will wait for it. We lock only one posting tree in
+    * whole index, so, it's concurrent enough.. Side effect: after this is
+    * full complete, tree is unused by any other process
     */
 
-   LockBufferForCleanup( buffer );
+   LockBufferForCleanup(buffer);
 
-   Assert( GinPageIsData(page) );
+   Assert(GinPageIsData(page));
 
-   if ( GinPageIsLeaf(page) ) {
-       OffsetNumber newMaxOff, oldMaxOff = GinPageGetOpaque(page)->maxoff;
+   if (GinPageIsLeaf(page))
+   {
+       OffsetNumber newMaxOff,
+                   oldMaxOff = GinPageGetOpaque(page)->maxoff;
        ItemPointerData *cleaned = NULL;
 
-       newMaxOff = ginVacuumPostingList( gvs, 
-               (ItemPointer)GinDataPageGetData(page), oldMaxOff, &cleaned );
+       newMaxOff = ginVacuumPostingList(gvs,
+               (ItemPointer) GinDataPageGetData(page), oldMaxOff, &cleaned);
 
        /* saves changes about deleted tuple ... */
-       if ( oldMaxOff != newMaxOff ) {
+       if (oldMaxOff != newMaxOff)
+       {
 
            START_CRIT_SECTION();
 
-           if ( newMaxOff > 0 ) 
-               memcpy( GinDataPageGetData(page), cleaned, sizeof(ItemPointerData) * newMaxOff );
-           pfree( cleaned );
+           if (newMaxOff > 0)
+               memcpy(GinDataPageGetData(page), cleaned, sizeof(ItemPointerData) * newMaxOff);
+           pfree(cleaned);
            GinPageGetOpaque(page)->maxoff = newMaxOff;
 
-           xlogVacuumPage(gvs->index,  buffer);
+           xlogVacuumPage(gvs->index, buffer);
 
-           MarkBufferDirty( buffer );
+           MarkBufferDirty(buffer);
            END_CRIT_SECTION();
-           
-           /* if root is a leaf page, we don't desire futher processing */ 
-           if ( !isRoot && GinPageGetOpaque(page)->maxoff < FirstOffsetNumber )
+
+           /* if root is a leaf page, we don't desire futher processing */
+           if (!isRoot && GinPageGetOpaque(page)->maxoff < FirstOffsetNumber)
                hasVoidPage = TRUE;
        }
-   } else {
+   }
+   else
+   {
        OffsetNumber i;
-       bool isChildHasVoid = FALSE;
+       bool        isChildHasVoid = FALSE;
+
+       for (i = FirstOffsetNumber; i <= GinPageGetOpaque(page)->maxoff; i++)
+       {
+           PostingItem *pitem = (PostingItem *) GinDataPageGetItem(page, i);
 
-       for( i=FirstOffsetNumber ; i <= GinPageGetOpaque(page)->maxoff ; i++ ) {
-           PostingItem *pitem = (PostingItem*)GinDataPageGetItem(page, i);
-           if ( ginVacuumPostingTreeLeaves( gvs, PostingItemGetBlockNumber(pitem), FALSE, NULL ) )
+           if (ginVacuumPostingTreeLeaves(gvs, PostingItemGetBlockNumber(pitem), FALSE, NULL))
                isChildHasVoid = TRUE;
        }
 
-       if ( isChildHasVoid )
+       if (isChildHasVoid)
            hasVoidPage = TRUE;
    }
 
-   /* if we have root and theres void pages in tree, then we don't release lock
-      to go further processing and guarantee that tree is unused */
-   if ( !(isRoot && hasVoidPage) ) {
-       UnlockReleaseBuffer( buffer );
-   } else {
-       Assert( rootBuffer );
+   /*
+    * if we have root and theres void pages in tree, then we don't release
+    * lock to go further processing and guarantee that tree is unused
+    */
+   if (!(isRoot && hasVoidPage))
+   {
+       UnlockReleaseBuffer(buffer);
+   }
+   else
+   {
+       Assert(rootBuffer);
        *rootBuffer = buffer;
    }
 
@@ -205,49 +235,54 @@ ginVacuumPostingTreeLeaves( GinVacuumState *gvs, BlockNumber blkno, bool isRoot,
 }
 
 static void
-ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkno, 
-       BlockNumber parentBlkno, OffsetNumber myoff, bool isParentRoot ) {
-   Buffer  dBuffer = ReadBuffer( gvs->index, deleteBlkno );
-   Buffer  lBuffer = (leftBlkno==InvalidBlockNumber) ? InvalidBuffer : ReadBuffer( gvs->index, leftBlkno );
-   Buffer  pBuffer = ReadBuffer( gvs->index, parentBlkno );
-   Page page, parentPage;
-
-   LockBuffer( dBuffer, GIN_EXCLUSIVE );
-   if ( !isParentRoot ) /* parent is already locked by LockBufferForCleanup() */
-       LockBuffer( pBuffer, GIN_EXCLUSIVE );
+ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkno,
+             BlockNumber parentBlkno, OffsetNumber myoff, bool isParentRoot)
+{
+   Buffer      dBuffer = ReadBuffer(gvs->index, deleteBlkno);
+   Buffer      lBuffer = (leftBlkno == InvalidBlockNumber) ? InvalidBuffer : ReadBuffer(gvs->index, leftBlkno);
+   Buffer      pBuffer = ReadBuffer(gvs->index, parentBlkno);
+   Page        page,
+               parentPage;
+
+   LockBuffer(dBuffer, GIN_EXCLUSIVE);
+   if (!isParentRoot)          /* parent is already locked by
+                                * LockBufferForCleanup() */
+       LockBuffer(pBuffer, GIN_EXCLUSIVE);
 
    START_CRIT_SECTION();
 
-   if ( leftBlkno!= InvalidBlockNumber ) {
+   if (leftBlkno != InvalidBlockNumber)
+   {
        BlockNumber rightlink;
 
-       LockBuffer( lBuffer, GIN_EXCLUSIVE );
+       LockBuffer(lBuffer, GIN_EXCLUSIVE);
 
-       page = BufferGetPage( dBuffer );
+       page = BufferGetPage(dBuffer);
        rightlink = GinPageGetOpaque(page)->rightlink;
 
-       page = BufferGetPage( lBuffer );
+       page = BufferGetPage(lBuffer);
        GinPageGetOpaque(page)->rightlink = rightlink;
    }
 
-   parentPage = BufferGetPage( pBuffer );
+   parentPage = BufferGetPage(pBuffer);
    PageDeletePostingItem(parentPage, myoff);
 
-   page = BufferGetPage( dBuffer );
+   page = BufferGetPage(dBuffer);
    GinPageGetOpaque(page)->flags = GIN_DELETED;
 
-   if (!gvs->index->rd_istemp) {
-       XLogRecPtr  recptr;
+   if (!gvs->index->rd_istemp)
+   {
+       XLogRecPtr  recptr;
        XLogRecData rdata[4];
-       ginxlogDeletePage    data;
-       int n;
+       ginxlogDeletePage data;
+       int         n;
 
        data.node = gvs->index->rd_node;
        data.blkno = deleteBlkno;
        data.parentBlkno = parentBlkno;
        data.parentOffset = myoff;
-       data.leftBlkno = leftBlkno; 
-       data.rightLink = GinPageGetOpaque(page)->rightlink; 
+       data.leftBlkno = leftBlkno;
+       data.rightLink = GinPageGetOpaque(page)->rightlink;
 
        rdata[0].buffer = dBuffer;
        rdata[0].buffer_std = FALSE;
@@ -261,20 +296,22 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
        rdata[1].len = 0;
        rdata[1].next = rdata + 2;
 
-       if ( leftBlkno!= InvalidBlockNumber ) {     
+       if (leftBlkno != InvalidBlockNumber)
+       {
            rdata[2].buffer = lBuffer;
            rdata[2].buffer_std = FALSE;
            rdata[2].data = NULL;
            rdata[2].len = 0;
            rdata[2].next = rdata + 3;
            n = 3;
-       } else
+       }
+       else
            n = 2;
 
        rdata[n].buffer = InvalidBuffer;
        rdata[n].buffer_std = FALSE;
        rdata[n].len = sizeof(ginxlogDeletePage);
-       rdata[n].data = (char*)&data;
+       rdata[n].data = (char *) &data;
        rdata[n].next = NULL;
 
        recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_DELETE_PAGE, rdata);
@@ -282,122 +319,141 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
        PageSetTLI(page, ThisTimeLineID);
        PageSetLSN(parentPage, recptr);
        PageSetTLI(parentPage, ThisTimeLineID);
-       if ( leftBlkno!= InvalidBlockNumber ) {
-           page = BufferGetPage( lBuffer );
+       if (leftBlkno != InvalidBlockNumber)
+       {
+           page = BufferGetPage(lBuffer);
            PageSetLSN(page, recptr);
            PageSetTLI(page, ThisTimeLineID);
        }
    }
 
-   MarkBufferDirty( pBuffer );
-   if ( !isParentRoot )
-       LockBuffer( pBuffer, GIN_UNLOCK );
-   ReleaseBuffer( pBuffer );
+   MarkBufferDirty(pBuffer);
+   if (!isParentRoot)
+       LockBuffer(pBuffer, GIN_UNLOCK);
+   ReleaseBuffer(pBuffer);
 
-   if ( leftBlkno!= InvalidBlockNumber ) {
-       MarkBufferDirty( lBuffer );
-       UnlockReleaseBuffer( lBuffer );
+   if (leftBlkno != InvalidBlockNumber)
+   {
+       MarkBufferDirty(lBuffer);
+       UnlockReleaseBuffer(lBuffer);
    }
 
-   MarkBufferDirty( dBuffer );
-   UnlockReleaseBuffer( dBuffer );
+   MarkBufferDirty(dBuffer);
+   UnlockReleaseBuffer(dBuffer);
 
    END_CRIT_SECTION();
 
    gvs->result->pages_deleted++;
 }
 
-typedef struct DataPageDeleteStack {
-   struct DataPageDeleteStack  *child; 
-   struct DataPageDeleteStack  *parent;
+typedef struct DataPageDeleteStack
+{
+   struct DataPageDeleteStack *child;
+   struct DataPageDeleteStack *parent;
 
-   BlockNumber                 blkno;
-   bool                        isRoot;
+   BlockNumber blkno;
+   bool        isRoot;
 } DataPageDeleteStack;
 
 /*
  * scans posting tree and deletes empty pages
  */
 static bool
-ginScanToDelete( GinVacuumState *gvs, BlockNumber blkno, bool isRoot, DataPageDeleteStack *parent, OffsetNumber myoff ) {
-   DataPageDeleteStack *me;
-   Buffer  buffer;
-   Page    page;
-   bool    meDelete = FALSE;
-
-   if ( isRoot ) {
+ginScanToDelete(GinVacuumState *gvs, BlockNumber blkno, bool isRoot, DataPageDeleteStack *parent, OffsetNumber myoff)
+{
+   DataPageDeleteStack *me;
+   Buffer      buffer;
+   Page        page;
+   bool        meDelete = FALSE;
+
+   if (isRoot)
+   {
        me = parent;
-   } else {
-       if ( ! parent->child ) {
-           me  = (DataPageDeleteStack*)palloc0(sizeof(DataPageDeleteStack));
-           me->parent=parent;
+   }
+   else
+   {
+       if (!parent->child)
+       {
+           me = (DataPageDeleteStack *) palloc0(sizeof(DataPageDeleteStack));
+           me->parent = parent;
            parent->child = me;
            me->blkno = InvalidBlockNumber;
-       } else
+       }
+       else
            me = parent->child;
    }
 
-   buffer = ReadBuffer( gvs->index, blkno ); 
-   page = BufferGetPage( buffer );
+   buffer = ReadBuffer(gvs->index, blkno);
+   page = BufferGetPage(buffer);
 
-   Assert( GinPageIsData(page) );
+   Assert(GinPageIsData(page));
 
-   if ( !GinPageIsLeaf(page) ) {
+   if (!GinPageIsLeaf(page))
+   {
        OffsetNumber i;
 
-       for(i=FirstOffsetNumber;i<=GinPageGetOpaque(page)->maxoff;i++) {
-           PostingItem *pitem = (PostingItem*)GinDataPageGetItem(page, i);
+       for (i = FirstOffsetNumber; i <= GinPageGetOpaque(page)->maxoff; i++)
+       {
+           PostingItem *pitem = (PostingItem *) GinDataPageGetItem(page, i);
 
-           if ( ginScanToDelete( gvs, PostingItemGetBlockNumber(pitem), FALSE, me, i ) )
+           if (ginScanToDelete(gvs, PostingItemGetBlockNumber(pitem), FALSE, me, i))
                i--;
        }
    }
 
-   if ( GinPageGetOpaque(page)->maxoff < FirstOffsetNumber ) {
-       if ( !( me->blkno == InvalidBlockNumber && GinPageRightMost(page) ) ) {
+   if (GinPageGetOpaque(page)->maxoff < FirstOffsetNumber)
+   {
+       if (!(me->blkno == InvalidBlockNumber && GinPageRightMost(page)))
+       {
            /* we never delete right most branch */
-           Assert( !isRoot );
-           if ( GinPageGetOpaque(page)->maxoff < FirstOffsetNumber )  {
-               ginDeletePage( gvs, blkno, me->blkno, me->parent->blkno, myoff, me->parent->isRoot );
+           Assert(!isRoot);
+           if (GinPageGetOpaque(page)->maxoff < FirstOffsetNumber)
+           {
+               ginDeletePage(gvs, blkno, me->blkno, me->parent->blkno, myoff, me->parent->isRoot);
                meDelete = TRUE;
            }
        }
    }
 
-   ReleaseBuffer( buffer );
+   ReleaseBuffer(buffer);
 
-   if ( !meDelete )
+   if (!meDelete)
        me->blkno = blkno;
 
    return meDelete;
 }
 
 static void
-ginVacuumPostingTree( GinVacuumState *gvs, BlockNumber rootBlkno ) {
-   Buffer  rootBuffer = InvalidBuffer;
-   DataPageDeleteStack root, *ptr, *tmp;
-
-   if ( ginVacuumPostingTreeLeaves(gvs, rootBlkno, TRUE, &rootBuffer)==FALSE ) {
-       Assert( rootBuffer == InvalidBuffer );
+ginVacuumPostingTree(GinVacuumState *gvs, BlockNumber rootBlkno)
+{
+   Buffer      rootBuffer = InvalidBuffer;
+   DataPageDeleteStack root,
+              *ptr,
+              *tmp;
+
+   if (ginVacuumPostingTreeLeaves(gvs, rootBlkno, TRUE, &rootBuffer) == FALSE)
+   {
+       Assert(rootBuffer == InvalidBuffer);
        return;
    }
 
-   memset(&root,0,sizeof(DataPageDeleteStack));
+   memset(&root, 0, sizeof(DataPageDeleteStack));
    root.blkno = rootBlkno;
    root.isRoot = TRUE;
 
    vacuum_delay_point();
 
-   ginScanToDelete( gvs, rootBlkno, TRUE, &root, InvalidOffsetNumber ); 
+   ginScanToDelete(gvs, rootBlkno, TRUE, &root, InvalidOffsetNumber);
 
    ptr = root.child;
-   while( ptr ) {
+   while (ptr)
+   {
        tmp = ptr->child;
-       pfree( ptr );
+       pfree(ptr);
        ptr = tmp;
    }
 
-   UnlockReleaseBuffer( rootBuffer );
+   UnlockReleaseBuffer(rootBuffer);
 }
 
 /*
@@ -406,48 +462,65 @@ ginVacuumPostingTree( GinVacuumState *gvs, BlockNumber rootBlkno ) {
  * then page is copied into temprorary one.
  */
 static Page
-ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint32 *nroot) {
-   Page    origpage = BufferGetPage( buffer ), tmppage;
-   OffsetNumber i, maxoff = PageGetMaxOffsetNumber( origpage );
+ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint32 *nroot)
+{
+   Page        origpage = BufferGetPage(buffer),
+               tmppage;
+   OffsetNumber i,
+               maxoff = PageGetMaxOffsetNumber(origpage);
 
    tmppage = origpage;
 
-   *nroot=0;
+   *nroot = 0;
 
-   for(i=FirstOffsetNumber; i<= maxoff; i++) {
-       IndexTuple itup = (IndexTuple) PageGetItem(tmppage, PageGetItemId(tmppage, i));
+   for (i = FirstOffsetNumber; i <= maxoff; i++)
+   {
+       IndexTuple  itup = (IndexTuple) PageGetItem(tmppage, PageGetItemId(tmppage, i));
 
-       if ( GinIsPostingTree(itup) ) {
-           /* store posting tree's roots for further processing,
-              we can't vacuum it just now due to risk of deadlocks with scans/inserts */
-           roots[ *nroot ] = GinItemPointerGetBlockNumber(&itup->t_tid);
+       if (GinIsPostingTree(itup))
+       {
+           /*
+            * store posting tree's roots for further processing, we can't
+            * vacuum it just now due to risk of deadlocks with scans/inserts
+            */
+           roots[*nroot] = GinItemPointerGetBlockNumber(&itup->t_tid);
            (*nroot)++;
-       } else if ( GinGetNPosting(itup) > 0 ) {
-           /* if we already create temrorary page, we will make changes in place */
-           ItemPointerData *cleaned = (tmppage==origpage) ? NULL : GinGetPosting(itup );
-           uint32  newN = ginVacuumPostingList( gvs, GinGetPosting(itup), GinGetNPosting(itup), &cleaned );
-           
-           if ( GinGetNPosting(itup) != newN ) {
-               bool    isnull;
-               Datum value;
+       }
+       else if (GinGetNPosting(itup) > 0)
+       {
+           /*
+            * if we already create temrorary page, we will make changes in
+            * place
+            */
+           ItemPointerData *cleaned = (tmppage == origpage) ? NULL : GinGetPosting(itup);
+           uint32      newN = ginVacuumPostingList(gvs, GinGetPosting(itup), GinGetNPosting(itup), &cleaned);
+
+           if (GinGetNPosting(itup) != newN)
+           {
+               bool        isnull;
+               Datum       value;
 
                /*
-                * Some ItemPointers was deleted, so we should remake our tuple 
+                * Some ItemPointers was deleted, so we should remake our
+                * tuple
                 */
 
-               if ( tmppage==origpage ) {
+               if (tmppage == origpage)
+               {
                    /*
                     * On first difference we create temprorary page in memory
                     * and copies content in to it.
                     */
-                   tmppage=GinPageGetCopyPage ( origpage );
+                   tmppage = GinPageGetCopyPage(origpage);
+
+                   if (newN > 0)
+                   {
+                       Size        pos = ((char *) GinGetPosting(itup)) - ((char *) origpage);
 
-                   if ( newN > 0 ) { 
-                       Size    pos = ((char*)GinGetPosting(itup)) - ((char*)origpage);
-                       memcpy( tmppage+pos, cleaned, sizeof(ItemPointerData)*newN );
+                       memcpy(tmppage + pos, cleaned, sizeof(ItemPointerData) * newN);
                    }
 
-                   pfree( cleaned );
+                   pfree(cleaned);
 
                    /* set itup pointer to new page */
                    itup = (IndexTuple) PageGetItem(tmppage, PageGetItemId(tmppage, i));
@@ -457,30 +530,31 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
                itup = GinFormTuple(&gvs->ginstate, value, GinGetPosting(itup), newN);
                PageIndexTupleDelete(tmppage, i);
 
-               if ( PageAddItem( tmppage, (Item)itup, IndexTupleSize(itup), i, LP_USED ) != i )
-                       elog(ERROR, "failed to add item to index page in \"%s\"",
-                               RelationGetRelationName(gvs->index));
+               if (PageAddItem(tmppage, (Item) itup, IndexTupleSize(itup), i, LP_USED) != i)
+                   elog(ERROR, "failed to add item to index page in \"%s\"",
+                        RelationGetRelationName(gvs->index));
 
-               pfree( itup );
+               pfree(itup);
            }
        }
    }
 
-   return  ( tmppage==origpage ) ? NULL : tmppage;
+   return (tmppage == origpage) ? NULL : tmppage;
 }
 
 Datum
-ginbulkdelete(PG_FUNCTION_ARGS) {
+ginbulkdelete(PG_FUNCTION_ARGS)
+{
    IndexVacuumInfo *info = (IndexVacuumInfo *) PG_GETARG_POINTER(0);
    IndexBulkDeleteResult *stats = (IndexBulkDeleteResult *) PG_GETARG_POINTER(1);
    IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(2);
    void       *callback_state = (void *) PG_GETARG_POINTER(3);
    Relation    index = info->index;
-   BlockNumber blkno = GIN_ROOT_BLKNO;
-   GinVacuumState  gvs;
-   Buffer      buffer;
-   BlockNumber rootOfPostingTree[ BLCKSZ/ (sizeof(IndexTupleData)+sizeof(ItemId)) ];
-   uint32 nRoot;
+   BlockNumber blkno = GIN_ROOT_BLKNO;
+   GinVacuumState gvs;
+   Buffer      buffer;
+   BlockNumber rootOfPostingTree[BLCKSZ / (sizeof(IndexTupleData) + sizeof(ItemId))];
+   uint32      nRoot;
 
    /* first time through? */
    if (stats == NULL)
@@ -494,107 +568,117 @@ ginbulkdelete(PG_FUNCTION_ARGS) {
    gvs.callback_state = callback_state;
    initGinState(&gvs.ginstate, index);
 
-   buffer = ReadBuffer( index, blkno );
+   buffer = ReadBuffer(index, blkno);
 
    /* find leaf page */
-   for(;;) {
-       Page page = BufferGetPage( buffer );
-       IndexTuple  itup;
+   for (;;)
+   {
+       Page        page = BufferGetPage(buffer);
+       IndexTuple  itup;
 
-       LockBuffer(buffer,GIN_SHARE);
+       LockBuffer(buffer, GIN_SHARE);
 
-       Assert( !GinPageIsData(page) );
+       Assert(!GinPageIsData(page));
 
-       if ( GinPageIsLeaf(page) ) {
-           LockBuffer(buffer,GIN_UNLOCK);
-           LockBuffer(buffer,GIN_EXCLUSIVE);
+       if (GinPageIsLeaf(page))
+       {
+           LockBuffer(buffer, GIN_UNLOCK);
+           LockBuffer(buffer, GIN_EXCLUSIVE);
 
-           if ( blkno==GIN_ROOT_BLKNO && !GinPageIsLeaf(page) ) {
-               LockBuffer(buffer,GIN_UNLOCK);
-               continue; /* check it one more */
+           if (blkno == GIN_ROOT_BLKNO && !GinPageIsLeaf(page))
+           {
+               LockBuffer(buffer, GIN_UNLOCK);
+               continue;       /* check it one more */
            }
-           break;  
+           break;
        }
 
-       Assert( PageGetMaxOffsetNumber(page) >= FirstOffsetNumber );
+       Assert(PageGetMaxOffsetNumber(page) >= FirstOffsetNumber);
 
        itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, FirstOffsetNumber));
        blkno = GinItemPointerGetBlockNumber(&(itup)->t_tid);
-       Assert( blkno!= InvalidBlockNumber );
+       Assert(blkno != InvalidBlockNumber);
 
-       LockBuffer(buffer,GIN_UNLOCK);
-       buffer = ReleaseAndReadBuffer( buffer, index, blkno );
+       LockBuffer(buffer, GIN_UNLOCK);
+       buffer = ReleaseAndReadBuffer(buffer, index, blkno);
    }
 
    /* right now we found leftmost page in entry's BTree */
 
-   for(;;) {
-       Page    page = BufferGetPage( buffer );
-       Page    resPage;
-       uint32  i;
+   for (;;)
+   {
+       Page        page = BufferGetPage(buffer);
+       Page        resPage;
+       uint32      i;
 
-       Assert( !GinPageIsData(page) );
+       Assert(!GinPageIsData(page));
 
        resPage = ginVacuumEntryPage(&gvs, buffer, rootOfPostingTree, &nRoot);
 
-       blkno = GinPageGetOpaque( page )->rightlink;
+       blkno = GinPageGetOpaque(page)->rightlink;
 
-       if ( resPage ) {
+       if (resPage)
+       {
            START_CRIT_SECTION();
-           PageRestoreTempPage( resPage, page );
-           xlogVacuumPage(gvs.index,  buffer);
-           MarkBufferDirty( buffer );
+           PageRestoreTempPage(resPage, page);
+           xlogVacuumPage(gvs.index, buffer);
+           MarkBufferDirty(buffer);
            UnlockReleaseBuffer(buffer);
            END_CRIT_SECTION();
-       } else {
+       }
+       else
+       {
            UnlockReleaseBuffer(buffer);
        }
 
        vacuum_delay_point();
 
-       for(i=0; i
-           ginVacuumPostingTree( &gvs, rootOfPostingTree[i] );
+       for (i = 0; i < nRoot; i++)
+       {
+           ginVacuumPostingTree(&gvs, rootOfPostingTree[i]);
            vacuum_delay_point();
        }
 
-       if ( blkno==InvalidBlockNumber ) /*rightmost page*/
+       if (blkno == InvalidBlockNumber)        /* rightmost page */
            break;
 
-       buffer = ReadBuffer( index, blkno );
-       LockBuffer(buffer,GIN_EXCLUSIVE);
+       buffer = ReadBuffer(index, blkno);
+       LockBuffer(buffer, GIN_EXCLUSIVE);
    }
 
    PG_RETURN_POINTER(gvs.result);
 }
 
-Datum 
-ginvacuumcleanup(PG_FUNCTION_ARGS) {
+Datum
+ginvacuumcleanup(PG_FUNCTION_ARGS)
+{
    IndexVacuumInfo *info = (IndexVacuumInfo *) PG_GETARG_POINTER(0);
    IndexBulkDeleteResult *stats = (IndexBulkDeleteResult *) PG_GETARG_POINTER(1);
-   Relation    index = info->index;
-   bool     needLock;
-    BlockNumber npages,
+   Relation    index = info->index;
+   bool        needLock;
+   BlockNumber npages,
                blkno;
    BlockNumber totFreePages,
                nFreePages,
               *freePages,
-              maxFreePages;
+               maxFreePages;
    BlockNumber lastBlock = GIN_ROOT_BLKNO,
-                  lastFilledBlock = GIN_ROOT_BLKNO;
+               lastFilledBlock = GIN_ROOT_BLKNO;
 
    /* Set up all-zero stats if ginbulkdelete wasn't called */
    if (stats == NULL)
        stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult));
+
    /*
     * XXX we always report the heap tuple count as the number of index
-    * entries.  This is bogus if the index is partial, but it's real hard
-    * to tell how many distinct heap entries are referenced by a GIN index.
+    * entries.  This is bogus if the index is partial, but it's real hard to
+    * tell how many distinct heap entries are referenced by a GIN index.
     */
    stats->num_index_tuples = info->num_heap_tuples;
 
    /*
-    * If vacuum full, we already have exclusive lock on the index.
-    * Otherwise, need lock unless it's local to this backend.
+    * If vacuum full, we already have exclusive lock on the index. Otherwise,
+    * need lock unless it's local to this backend.
     */
    if (info->vacuum_full)
        needLock = false;
@@ -614,32 +698,38 @@ ginvacuumcleanup(PG_FUNCTION_ARGS) {
    totFreePages = nFreePages = 0;
    freePages = (BlockNumber *) palloc(sizeof(BlockNumber) * maxFreePages);
 
-   for (blkno = GIN_ROOT_BLKNO + 1; blkno < npages; blkno++) {
-       Buffer buffer;
-       Page   page;
+   for (blkno = GIN_ROOT_BLKNO + 1; blkno < npages; blkno++)
+   {
+       Buffer      buffer;
+       Page        page;
 
        vacuum_delay_point();
-   
+
        buffer = ReadBuffer(index, blkno);
        LockBuffer(buffer, GIN_SHARE);
        page = (Page) BufferGetPage(buffer);
 
-       if ( GinPageIsDeleted(page) ) {
+       if (GinPageIsDeleted(page))
+       {
            if (nFreePages < maxFreePages)
                freePages[nFreePages++] = blkno;
            totFreePages++;
-       } else
+       }
+       else
            lastFilledBlock = blkno;
 
        UnlockReleaseBuffer(buffer);
    }
    lastBlock = npages - 1;
 
-   if (info->vacuum_full && nFreePages > 0) {
+   if (info->vacuum_full && nFreePages > 0)
+   {
        /* try to truncate index */
-       int         i;
-       for (i = 0; i < nFreePages; i++) 
-           if (freePages[i] >= lastFilledBlock) {
+       int         i;
+
+       for (i = 0; i < nFreePages; i++)
+           if (freePages[i] >= lastFilledBlock)
+           {
                totFreePages = nFreePages = i;
                break;
            }
@@ -661,4 +751,3 @@ ginvacuumcleanup(PG_FUNCTION_ARGS) {
 
    PG_RETURN_POINTER(stats);
 }
-
index 265e7de70c48278c985a0ba56e634e59df3eb6b6..788f290b84368b49165a8680e5c85a4b248c4cbd 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.4 2006/08/07 16:57:56 tgl Exp $
+ *          $PostgreSQL: pgsql/src/backend/access/gin/ginxlog.c,v 1.5 2006/10/04 00:29:48 momjian Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
 #include "access/heapam.h"
 #include "utils/memutils.h"
 
-static MemoryContext opCtx;     /* working memory for operations */
+static MemoryContext opCtx;        /* working memory for operations */
 static MemoryContext topCtx;
 
-typedef struct ginIncompleteSplit {
-   RelFileNode node;
-    BlockNumber leftBlkno;
+typedef struct ginIncompleteSplit
+{
+   RelFileNode node;
+   BlockNumber leftBlkno;
    BlockNumber rightBlkno;
    BlockNumber rootBlkno;
 } ginIncompleteSplit;
@@ -30,10 +31,11 @@ typedef struct ginIncompleteSplit {
 static List *incomplete_splits;
 
 static void
-pushIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber rightBlkno, BlockNumber rootBlkno) {
-   ginIncompleteSplit *split; 
+pushIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber rightBlkno, BlockNumber rootBlkno)
+{
+   ginIncompleteSplit *split;
 
-   MemoryContextSwitchTo( topCtx );    
+   MemoryContextSwitchTo(topCtx);
 
    split = palloc(sizeof(ginIncompleteSplit));
 
@@ -44,17 +46,20 @@ pushIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber rightBl
 
    incomplete_splits = lappend(incomplete_splits, split);
 
-   MemoryContextSwitchTo( opCtx ); 
+   MemoryContextSwitchTo(opCtx);
 }
 
 static void
-forgetIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber updateBlkno) {
+forgetIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber updateBlkno)
+{
    ListCell   *l;
 
-   foreach(l, incomplete_splits) {
-       ginIncompleteSplit  *split = (ginIncompleteSplit *) lfirst(l);
+   foreach(l, incomplete_splits)
+   {
+       ginIncompleteSplit *split = (ginIncompleteSplit *) lfirst(l);
 
-       if ( RelFileNodeEquals(node, split->node) && leftBlkno == split->leftBlkno && updateBlkno == split->rightBlkno ) {
+       if (RelFileNodeEquals(node, split->node) && leftBlkno == split->leftBlkno && updateBlkno == split->rightBlkno)
+       {
            incomplete_splits = list_delete_ptr(incomplete_splits, split);
            break;
        }
@@ -62,7 +67,8 @@ forgetIncompleteSplit(RelFileNode node, BlockNumber leftBlkno, BlockNumber updat
 }
 
 static void
-ginRedoCreateIndex(XLogRecPtr lsn, XLogRecord *record) {
+ginRedoCreateIndex(XLogRecPtr lsn, XLogRecord *record)
+{
    RelFileNode *node = (RelFileNode *) XLogRecGetData(record);
    Relation    reln;
    Buffer      buffer;
@@ -83,9 +89,10 @@ ginRedoCreateIndex(XLogRecPtr lsn, XLogRecord *record) {
 }
 
 static void
-ginRedoCreatePTree(XLogRecPtr lsn, XLogRecord *record) {
-   ginxlogCreatePostingTree    *data = (ginxlogCreatePostingTree*)XLogRecGetData(record);
-   ItemPointerData             *items = (ItemPointerData*)(XLogRecGetData(record) + sizeof(ginxlogCreatePostingTree));
+ginRedoCreatePTree(XLogRecPtr lsn, XLogRecord *record)
+{
+   ginxlogCreatePostingTree *data = (ginxlogCreatePostingTree *) XLogRecGetData(record);
+   ItemPointerData *items = (ItemPointerData *) (XLogRecGetData(record) + sizeof(ginxlogCreatePostingTree));
    Relation    reln;
    Buffer      buffer;
    Page        page;
@@ -95,8 +102,8 @@ ginRedoCreatePTree(XLogRecPtr lsn, XLogRecord *record) {
    Assert(BufferIsValid(buffer));
    page = (Page) BufferGetPage(buffer);
 
-   GinInitBuffer(buffer, GIN_DATA|GIN_LEAF);
-   memcpy( GinDataPageGetData(page), items, sizeof(ItemPointerData) * data->nitem );
+   GinInitBuffer(buffer, GIN_DATA | GIN_LEAF);
+   memcpy(GinDataPageGetData(page), items, sizeof(ItemPointerData) * data->nitem);
    GinPageGetOpaque(page)->maxoff = data->nitem;
 
    PageSetLSN(page, lsn);
@@ -107,8 +114,9 @@ ginRedoCreatePTree(XLogRecPtr lsn, XLogRecord *record) {
 }
 
 static void
-ginRedoInsert(XLogRecPtr lsn, XLogRecord *record) {
-   ginxlogInsert   *data = (ginxlogInsert*)XLogRecGetData(record);
+ginRedoInsert(XLogRecPtr lsn, XLogRecord *record)
+{
+   ginxlogInsert *data = (ginxlogInsert *) XLogRecGetData(record);
    Relation    reln;
    Buffer      buffer;
    Page        page;
@@ -122,64 +130,73 @@ ginRedoInsert(XLogRecPtr lsn, XLogRecord *record) {
    Assert(BufferIsValid(buffer));
    page = (Page) BufferGetPage(buffer);
 
-   if ( data->isData ) {
-       Assert( data->isDelete == FALSE );
-       Assert( GinPageIsData( page ) );
+   if (data->isData)
+   {
+       Assert(data->isDelete == FALSE);
+       Assert(GinPageIsData(page));
 
-       if ( data->isLeaf ) {
+       if (data->isLeaf)
+       {
            OffsetNumber i;
-           ItemPointerData *items = (ItemPointerData*)( XLogRecGetData(record) + sizeof(ginxlogInsert) );
+           ItemPointerData *items = (ItemPointerData *) (XLogRecGetData(record) + sizeof(ginxlogInsert));
 
-           Assert( GinPageIsLeaf( page ) );
-           Assert( data->updateBlkno == InvalidBlockNumber );
+           Assert(GinPageIsLeaf(page));
+           Assert(data->updateBlkno == InvalidBlockNumber);
 
-           for(i=0;initem;i++)
-               GinDataPageAddItem( page, items+i, data->offset + i );  
-       } else {
+           for (i = 0; i < data->nitem; i++)
+               GinDataPageAddItem(page, items + i, data->offset + i);
+       }
+       else
+       {
            PostingItem *pitem;
 
-           Assert( !GinPageIsLeaf( page ) );
+           Assert(!GinPageIsLeaf(page));
 
-           if ( data->updateBlkno != InvalidBlockNumber ) {
-               /* update link to right page after split */ 
-               pitem = (PostingItem*)GinDataPageGetItem(page, data->offset);
-               PostingItemSetBlockNumber( pitem, data->updateBlkno );
+           if (data->updateBlkno != InvalidBlockNumber)
+           {
+               /* update link to right page after split */
+               pitem = (PostingItem *) GinDataPageGetItem(page, data->offset);
+               PostingItemSetBlockNumber(pitem, data->updateBlkno);
            }
 
-           pitem = (PostingItem*)( XLogRecGetData(record) + sizeof(ginxlogInsert) );
+           pitem = (PostingItem *) (XLogRecGetData(record) + sizeof(ginxlogInsert));
 
-           GinDataPageAddItem( page, pitem, data->offset );
+           GinDataPageAddItem(page, pitem, data->offset);
 
-           if ( data->updateBlkno != InvalidBlockNumber ) 
-               forgetIncompleteSplit(data->node, PostingItemGetBlockNumber( pitem ), data->updateBlkno);
+           if (data->updateBlkno != InvalidBlockNumber)
+               forgetIncompleteSplit(data->node, PostingItemGetBlockNumber(pitem), data->updateBlkno);
        }
-   } else {
-       IndexTuple itup;
+   }
+   else
+   {
+       IndexTuple  itup;
 
-       Assert( !GinPageIsData( page ) );
+       Assert(!GinPageIsData(page));
 
-       if ( data->updateBlkno != InvalidBlockNumber ) {
-           /* update link to right page after split */ 
-           Assert( !GinPageIsLeaf( page ) );
-           Assert( data->offset>=FirstOffsetNumber && data->offset<=PageGetMaxOffsetNumber(page) );
+       if (data->updateBlkno != InvalidBlockNumber)
+       {
+           /* update link to right page after split */
+           Assert(!GinPageIsLeaf(page));
+           Assert(data->offset >= FirstOffsetNumber && data->offset <= PageGetMaxOffsetNumber(page));
            itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, data->offset));
            ItemPointerSet(&itup->t_tid, data->updateBlkno, InvalidOffsetNumber);
        }
 
-       if ( data->isDelete ) {
-           Assert( GinPageIsLeaf( page ) );
-           Assert( data->offset>=FirstOffsetNumber && data->offset<=PageGetMaxOffsetNumber(page) );
+       if (data->isDelete)
+       {
+           Assert(GinPageIsLeaf(page));
+           Assert(data->offset >= FirstOffsetNumber && data->offset <= PageGetMaxOffsetNumber(page));
            PageIndexTupleDelete(page, data->offset);
        }
 
-       itup = (IndexTuple)( XLogRecGetData(record) + sizeof(ginxlogInsert) );
+       itup = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogInsert));
 
-       if ( PageAddItem( page, (Item)itup, IndexTupleSize(itup), data->offset, LP_USED) == InvalidOffsetNumber )
-           elog(ERROR, "failed to add item to index page in %u/%u/%u", 
-               data->node.spcNode, data->node.dbNode, data->node.relNode );
+       if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), data->offset, LP_USED) == InvalidOffsetNumber)
+           elog(ERROR, "failed to add item to index page in %u/%u/%u",
+                data->node.spcNode, data->node.dbNode, data->node.relNode);
 
-       if ( !data->isLeaf && data->updateBlkno != InvalidBlockNumber )
-           forgetIncompleteSplit(data->node, GinItemPointerGetBlockNumber( &itup->t_tid ), data->updateBlkno);
+       if (!data->isLeaf && data->updateBlkno != InvalidBlockNumber)
+           forgetIncompleteSplit(data->node, GinItemPointerGetBlockNumber(&itup->t_tid), data->updateBlkno);
    }
 
    PageSetLSN(page, lsn);
@@ -190,18 +207,21 @@ ginRedoInsert(XLogRecPtr lsn, XLogRecord *record) {
 }
 
 static void
-ginRedoSplit(XLogRecPtr lsn, XLogRecord *record) {
-   ginxlogSplit    *data = (ginxlogSplit*)XLogRecGetData(record);
+ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
+{
+   ginxlogSplit *data = (ginxlogSplit *) XLogRecGetData(record);
    Relation    reln;
-   Buffer      lbuffer, rbuffer;
-   Page        lpage, rpage;
+   Buffer      lbuffer,
+               rbuffer;
+   Page        lpage,
+               rpage;
    uint32      flags = 0;
 
    reln = XLogOpenRelation(data->node);
 
-   if ( data->isLeaf )
+   if (data->isLeaf)
        flags |= GIN_LEAF;
-   if ( data->isData )
+   if (data->isData)
        flags |= GIN_DATA;
 
    lbuffer = XLogReadBuffer(reln, data->lblkno, data->isRootSplit);
@@ -214,50 +234,57 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record) {
    rpage = (Page) BufferGetPage(rbuffer);
    GinInitBuffer(rbuffer, flags);
 
-   GinPageGetOpaque(lpage)->rightlink = BufferGetBlockNumber( rbuffer );
+   GinPageGetOpaque(lpage)->rightlink = BufferGetBlockNumber(rbuffer);
    GinPageGetOpaque(rpage)->rightlink = data->rrlink;
 
-   if ( data->isData ) {
-       char    *ptr = XLogRecGetData(record) + sizeof(ginxlogSplit);
-       Size    sizeofitem = GinSizeOfItem(lpage);
+   if (data->isData)
+   {
+       char       *ptr = XLogRecGetData(record) + sizeof(ginxlogSplit);
+       Size        sizeofitem = GinSizeOfItem(lpage);
        OffsetNumber i;
-       ItemPointer bound;
+       ItemPointer bound;
 
-       for(i=0;iseparator;i++) {
-           GinDataPageAddItem( lpage, ptr, InvalidOffsetNumber );
+       for (i = 0; i < data->separator; i++)
+       {
+           GinDataPageAddItem(lpage, ptr, InvalidOffsetNumber);
            ptr += sizeofitem;
        }
 
-       for(i=data->separator;initem;i++) {
-           GinDataPageAddItem( rpage, ptr, InvalidOffsetNumber );
+       for (i = data->separator; i < data->nitem; i++)
+       {
+           GinDataPageAddItem(rpage, ptr, InvalidOffsetNumber);
            ptr += sizeofitem;
        }
 
        /* set up right key */
        bound = GinDataPageGetRightBound(lpage);
-       if ( data->isLeaf ) 
-           *bound = *(ItemPointerData*)GinDataPageGetItem(lpage, GinPageGetOpaque(lpage)->maxoff);
+       if (data->isLeaf)
+           *bound = *(ItemPointerData *) GinDataPageGetItem(lpage, GinPageGetOpaque(lpage)->maxoff);
        else
-           *bound = ((PostingItem*)GinDataPageGetItem(lpage, GinPageGetOpaque(lpage)->maxoff))->key;
+           *bound = ((PostingItem *) GinDataPageGetItem(lpage, GinPageGetOpaque(lpage)->maxoff))->key;
 
        bound = GinDataPageGetRightBound(rpage);
        *bound = data->rightbound;
-   } else {
-       IndexTuple itup = (IndexTuple)( XLogRecGetData(record) + sizeof(ginxlogSplit) );
+   }
+   else
+   {
+       IndexTuple  itup = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogSplit));
        OffsetNumber i;
 
-       for(i=0;iseparator;i++) {
-           if ( PageAddItem( lpage, (Item)itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber )
-               elog(ERROR, "failed to add item to index page in %u/%u/%u", 
-                   data->node.spcNode, data->node.dbNode, data->node.relNode );
-           itup = (IndexTuple)(  ((char*)itup) + MAXALIGN( IndexTupleSize(itup) ) );
+       for (i = 0; i < data->separator; i++)
+       {
+           if (PageAddItem(lpage, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
+               elog(ERROR, "failed to add item to index page in %u/%u/%u",
+                 data->node.spcNode, data->node.dbNode, data->node.relNode);
+           itup = (IndexTuple) (((char *) itup) + MAXALIGN(IndexTupleSize(itup)));
        }
 
-       for(i=data->separator;initem;i++) {
-           if ( PageAddItem( rpage, (Item)itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber )
-               elog(ERROR, "failed to add item to index page in %u/%u/%u", 
-                   data->node.spcNode, data->node.dbNode, data->node.relNode );
-           itup = (IndexTuple)(  ((char*)itup) + MAXALIGN( IndexTupleSize(itup) ) );
+       for (i = data->separator; i < data->nitem; i++)
+       {
+           if (PageAddItem(rpage, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
+               elog(ERROR, "failed to add item to index page in %u/%u/%u",
+                 data->node.spcNode, data->node.dbNode, data->node.relNode);
+           itup = (IndexTuple) (((char *) itup) + MAXALIGN(IndexTupleSize(itup)));
        }
    }
 
@@ -269,20 +296,24 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record) {
    PageSetTLI(lpage, ThisTimeLineID);
    MarkBufferDirty(lbuffer);
 
-   if ( !data->isLeaf && data->updateBlkno != InvalidBlockNumber ) 
+   if (!data->isLeaf && data->updateBlkno != InvalidBlockNumber)
        forgetIncompleteSplit(data->node, data->leftChildBlkno, data->updateBlkno);
 
-   if ( data->isRootSplit ) {
-       Buffer  rootBuf = XLogReadBuffer(reln, data->rootBlkno, false);
-       Page    rootPage = BufferGetPage( rootBuf );
+   if (data->isRootSplit)
+   {
+       Buffer      rootBuf = XLogReadBuffer(reln, data->rootBlkno, false);
+       Page        rootPage = BufferGetPage(rootBuf);
 
-       GinInitBuffer( rootBuf, flags & ~GIN_LEAF );
+       GinInitBuffer(rootBuf, flags & ~GIN_LEAF);
 
-       if ( data->isData ) {
-           Assert( data->rootBlkno != GIN_ROOT_BLKNO );
+       if (data->isData)
+       {
+           Assert(data->rootBlkno != GIN_ROOT_BLKNO);
            dataFillRoot(NULL, rootBuf, lbuffer, rbuffer);
-       } else {
-           Assert( data->rootBlkno == GIN_ROOT_BLKNO );
+       }
+       else
+       {
+           Assert(data->rootBlkno == GIN_ROOT_BLKNO);
            entryFillRoot(NULL, rootBuf, lbuffer, rbuffer);
        }
 
@@ -291,7 +322,8 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record) {
 
        MarkBufferDirty(rootBuf);
        UnlockReleaseBuffer(rootBuf);
-   } else 
+   }
+   else
        pushIncompleteSplit(data->node, data->lblkno, data->rblkno, data->rootBlkno);
 
    UnlockReleaseBuffer(rbuffer);
@@ -299,8 +331,9 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record) {
 }
 
 static void
-ginRedoVacuumPage(XLogRecPtr lsn, XLogRecord *record) {
-   ginxlogVacuumPage   *data = (ginxlogVacuumPage*)XLogRecGetData(record);
+ginRedoVacuumPage(XLogRecPtr lsn, XLogRecord *record)
+{
+   ginxlogVacuumPage *data = (ginxlogVacuumPage *) XLogRecGetData(record);
    Relation    reln;
    Buffer      buffer;
    Page        page;
@@ -314,25 +347,30 @@ ginRedoVacuumPage(XLogRecPtr lsn, XLogRecord *record) {
    Assert(BufferIsValid(buffer));
    page = (Page) BufferGetPage(buffer);
 
-   if ( GinPageIsData( page ) ) {
-       memcpy( GinDataPageGetData(page), XLogRecGetData(record) + sizeof(ginxlogVacuumPage),
-                   GinSizeOfItem(page) * data->nitem );
+   if (GinPageIsData(page))
+   {
+       memcpy(GinDataPageGetData(page), XLogRecGetData(record) + sizeof(ginxlogVacuumPage),
+              GinSizeOfItem(page) *data->nitem);
        GinPageGetOpaque(page)->maxoff = data->nitem;
-   } else {
-       OffsetNumber i, *tod;
-       IndexTuple itup = (IndexTuple)( XLogRecGetData(record) + sizeof(ginxlogVacuumPage) );
-
-       tod = (OffsetNumber*)palloc( sizeof(OffsetNumber) * PageGetMaxOffsetNumber(page) );
-       for(i=FirstOffsetNumber;i<=PageGetMaxOffsetNumber(page);i++)
-           tod[i-1] = i;
-
-       PageIndexMultiDelete(page, tod, PageGetMaxOffsetNumber(page));  
-           
-       for(i=0;initem;i++) {
-           if ( PageAddItem( page, (Item)itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber )
-               elog(ERROR, "failed to add item to index page in %u/%u/%u", 
-                   data->node.spcNode, data->node.dbNode, data->node.relNode );
-           itup = (IndexTuple)(  ((char*)itup) + MAXALIGN( IndexTupleSize(itup) ) );
+   }
+   else
+   {
+       OffsetNumber i,
+                  *tod;
+       IndexTuple  itup = (IndexTuple) (XLogRecGetData(record) + sizeof(ginxlogVacuumPage));
+
+       tod = (OffsetNumber *) palloc(sizeof(OffsetNumber) * PageGetMaxOffsetNumber(page));
+       for (i = FirstOffsetNumber; i <= PageGetMaxOffsetNumber(page); i++)
+           tod[i - 1] = i;
+
+       PageIndexMultiDelete(page, tod, PageGetMaxOffsetNumber(page));
+
+       for (i = 0; i < data->nitem; i++)
+       {
+           if (PageAddItem(page, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, LP_USED) == InvalidOffsetNumber)
+               elog(ERROR, "failed to add item to index page in %u/%u/%u",
+                 data->node.spcNode, data->node.dbNode, data->node.relNode);
+           itup = (IndexTuple) (((char *) itup) + MAXALIGN(IndexTupleSize(itup)));
        }
    }
 
@@ -344,17 +382,19 @@ ginRedoVacuumPage(XLogRecPtr lsn, XLogRecord *record) {
 }
 
 static void
-ginRedoDeletePage(XLogRecPtr lsn, XLogRecord *record) {
-   ginxlogDeletePage   *data = (ginxlogDeletePage*)XLogRecGetData(record);
+ginRedoDeletePage(XLogRecPtr lsn, XLogRecord *record)
+{
+   ginxlogDeletePage *data = (ginxlogDeletePage *) XLogRecGetData(record);
    Relation    reln;
    Buffer      buffer;
    Page        page;
 
    reln = XLogOpenRelation(data->node);
 
-   if ( !( record->xl_info & XLR_BKP_BLOCK_1) ) {
+   if (!(record->xl_info & XLR_BKP_BLOCK_1))
+   {
        buffer = XLogReadBuffer(reln, data->blkno, false);
-       page = BufferGetPage( buffer );
+       page = BufferGetPage(buffer);
        Assert(GinPageIsData(page));
        GinPageGetOpaque(page)->flags = GIN_DELETED;
        PageSetLSN(page, lsn);
@@ -363,9 +403,10 @@ ginRedoDeletePage(XLogRecPtr lsn, XLogRecord *record) {
        UnlockReleaseBuffer(buffer);
    }
 
-   if ( !( record->xl_info & XLR_BKP_BLOCK_2) ) { 
+   if (!(record->xl_info & XLR_BKP_BLOCK_2))
+   {
        buffer = XLogReadBuffer(reln, data->parentBlkno, false);
-       page = BufferGetPage( buffer );
+       page = BufferGetPage(buffer);
        Assert(GinPageIsData(page));
        Assert(!GinPageIsLeaf(page));
        PageDeletePostingItem(page, data->parentOffset);
@@ -375,9 +416,10 @@ ginRedoDeletePage(XLogRecPtr lsn, XLogRecord *record) {
        UnlockReleaseBuffer(buffer);
    }
 
-   if ( !( record->xl_info & XLR_BKP_BLOCK_2) && data->leftBlkno != InvalidBlockNumber ) { 
+   if (!(record->xl_info & XLR_BKP_BLOCK_2) && data->leftBlkno != InvalidBlockNumber)
+   {
        buffer = XLogReadBuffer(reln, data->leftBlkno, false);
-       page = BufferGetPage( buffer );
+       page = BufferGetPage(buffer);
        Assert(GinPageIsData(page));
        GinPageGetOpaque(page)->rightlink = data->rightLink;
        PageSetLSN(page, lsn);
@@ -387,28 +429,30 @@ ginRedoDeletePage(XLogRecPtr lsn, XLogRecord *record) {
    }
 }
 
-void 
-gin_redo(XLogRecPtr lsn, XLogRecord *record) {
-   uint8       info = record->xl_info & ~XLR_INFO_MASK;
+void
+gin_redo(XLogRecPtr lsn, XLogRecord *record)
+{
+   uint8       info = record->xl_info & ~XLR_INFO_MASK;
 
    topCtx = MemoryContextSwitchTo(opCtx);
-   switch (info) {
-       case    XLOG_GIN_CREATE_INDEX:
+   switch (info)
+   {
+       case XLOG_GIN_CREATE_INDEX:
            ginRedoCreateIndex(lsn, record);
            break;
-       case    XLOG_GIN_CREATE_PTREE:
+       case XLOG_GIN_CREATE_PTREE:
            ginRedoCreatePTree(lsn, record);
            break;
-       case    XLOG_GIN_INSERT:
+       case XLOG_GIN_INSERT:
            ginRedoInsert(lsn, record);
            break;
-       case    XLOG_GIN_SPLIT:
+       case XLOG_GIN_SPLIT:
            ginRedoSplit(lsn, record);
            break;
-       case    XLOG_GIN_VACUUM_PAGE:
+       case XLOG_GIN_VACUUM_PAGE:
            ginRedoVacuumPage(lsn, record);
            break;
-       case    XLOG_GIN_DELETE_PAGE:
+       case XLOG_GIN_DELETE_PAGE:
            ginRedoDeletePage(lsn, record);
            break;
        default:
@@ -419,110 +463,122 @@ gin_redo(XLogRecPtr lsn, XLogRecord *record) {
 }
 
 static void
-desc_node( StringInfo buf, RelFileNode node, BlockNumber blkno ) {
-   appendStringInfo(buf,"node: %u/%u/%u blkno: %u",
-       node.spcNode, node.dbNode, node.relNode, blkno);
+desc_node(StringInfo buf, RelFileNode node, BlockNumber blkno)
+{
+   appendStringInfo(buf, "node: %u/%u/%u blkno: %u",
+                    node.spcNode, node.dbNode, node.relNode, blkno);
 }
 
-void 
-gin_desc(StringInfo buf, uint8 xl_info, char *rec) {
-   uint8       info = xl_info & ~XLR_INFO_MASK;
+void
+gin_desc(StringInfo buf, uint8 xl_info, char *rec)
+{
+   uint8       info = xl_info & ~XLR_INFO_MASK;
 
-   switch (info) {
-       case    XLOG_GIN_CREATE_INDEX:
-           appendStringInfo(buf,"Create index, ");
-           desc_node(buf, *(RelFileNode*)rec, GIN_ROOT_BLKNO );
+   switch (info)
+   {
+       case XLOG_GIN_CREATE_INDEX:
+           appendStringInfo(buf, "Create index, ");
+           desc_node(buf, *(RelFileNode *) rec, GIN_ROOT_BLKNO);
            break;
-       case    XLOG_GIN_CREATE_PTREE:
-           appendStringInfo(buf,"Create posting tree, ");
-           desc_node(buf, ((ginxlogCreatePostingTree*)rec)->node, ((ginxlogCreatePostingTree*)rec)->blkno );
+       case XLOG_GIN_CREATE_PTREE:
+           appendStringInfo(buf, "Create posting tree, ");
+           desc_node(buf, ((ginxlogCreatePostingTree *) rec)->node, ((ginxlogCreatePostingTree *) rec)->blkno);
            break;
-       case    XLOG_GIN_INSERT:
-           appendStringInfo(buf,"Insert item, ");
-           desc_node(buf, ((ginxlogInsert*)rec)->node, ((ginxlogInsert*)rec)->blkno );
-           appendStringInfo(buf," offset: %u nitem: %u isdata: %c isleaf %c isdelete %c updateBlkno:%u",
-               ((ginxlogInsert*)rec)->offset,
-               ((ginxlogInsert*)rec)->nitem,
-               ( ((ginxlogInsert*)rec)->isData ) ? 'T' : 'F',
-               ( ((ginxlogInsert*)rec)->isLeaf ) ? 'T' : 'F',
-               ( ((ginxlogInsert*)rec)->isDelete ) ? 'T' : 'F',
-               ((ginxlogInsert*)rec)->updateBlkno
-           );
+       case XLOG_GIN_INSERT:
+           appendStringInfo(buf, "Insert item, ");
+           desc_node(buf, ((ginxlogInsert *) rec)->node, ((ginxlogInsert *) rec)->blkno);
+           appendStringInfo(buf, " offset: %u nitem: %u isdata: %c isleaf %c isdelete %c updateBlkno:%u",
+                            ((ginxlogInsert *) rec)->offset,
+                            ((ginxlogInsert *) rec)->nitem,
+                            (((ginxlogInsert *) rec)->isData) ? 'T' : 'F',
+                            (((ginxlogInsert *) rec)->isLeaf) ? 'T' : 'F',
+                            (((ginxlogInsert *) rec)->isDelete) ? 'T' : 'F',
+                            ((ginxlogInsert *) rec)->updateBlkno
+               );
 
            break;
-       case    XLOG_GIN_SPLIT:
-           appendStringInfo(buf,"Page split, ");
-           desc_node(buf, ((ginxlogSplit*)rec)->node, ((ginxlogSplit*)rec)->lblkno );
-           appendStringInfo(buf," isrootsplit: %c", ( ((ginxlogSplit*)rec)->isRootSplit ) ? 'T' : 'F');
+       case XLOG_GIN_SPLIT:
+           appendStringInfo(buf, "Page split, ");
+           desc_node(buf, ((ginxlogSplit *) rec)->node, ((ginxlogSplit *) rec)->lblkno);
+           appendStringInfo(buf, " isrootsplit: %c", (((ginxlogSplit *) rec)->isRootSplit) ? 'T' : 'F');
            break;
-       case    XLOG_GIN_VACUUM_PAGE:
-           appendStringInfo(buf,"Vacuum page, ");
-           desc_node(buf, ((ginxlogVacuumPage*)rec)->node, ((ginxlogVacuumPage*)rec)->blkno );
+       case XLOG_GIN_VACUUM_PAGE:
+           appendStringInfo(buf, "Vacuum page, ");
+           desc_node(buf, ((ginxlogVacuumPage *) rec)->node, ((ginxlogVacuumPage *) rec)->blkno);
            break;
-       case    XLOG_GIN_DELETE_PAGE:
-           appendStringInfo(buf,"Delete page, ");
-           desc_node(buf, ((ginxlogDeletePage*)rec)->node, ((ginxlogDeletePage*)rec)->blkno );
+       case XLOG_GIN_DELETE_PAGE:
+           appendStringInfo(buf, "Delete page, ");
+           desc_node(buf, ((ginxlogDeletePage *) rec)->node, ((ginxlogDeletePage *) rec)->blkno);
            break;
        default:
            elog(PANIC, "gin_desc: unknown op code %u", info);
    }
 }
 
-void 
-gin_xlog_startup(void) {
+void
+gin_xlog_startup(void)
+{
    incomplete_splits = NIL;
 
    opCtx = AllocSetContextCreate(CurrentMemoryContext,
-       "GIN recovery temporary context",
-       ALLOCSET_DEFAULT_MINSIZE,
-       ALLOCSET_DEFAULT_INITSIZE,
-       ALLOCSET_DEFAULT_MAXSIZE);
+                                 "GIN recovery temporary context",
+                                 ALLOCSET_DEFAULT_MINSIZE,
+                                 ALLOCSET_DEFAULT_INITSIZE,
+                                 ALLOCSET_DEFAULT_MAXSIZE);
 }
 
 static void
-ginContinueSplit( ginIncompleteSplit *split ) {
+ginContinueSplit(ginIncompleteSplit *split)
+{
    GinBtreeData btree;
    Relation    reln;
    Buffer      buffer;
-   GinBtreeStack   stack;
+   GinBtreeStack stack;
 
-   /* elog(NOTICE,"ginContinueSplit root:%u l:%u r:%u",  split->rootBlkno, split->leftBlkno, split->rightBlkno); */
+   /*
+    * elog(NOTICE,"ginContinueSplit root:%u l:%u r:%u",  split->rootBlkno,
+    * split->leftBlkno, split->rightBlkno);
+    */
    reln = XLogOpenRelation(split->node);
 
-   buffer =  XLogReadBuffer(reln, split->leftBlkno, false);
+   buffer = XLogReadBuffer(reln, split->leftBlkno, false);
 
-   if ( split->rootBlkno == GIN_ROOT_BLKNO ) {
-       prepareEntryScan( &btree, reln, (Datum)0, NULL );
-       btree.entry = ginPageGetLinkItup( buffer );
-   } else {
-       Page        page = BufferGetPage( buffer );
+   if (split->rootBlkno == GIN_ROOT_BLKNO)
+   {
+       prepareEntryScan(&btree, reln, (Datum) 0, NULL);
+       btree.entry = ginPageGetLinkItup(buffer);
+   }
+   else
+   {
+       Page        page = BufferGetPage(buffer);
 
-       prepareDataScan( &btree, reln );
+       prepareDataScan(&btree, reln);
 
-       PostingItemSetBlockNumber( &(btree.pitem), split->leftBlkno );
-       if ( GinPageIsLeaf(page) )
-           btree.pitem.key = *(ItemPointerData*)GinDataPageGetItem(page,
-               GinPageGetOpaque(page)->maxoff);
+       PostingItemSetBlockNumber(&(btree.pitem), split->leftBlkno);
+       if (GinPageIsLeaf(page))
+           btree.pitem.key = *(ItemPointerData *) GinDataPageGetItem(page,
+                                            GinPageGetOpaque(page)->maxoff);
        else
-           btree.pitem.key = ((PostingItem*)GinDataPageGetItem(page,
-               GinPageGetOpaque(page)->maxoff))->key;
+           btree.pitem.key = ((PostingItem *) GinDataPageGetItem(page,
+                                      GinPageGetOpaque(page)->maxoff))->key;
    }
 
-   btree.rightblkno = split->rightBlkno; 
+   btree.rightblkno = split->rightBlkno;
 
    stack.blkno = split->leftBlkno;
    stack.buffer = buffer;
    stack.off = InvalidOffsetNumber;
    stack.parent = NULL;
 
-   findParents( &btree, &stack, split->rootBlkno);
-   ginInsertValue( &btree, stack.parent );
+   findParents(&btree, &stack, split->rootBlkno);
+   ginInsertValue(&btree, stack.parent);
 
-   UnlockReleaseBuffer( buffer );
+   UnlockReleaseBuffer(buffer);
 }
 
-void 
-gin_xlog_cleanup(void) {
+void
+gin_xlog_cleanup(void)
+{
    ListCell   *l;
    MemoryContext topCtx;
 
@@ -531,8 +587,9 @@ gin_xlog_cleanup(void) {
    foreach(l, incomplete_splits)
    {
        ginIncompleteSplit *split = (ginIncompleteSplit *) lfirst(l);
-       ginContinueSplit( split );
-       MemoryContextReset( opCtx );
+
+       ginContinueSplit(split);
+       MemoryContextReset(opCtx);
    }
 
    MemoryContextSwitchTo(topCtx);
index 7b0c0f6b3873d7b6ae669f762eef5f1af7c6cf41..60d0affbfcfdc547d09f54b0bdc47588679c4d34 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.142 2006/07/14 14:52:16 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.143 2006/10/04 00:29:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -185,7 +185,7 @@ gistbuildCallback(Relation index,
 
    /* form an index tuple and point it at the heap tuple */
    itup = gistFormTuple(&buildstate->giststate, index,
-       values, isnull, true /* size is currently bogus */);
+                        values, isnull, true /* size is currently bogus */ );
    itup->t_tid = htup->t_self;
 
    /*
@@ -199,7 +199,7 @@ gistbuildCallback(Relation index,
     * after initial build do not.
     */
    gistdoinsert(index, itup,
-                RelationGetTargetPageFreeSpace(index, GIST_DEFAULT_FILLFACTOR),
+             RelationGetTargetPageFreeSpace(index, GIST_DEFAULT_FILLFACTOR),
                 &buildstate->giststate);
 
    buildstate->indtuples += 1;
@@ -236,7 +236,7 @@ gistinsert(PG_FUNCTION_ARGS)
    initGISTstate(&giststate, r);
 
    itup = gistFormTuple(&giststate, r,
-       values, isnull, true /* size is currently bogus */);
+                        values, isnull, true /* size is currently bogus */ );
    itup->t_tid = *ht_ctid;
 
    gistdoinsert(r, itup, 0, &giststate);
@@ -285,18 +285,17 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
    bool        is_leaf = (GistPageIsLeaf(state->stack->page)) ? true : false;
 
    /*
-    * if (!is_leaf) remove old key:
-    * This node's key has been modified, either because a child split
-    * occurred or because we needed to adjust our key for an insert in a
-    * child node. Therefore, remove the old version of this node's key.
+    * if (!is_leaf) remove old key: This node's key has been modified, either
+    * because a child split occurred or because we needed to adjust our key
+    * for an insert in a child node. Therefore, remove the old version of
+    * this node's key.
     *
-    * for WAL replay, in the non-split case we handle this by
-    * setting up a one-element todelete array; in the split case, it's
-    * handled implicitly because the tuple vector passed to gistSplit
-    * won't include this tuple.
+    * for WAL replay, in the non-split case we handle this by setting up a
+    * one-element todelete array; in the split case, it's handled implicitly
+    * because the tuple vector passed to gistSplit won't include this tuple.
     *
-    * XXX: If we want to change fillfactors between node and leaf,
-    * fillfactor = (is_leaf ? state->leaf_fillfactor : state->node_fillfactor)
+    * XXX: If we want to change fillfactors between node and leaf, fillfactor
+    * = (is_leaf ? state->leaf_fillfactor : state->node_fillfactor)
     */
    if (gistnospace(state->stack->page, state->itup, state->ituplen,
                    is_leaf ? InvalidOffsetNumber : state->stack->childoffnum,
@@ -307,80 +306,88 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
        int         tlen;
        SplitedPageLayout *dist = NULL,
                   *ptr;
-       BlockNumber rrlink = InvalidBlockNumber;
+       BlockNumber rrlink = InvalidBlockNumber;
        GistNSN     oldnsn;
 
        is_splitted = true;
 
        /*
-        * Form index tuples vector to split:
-        * remove old tuple if t's needed and add new tuples to vector
+        * Form index tuples vector to split: remove old tuple if t's needed
+        * and add new tuples to vector
         */
        itvec = gistextractpage(state->stack->page, &tlen);
-       if ( !is_leaf ) {
+       if (!is_leaf)
+       {
            /* on inner page we should remove old tuple */
-           int pos = state->stack->childoffnum - FirstOffsetNumber;
+           int         pos = state->stack->childoffnum - FirstOffsetNumber;
 
-           tlen--; 
-           if ( pos != tlen ) 
-               memmove( itvec+pos, itvec + pos + 1, sizeof( IndexTuple ) * (tlen-pos) );
+           tlen--;
+           if (pos != tlen)
+               memmove(itvec + pos, itvec + pos + 1, sizeof(IndexTuple) * (tlen - pos));
        }
        itvec = gistjoinvector(itvec, &tlen, state->itup, state->ituplen);
        dist = gistSplit(state->r, state->stack->page, itvec, tlen, giststate);
 
-       state->itup = (IndexTuple*)palloc( sizeof(IndexTuple) * tlen);
+       state->itup = (IndexTuple *) palloc(sizeof(IndexTuple) * tlen);
        state->ituplen = 0;
 
-       if (state->stack->blkno != GIST_ROOT_BLKNO) {
-           /* if non-root split then we should not allocate new buffer,
-              but we must create temporary page to operate */ 
+       if (state->stack->blkno != GIST_ROOT_BLKNO)
+       {
+           /*
+            * if non-root split then we should not allocate new buffer, but
+            * we must create temporary page to operate
+            */
            dist->buffer = state->stack->buffer;
-           dist->page = PageGetTempPage( BufferGetPage(dist->buffer), sizeof(GISTPageOpaqueData) );
+           dist->page = PageGetTempPage(BufferGetPage(dist->buffer), sizeof(GISTPageOpaqueData));
 
-           /*clean all flags except F_LEAF */ 
+           /* clean all flags except F_LEAF */
            GistPageGetOpaque(dist->page)->flags = (is_leaf) ? F_LEAF : 0;
        }
 
        /* make new pages and fills them */
-       for (ptr = dist; ptr; ptr = ptr->next) {
-           int i;
-           char *data;
+       for (ptr = dist; ptr; ptr = ptr->next)
+       {
+           int         i;
+           char       *data;
 
            /* get new page */
-           if ( ptr->buffer == InvalidBuffer ) {
-               ptr->buffer = gistNewBuffer( state->r );
-               GISTInitBuffer( ptr->buffer, (is_leaf) ? F_LEAF : 0 );
+           if (ptr->buffer == InvalidBuffer)
+           {
+               ptr->buffer = gistNewBuffer(state->r);
+               GISTInitBuffer(ptr->buffer, (is_leaf) ? F_LEAF : 0);
                ptr->page = BufferGetPage(ptr->buffer);
            }
-           ptr->block.blkno = BufferGetBlockNumber( ptr->buffer );
+           ptr->block.blkno = BufferGetBlockNumber(ptr->buffer);
 
-           /* fill page, we can do it becouse all this pages are new (ie not linked in tree
-              or masked by temp page */
-           data = (char*)(ptr->list); 
-           for(i=0;iblock.num;i++) {
-               if ( PageAddItem(ptr->page, (Item)data, IndexTupleSize((IndexTuple)data), i+FirstOffsetNumber, LP_USED) == InvalidOffsetNumber )
+           /*
+            * fill page, we can do it becouse all this pages are new (ie not
+            * linked in tree or masked by temp page
+            */
+           data = (char *) (ptr->list);
+           for (i = 0; i < ptr->block.num; i++)
+           {
+               if (PageAddItem(ptr->page, (Item) data, IndexTupleSize((IndexTuple) data), i + FirstOffsetNumber, LP_USED) == InvalidOffsetNumber)
                    elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(state->r));
-               data += IndexTupleSize((IndexTuple)data);
+               data += IndexTupleSize((IndexTuple) data);
            }
 
            /* set up ItemPointer and remmeber it for parent */
            ItemPointerSetBlockNumber(&(ptr->itup->t_tid), ptr->block.blkno);
-           state->itup[ state->ituplen ] = ptr->itup;
+           state->itup[state->ituplen] = ptr->itup;
            state->ituplen++;
        }
 
        /* saves old rightlink */
-       if ( state->stack->blkno != GIST_ROOT_BLKNO )
-           rrlink =  GistPageGetOpaque(dist->page)->rightlink;
+       if (state->stack->blkno != GIST_ROOT_BLKNO)
+           rrlink = GistPageGetOpaque(dist->page)->rightlink;
 
        START_CRIT_SECTION();
 
        /*
-        * must mark buffers dirty before XLogInsert, even though we'll
-        * still be changing their opaque fields below.
-        * set up right links.
+        * must mark buffers dirty before XLogInsert, even though we'll still
+        * be changing their opaque fields below. set up right links.
         */
-       for (ptr = dist; ptr; ptr = ptr->next) 
+       for (ptr = dist; ptr; ptr = ptr->next)
        {
            MarkBufferDirty(ptr->buffer);
            GistPageGetOpaque(ptr->page)->rightlink = (ptr->next) ?
@@ -388,9 +395,10 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
        }
 
        /* restore splitted non-root page */
-       if ( state->stack->blkno != GIST_ROOT_BLKNO ) {
-           PageRestoreTempPage( dist->page, BufferGetPage( dist->buffer ) );
-           dist->page = BufferGetPage( dist->buffer );
+       if (state->stack->blkno != GIST_ROOT_BLKNO)
+       {
+           PageRestoreTempPage(dist->page, BufferGetPage(dist->buffer));
+           dist->page = BufferGetPage(dist->buffer);
        }
 
        if (!state->r->rd_istemp)
@@ -419,25 +427,27 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
 
        /* set up NSN */
        oldnsn = GistPageGetOpaque(dist->page)->nsn;
-       if ( state->stack->blkno == GIST_ROOT_BLKNO )
+       if (state->stack->blkno == GIST_ROOT_BLKNO)
            /* if root split we should put initial value */
            oldnsn = PageGetLSN(dist->page);
 
-       for (ptr = dist; ptr; ptr = ptr->next) {
+       for (ptr = dist; ptr; ptr = ptr->next)
+       {
            /* only for last set oldnsn */
            GistPageGetOpaque(ptr->page)->nsn = (ptr->next) ?
                PageGetLSN(ptr->page) : oldnsn;
        }
 
-       /* 
-        * release buffers, if it was a root split then
-        * release all buffers because we create all buffers 
+       /*
+        * release buffers, if it was a root split then release all buffers
+        * because we create all buffers
         */
-       ptr = ( state->stack->blkno == GIST_ROOT_BLKNO ) ? dist : dist->next;
-       for(; ptr; ptr = ptr->next)
+       ptr = (state->stack->blkno == GIST_ROOT_BLKNO) ? dist : dist->next;
+       for (; ptr; ptr = ptr->next)
            UnlockReleaseBuffer(ptr->buffer);
 
-       if (state->stack->blkno == GIST_ROOT_BLKNO) {
+       if (state->stack->blkno == GIST_ROOT_BLKNO)
+       {
            gistnewroot(state->r, state->stack->buffer, state->itup, state->ituplen, &(state->key));
            state->needInsertComplete = false;
        }
@@ -470,7 +480,7 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate)
            }
 
            rdata = formUpdateRdata(state->r->rd_node, state->stack->buffer,
-                                   offs, noffs, 
+                                   offs, noffs,
                                    state->itup, state->ituplen,
                                    &(state->key));
 
@@ -922,16 +932,16 @@ gistSplit(Relation r,
    GistSplitVector v;
    GistEntryVector *entryvec;
    int         i;
-   SplitedPageLayout   *res = NULL;
+   SplitedPageLayout *res = NULL;
 
    /* generate the item array */
    entryvec = palloc(GEVHDRSZ + (len + 1) * sizeof(GISTENTRY));
    entryvec->n = len + 1;
 
-   memset( v.spl_lisnull, TRUE, sizeof(bool) * giststate->tupdesc->natts ); 
-   memset( v.spl_risnull, TRUE, sizeof(bool) * giststate->tupdesc->natts ); 
-   gistSplitByKey(r, page, itup, len, giststate, 
-       &v, entryvec, 0);
+   memset(v.spl_lisnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
+   memset(v.spl_risnull, TRUE, sizeof(bool) * giststate->tupdesc->natts);
+   gistSplitByKey(r, page, itup, len, giststate,
+                  &v, entryvec, 0);
 
    /* form left and right vector */
    lvectup = (IndexTuple *) palloc(sizeof(IndexTuple) * (len + 1));
@@ -952,19 +962,20 @@ gistSplit(Relation r,
    {
        ROTATEDIST(res);
        res->block.num = v.splitVector.spl_nright;
-       res->list = gistfillitupvec(rvectup, v.splitVector.spl_nright, &( res->lenlist ) );
+       res->list = gistfillitupvec(rvectup, v.splitVector.spl_nright, &(res->lenlist));
        res->itup = (v.spl_rightvalid) ? gistFormTuple(giststate, r, v.spl_rattr, v.spl_risnull, false)
            : gist_form_invalid_tuple(GIST_ROOT_BLKNO);
    }
 
    if (!gistfitpage(lvectup, v.splitVector.spl_nleft))
    {
-       SplitedPageLayout *resptr, *subres;
+       SplitedPageLayout *resptr,
+                  *subres;
 
        resptr = subres = gistSplit(r, page, lvectup, v.splitVector.spl_nleft, giststate);
 
-       /* install on list's tail */ 
-       while( resptr->next )
+       /* install on list's tail */
+       while (resptr->next)
            resptr = resptr->next;
 
        resptr->next = res;
@@ -974,7 +985,7 @@ gistSplit(Relation r,
    {
        ROTATEDIST(res);
        res->block.num = v.splitVector.spl_nleft;
-       res->list = gistfillitupvec(lvectup, v.splitVector.spl_nleft, &( res->lenlist ) );
+       res->list = gistfillitupvec(lvectup, v.splitVector.spl_nleft, &(res->lenlist));
        res->itup = (v.spl_leftvalid) ? gistFormTuple(giststate, r, v.spl_lattr, v.spl_lisnull, false)
            : gist_form_invalid_tuple(GIST_ROOT_BLKNO);
    }
index ed41f2c335ec255f47f250c9069ea92ae20c11f4..68a4c18bb87a210bfcae32c5e08aee0f7d4e1886 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.60 2006/07/14 14:52:16 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.61 2006/10/04 00:29:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -360,8 +360,7 @@ gistindex_keytest(IndexTuple tuple,
    IncrIndexProcessed();
 
    /*
-    * Tuple doesn't restore after crash recovery because of incomplete
-    * insert
+    * Tuple doesn't restore after crash recovery because of incomplete insert
     */
    if (!GistPageIsLeaf(p) && GistTupleIsInvalid(tuple))
        return true;
@@ -378,14 +377,18 @@ gistindex_keytest(IndexTuple tuple,
                              giststate->tupdesc,
                              &isNull);
 
-       if ( key->sk_flags & SK_ISNULL ) {
-           /* is the compared-to datum NULL? on non-leaf page it's possible
-              to have nulls in childs :( */
+       if (key->sk_flags & SK_ISNULL)
+       {
+           /*
+            * is the compared-to datum NULL? on non-leaf page it's possible
+            * to have nulls in childs :(
+            */
 
-           if ( isNull || !GistPageIsLeaf(p) )
+           if (isNull || !GistPageIsLeaf(p))
                return true;
            return false;
-       } else if ( isNull )
+       }
+       else if (isNull)
            return false;
 
        gistdentryinit(giststate, key->sk_attno - 1, &de,
index ccd54bac12073736f7e271a45cbce21cd52632fe..5c021461eec90cd08b895502aaf316e3b0358a6b 100644 (file)
@@ -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.8 2006/09/10 00:29:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistproc.c,v 1.9 2006/10/04 00:29:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -112,7 +112,8 @@ gist_box_consistent(PG_FUNCTION_ARGS)
 }
 
 static void
-adjustBox( BOX *b, BOX *addon ) {
+adjustBox(BOX *b, BOX *addon)
+{
    if (b->high.x < addon->high.x)
        b->high.x = addon->high.x;
    if (b->low.x > addon->low.x)
@@ -146,7 +147,7 @@ gist_box_union(PG_FUNCTION_ARGS)
    for (i = 1; i < numranges; i++)
    {
        cur = DatumGetBoxP(entryvec->vector[i].key);
-       adjustBox( pageunion, cur );
+       adjustBox(pageunion, cur);
    }
    *sizep = sizeof(BOX);
 
@@ -210,67 +211,79 @@ compare_KB(const void *a, const void *b)
 }
 
 static void
-chooseLR( GIST_SPLITVEC *v, 
-   OffsetNumber *list1, int nlist1, BOX *union1, 
-   OffsetNumber *list2, int nlist2, BOX *union2 )
+chooseLR(GIST_SPLITVEC *v,
+        OffsetNumber *list1, int nlist1, BOX *union1,
+        OffsetNumber *list2, int nlist2, BOX *union2)
 {
-   bool    firstToLeft = true;
-
-   if ( v->spl_ldatum_exists || v->spl_rdatum_exists ) {
-       if (  v->spl_ldatum_exists && v->spl_rdatum_exists ) {
-           BOX LRl = *union1, LRr = *union2; 
-           BOX RLl = *union2, RLr = *union1;
-           double sizeLR, sizeRL;
-
-           adjustBox( &LRl, DatumGetBoxP( v->spl_ldatum ) );
-           adjustBox( &LRr, DatumGetBoxP( v->spl_rdatum ) );
-           adjustBox( &RLl, DatumGetBoxP( v->spl_ldatum ) );
-           adjustBox( &RLr, DatumGetBoxP( v->spl_rdatum ) );
-
-           sizeLR = size_box( DirectFunctionCall2(rt_box_inter, BoxPGetDatum(&LRl), BoxPGetDatum(&LRr)) );
-           sizeRL = size_box( DirectFunctionCall2(rt_box_inter, BoxPGetDatum(&RLl), BoxPGetDatum(&RLr)) );
+   bool        firstToLeft = true;
 
-           if ( sizeLR > sizeRL ) 
+   if (v->spl_ldatum_exists || v->spl_rdatum_exists)
+   {
+       if (v->spl_ldatum_exists && v->spl_rdatum_exists)
+       {
+           BOX         LRl = *union1,
+                       LRr = *union2;
+           BOX         RLl = *union2,
+                       RLr = *union1;
+           double      sizeLR,
+                       sizeRL;
+
+           adjustBox(&LRl, DatumGetBoxP(v->spl_ldatum));
+           adjustBox(&LRr, DatumGetBoxP(v->spl_rdatum));
+           adjustBox(&RLl, DatumGetBoxP(v->spl_ldatum));
+           adjustBox(&RLr, DatumGetBoxP(v->spl_rdatum));
+
+           sizeLR = size_box(DirectFunctionCall2(rt_box_inter, BoxPGetDatum(&LRl), BoxPGetDatum(&LRr)));
+           sizeRL = size_box(DirectFunctionCall2(rt_box_inter, BoxPGetDatum(&RLl), BoxPGetDatum(&RLr)));
+
+           if (sizeLR > sizeRL)
                firstToLeft = false;
 
-       } else {
-           float p1, p2;
-           GISTENTRY   oldUnion, addon;
+       }
+       else
+       {
+           float       p1,
+                       p2;
+           GISTENTRY   oldUnion,
+                       addon;
 
-           gistentryinit(oldUnion, ( v->spl_ldatum_exists ) ? v->spl_ldatum : v->spl_rdatum,
+           gistentryinit(oldUnion, (v->spl_ldatum_exists) ? v->spl_ldatum : v->spl_rdatum,
                          NULL, NULL, InvalidOffsetNumber, FALSE);
-       
+
            gistentryinit(addon, BoxPGetDatum(union1), NULL, NULL, InvalidOffsetNumber, FALSE);
-           DirectFunctionCall3(gist_box_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&union1), PointerGetDatum(&p1)); 
+           DirectFunctionCall3(gist_box_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&union1), PointerGetDatum(&p1));
            gistentryinit(addon, BoxPGetDatum(union2), NULL, NULL, InvalidOffsetNumber, FALSE);
            DirectFunctionCall3(gist_box_penalty, PointerGetDatum(&oldUnion), PointerGetDatum(&union2), PointerGetDatum(&p2));
 
-           if (  (v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2)  ) 
-               firstToLeft = false;    
+           if ((v->spl_ldatum_exists && p1 > p2) || (v->spl_rdatum_exists && p1 < p2))
+               firstToLeft = false;
        }
    }
 
-   if ( firstToLeft ) {    
+   if (firstToLeft)
+   {
        v->spl_left = list1;
        v->spl_right = list2;
        v->spl_nleft = nlist1;
        v->spl_nright = nlist2;
-       if ( v->spl_ldatum_exists )
-           adjustBox(union1, DatumGetBoxP( v->spl_ldatum ) );
+       if (v->spl_ldatum_exists)
+           adjustBox(union1, DatumGetBoxP(v->spl_ldatum));
        v->spl_ldatum = BoxPGetDatum(union1);
-       if ( v->spl_rdatum_exists )
-           adjustBox(union2, DatumGetBoxP( v->spl_rdatum ) );
+       if (v->spl_rdatum_exists)
+           adjustBox(union2, DatumGetBoxP(v->spl_rdatum));
        v->spl_rdatum = BoxPGetDatum(union2);
-   } else {
+   }
+   else
+   {
        v->spl_left = list2;
        v->spl_right = list1;
        v->spl_nleft = nlist2;
        v->spl_nright = nlist1;
-       if ( v->spl_ldatum_exists )
-           adjustBox(union2, DatumGetBoxP( v->spl_ldatum ) );
+       if (v->spl_ldatum_exists)
+           adjustBox(union2, DatumGetBoxP(v->spl_ldatum));
        v->spl_ldatum = BoxPGetDatum(union2);
-       if ( v->spl_rdatum_exists )
-           adjustBox(union1, DatumGetBoxP( v->spl_rdatum ) );
+       if (v->spl_rdatum_exists)
+           adjustBox(union1, DatumGetBoxP(v->spl_rdatum));
        v->spl_rdatum = BoxPGetDatum(union1);
    }
 
@@ -326,7 +339,7 @@ gist_box_picksplit(PG_FUNCTION_ARGS)
                                   ))
            allisequal = false;
 
-       adjustBox( &pageunion, cur );
+       adjustBox(&pageunion, cur);
    }
 
    nbytes = (maxoff + 2) * sizeof(OffsetNumber);
@@ -359,12 +372,12 @@ gist_box_picksplit(PG_FUNCTION_ARGS)
                }
            }
 
-           if ( v->spl_ldatum_exists ) 
-               adjustBox( unionL, DatumGetBoxP( v->spl_ldatum ) );
+           if (v->spl_ldatum_exists)
+               adjustBox(unionL, DatumGetBoxP(v->spl_ldatum));
            v->spl_ldatum = BoxPGetDatum(unionL);
 
-           if ( v->spl_rdatum_exists ) 
-               adjustBox( unionR, DatumGetBoxP( v->spl_rdatum ) );
+           if (v->spl_rdatum_exists)
+               adjustBox(unionR, DatumGetBoxP(v->spl_rdatum));
            v->spl_rdatum = BoxPGetDatum(unionR);
 
            v->spl_ldatum_exists = v->spl_rdatum_exists = false;
@@ -471,13 +484,13 @@ gist_box_picksplit(PG_FUNCTION_ARGS)
    }
 
    if (direction == 'x')
-       chooseLR( v,
-                   listL, posL, unionL,
-                   listR, posR, unionR );
-   else 
-       chooseLR( v,
-                   listB, posB, unionB,
-                   listT, posT, unionT );
+       chooseLR(v,
+                listL, posL, unionL,
+                listR, posR, unionR);
+   else
+       chooseLR(v,
+                listB, posB, unionB,
+                listT, posT, unionT);
 
    PG_RETURN_POINTER(v);
 }
index 0d3c1d2a9a9c75af4ab7c9e7583093d29480f8a8..b0fdb74004790ccaf97b0c200f2b26fc990e6fef 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.64 2006/07/14 14:52:16 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.65 2006/10/04 00:29:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -228,12 +228,12 @@ gistendscan(PG_FUNCTION_ARGS)
 
 static void
 gistfreestack(GISTSearchStack *s)
-{  
+{
    while (s != NULL)
    {
        GISTSearchStack *p = s->next;
+
        pfree(s);
        s = p;
    }
 }
-
index 8c6683a4cc7e122ef12a3bf6c814c8aa61e2473c..14a14509cbb825eab670a3c213b277e5b7016b1e 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/gist/gistsplit.c,v 1.2 2006/07/14 14:52:16 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/gist/gistsplit.c,v 1.3 2006/10/04 00:29:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "access/gist_private.h"
 
-typedef struct {
-    Datum   *attr;
-   int     len;
+typedef struct
+{
+   Datum      *attr;
+   int         len;
    OffsetNumber *entries;
-   bool    *isnull;
-   bool        *equiv;
+   bool       *isnull;
+   bool       *equiv;
 } GistSplitUnion;
 
 
@@ -29,25 +30,28 @@ typedef struct {
  * Forms unions of subkeys after page split, but
  * uses only tuples aren't in groups of equalent tuples
  */
-static void 
-gistunionsubkeyvec(GISTSTATE *giststate,  IndexTuple *itvec, 
-                           GistSplitUnion *gsvp, int startkey) {
-   IndexTuple  *cleanedItVec;
-   int         i, cleanedLen=0;
+static void
+gistunionsubkeyvec(GISTSTATE *giststate, IndexTuple *itvec,
+                  GistSplitUnion *gsvp, int startkey)
+{
+   IndexTuple *cleanedItVec;
+   int         i,
+               cleanedLen = 0;
 
-   cleanedItVec = (IndexTuple*)palloc(sizeof(IndexTuple) * gsvp->len);
+   cleanedItVec = (IndexTuple *) palloc(sizeof(IndexTuple) * gsvp->len);
 
-   for(i=0;ilen;i++) {
-       if ( gsvp->equiv && gsvp->equiv[gsvp->entries[i]])
+   for (i = 0; i < gsvp->len; i++)
+   {
+       if (gsvp->equiv && gsvp->equiv[gsvp->entries[i]])
            continue;
 
        cleanedItVec[cleanedLen++] = itvec[gsvp->entries[i] - 1];
    }
 
-    gistMakeUnionItVec(giststate, cleanedItVec, cleanedLen, startkey, 
-       gsvp->attr, gsvp->isnull);
+   gistMakeUnionItVec(giststate, cleanedItVec, cleanedLen, startkey,
+                      gsvp->attr, gsvp->isnull);
 
-   pfree( cleanedItVec );
+   pfree(cleanedItVec);
 }
 
 /*
@@ -56,7 +60,7 @@ gistunionsubkeyvec(GISTSTATE *giststate,  IndexTuple *itvec,
 static void
 gistunionsubkey(GISTSTATE *giststate, IndexTuple *itvec, GistSplitVector *spl, int attno)
 {
-   GistSplitUnion  gsvp;
+   GistSplitUnion gsvp;
 
    gsvp.equiv = spl->spl_equiv;
 
@@ -76,34 +80,40 @@ gistunionsubkey(GISTSTATE *giststate, IndexTuple *itvec, GistSplitVector *spl, i
 }
 
 /*
- * find group in vector with equivalent value 
+ * find group in vector with equivalent value
  */
 static int
 gistfindgroup(Relation r, GISTSTATE *giststate, GISTENTRY *valvec, GistSplitVector *spl, int attno)
 {
    int         i;
    GISTENTRY   entry;
-   int len=0;
+   int         len = 0;
 
    /*
-    * attno key is always not null (see gistSplitByKey), so we may not check for
-    * nulls
+    * attno key is always not null (see gistSplitByKey), so we may not check
+    * for nulls
     */
    gistentryinit(entry, spl->splitVector.spl_rdatum, r, NULL, (OffsetNumber) 0, FALSE);
-   for (i = 0; i < spl->splitVector.spl_nleft; i++) {
-       float penalty = gistpenalty(giststate, attno, &entry, false,
-                                   &valvec[spl->splitVector.spl_left[i]], false);
-       if ( penalty == 0.0 ) {
+   for (i = 0; i < spl->splitVector.spl_nleft; i++)
+   {
+       float       penalty = gistpenalty(giststate, attno, &entry, false,
+                              &valvec[spl->splitVector.spl_left[i]], false);
+
+       if (penalty == 0.0)
+       {
            spl->spl_equiv[spl->splitVector.spl_left[i]] = true;
            len++;
        }
    }
 
    gistentryinit(entry, spl->splitVector.spl_ldatum, r, NULL, (OffsetNumber) 0, FALSE);
-   for (i = 0; i < spl->splitVector.spl_nright; i++) {
-       float penalty = gistpenalty(giststate, attno, &entry, false,
-                                   &valvec[spl->splitVector.spl_right[i]], false);
-       if ( penalty == 0.0 ) {
+   for (i = 0; i < spl->splitVector.spl_nright; i++)
+   {
+       float       penalty = gistpenalty(giststate, attno, &entry, false,
+                             &valvec[spl->splitVector.spl_right[i]], false);
+
+       if (penalty == 0.0)
+       {
            spl->spl_equiv[spl->splitVector.spl_right[i]] = true;
            len++;
        }
@@ -113,24 +123,32 @@ gistfindgroup(Relation r, GISTSTATE *giststate, GISTENTRY *valvec, GistSplitVect
 }
 
 static void
-cleanupOffsets( OffsetNumber *a, int *len, bool *equiv, int *LenEquiv ) {
-   int curlen,i;
-   OffsetNumber    *curwpos;
+cleanupOffsets(OffsetNumber *a, int *len, bool *equiv, int *LenEquiv)
+{
+   int         curlen,
+               i;
+   OffsetNumber *curwpos;
 
    curlen = *len;
    curwpos = a;
-   for (i = 0; i < *len; i++) {
-       if ( equiv[ a[i] ] == FALSE ) {
+   for (i = 0; i < *len; i++)
+   {
+       if (equiv[a[i]] == FALSE)
+       {
            *curwpos = a[i];
            curwpos++;
-       } else {
+       }
+       else
+       {
            /* corner case: we shouldn't make void array */
-           if ( curlen==1 ) {
-               equiv[ a[i] ] = FALSE; /* mark item as non-equivalent */
-               i--; /* redo the same */
+           if (curlen == 1)
+           {
+               equiv[a[i]] = FALSE;    /* mark item as non-equivalent */
+               i--;            /* redo the same */
                *LenEquiv -= 1;
                continue;
-           } else
+           }
+           else
                curlen--;
        }
    }
@@ -139,33 +157,37 @@ cleanupOffsets( OffsetNumber *a, int *len, bool *equiv, int *LenEquiv ) {
 }
 
 static void
-placeOne( Relation r, GISTSTATE *giststate, GistSplitVector *v, IndexTuple itup, OffsetNumber off, int attno ) {
+placeOne(Relation r, GISTSTATE *giststate, GistSplitVector *v, IndexTuple itup, OffsetNumber off, int attno)
+{
    GISTENTRY   identry[INDEX_MAX_KEYS];
    bool        isnull[INDEX_MAX_KEYS];
-   bool    toLeft = true;
+   bool        toLeft = true;
 
    gistDeCompressAtt(giststate, r, itup, NULL, (OffsetNumber) 0, identry, isnull);
 
-   for(;attnotupdesc->natts;attno++) {
-       float lpenalty, rpenalty;
+   for (; attno < giststate->tupdesc->natts; attno++)
+   {
+       float       lpenalty,
+                   rpenalty;
        GISTENTRY   entry;
 
-       gistentryinit(entry, v->spl_lattr[attno], r, NULL, 0,  FALSE);
-       lpenalty = gistpenalty(giststate, attno, &entry, v->spl_lisnull[attno], identry+attno, isnull[ attno ]); 
-       gistentryinit(entry, v->spl_rattr[attno], r, NULL, 0,  FALSE);
-       rpenalty = gistpenalty(giststate, attno, &entry, v->spl_risnull[attno], identry+attno, isnull[ attno ]);
+       gistentryinit(entry, v->spl_lattr[attno], r, NULL, 0, FALSE);
+       lpenalty = gistpenalty(giststate, attno, &entry, v->spl_lisnull[attno], identry + attno, isnull[attno]);
+       gistentryinit(entry, v->spl_rattr[attno], r, NULL, 0, FALSE);
+       rpenalty = gistpenalty(giststate, attno, &entry, v->spl_risnull[attno], identry + attno, isnull[attno]);
 
-       if ( lpenalty != rpenalty ) {
-           if ( lpenalty > rpenalty )
+       if (lpenalty != rpenalty)
+       {
+           if (lpenalty > rpenalty)
                toLeft = false;
            break;
        }
    }
 
-   if ( toLeft ) 
-       v->splitVector.spl_left[ v->splitVector.spl_nleft++ ] = off;
+   if (toLeft)
+       v->splitVector.spl_left[v->splitVector.spl_nleft++] = off;
    else
-       v->splitVector.spl_right[ v->splitVector.spl_nright++ ] = off;
+       v->splitVector.spl_right[v->splitVector.spl_nright++] = off;
 }
 
 #define SWAPVAR( s, d, t ) \
@@ -176,71 +198,83 @@ do {  \
 } while(0)
 
 /*
- * adjust left and right unions according to splits by previous 
- * split by firsts columns. This function is called only in case 
+ * adjust left and right unions according to splits by previous
+ * split by firsts columns. This function is called only in case
  * when pickSplit doesn't support subspplit.
  */
 
 static void
-supportSecondarySplit( Relation r, GISTSTATE *giststate, int attno, GIST_SPLITVEC *sv, Datum oldL, Datum oldR ) {
-   bool    leaveOnLeft = true, tmpBool;
-   GISTENTRY entryL, entryR, entrySL, entrySR; 
-   
-   gistentryinit(entryL, oldL, r, NULL, 0,  FALSE);
-   gistentryinit(entryR, oldR, r, NULL, 0,  FALSE);
-   gistentryinit(entrySL, sv->spl_ldatum , r, NULL, 0,  FALSE);
-   gistentryinit(entrySR, sv->spl_rdatum , r, NULL, 0,  FALSE);
-
-   if ( sv->spl_ldatum_exists && sv->spl_rdatum_exists ) {
-       float penalty1, penalty2;
+supportSecondarySplit(Relation r, GISTSTATE *giststate, int attno, GIST_SPLITVEC *sv, Datum oldL, Datum oldR)
+{
+   bool        leaveOnLeft = true,
+               tmpBool;
+   GISTENTRY   entryL,
+               entryR,
+               entrySL,
+               entrySR;
+
+   gistentryinit(entryL, oldL, r, NULL, 0, FALSE);
+   gistentryinit(entryR, oldR, r, NULL, 0, FALSE);
+   gistentryinit(entrySL, sv->spl_ldatum, r, NULL, 0, FALSE);
+   gistentryinit(entrySR, sv->spl_rdatum, r, NULL, 0, FALSE);
+
+   if (sv->spl_ldatum_exists && sv->spl_rdatum_exists)
+   {
+       float       penalty1,
+                   penalty2;
 
        penalty1 = gistpenalty(giststate, attno, &entryL, false, &entrySL, false) +
-                  gistpenalty(giststate, attno, &entryR, false, &entrySR, false);
+           gistpenalty(giststate, attno, &entryR, false, &entrySR, false);
        penalty2 = gistpenalty(giststate, attno, &entryL, false, &entrySR, false) +
-                  gistpenalty(giststate, attno, &entryR, false, &entrySL, false);
+           gistpenalty(giststate, attno, &entryR, false, &entrySL, false);
 
-       if ( penalty1 > penalty2 )
+       if (penalty1 > penalty2)
            leaveOnLeft = false;
 
-   } else {
-       GISTENTRY   *entry1 = (sv->spl_ldatum_exists) ? &entryL : &entryR;
-       float penalty1, penalty2;
+   }
+   else
+   {
+       GISTENTRY  *entry1 = (sv->spl_ldatum_exists) ? &entryL : &entryR;
+       float       penalty1,
+                   penalty2;
 
        /*
-        * there is only one previously defined union,
-        * so we just choose swap or not by lowest penalty
+        * there is only one previously defined union, so we just choose swap
+        * or not by lowest penalty
         */
 
        penalty1 = gistpenalty(giststate, attno, entry1, false, &entrySL, false);
        penalty2 = gistpenalty(giststate, attno, entry1, false, &entrySR, false);
 
-       if ( penalty1 < penalty2 ) 
-           leaveOnLeft = ( sv->spl_ldatum_exists ) ? true : false;
+       if (penalty1 < penalty2)
+           leaveOnLeft = (sv->spl_ldatum_exists) ? true : false;
        else
-           leaveOnLeft = ( sv->spl_rdatum_exists ) ? true : false;
+           leaveOnLeft = (sv->spl_rdatum_exists) ? true : false;
    }
 
-   if ( leaveOnLeft == false ) {
+   if (leaveOnLeft == false)
+   {
        /*
-        * swap left and right 
+        * swap left and right
         */
-       OffsetNumber    *off, noff;
-       Datum           datum;
-
-       SWAPVAR( sv->spl_left, sv->spl_right, off );
-       SWAPVAR( sv->spl_nleft, sv->spl_nright, noff );
-       SWAPVAR( sv->spl_ldatum, sv->spl_rdatum, datum );
-       gistentryinit(entrySL, sv->spl_ldatum , r, NULL, 0,  FALSE);
-       gistentryinit(entrySR, sv->spl_rdatum , r, NULL, 0,  FALSE);
+       OffsetNumber *off,
+                   noff;
+       Datum       datum;
+
+       SWAPVAR(sv->spl_left, sv->spl_right, off);
+       SWAPVAR(sv->spl_nleft, sv->spl_nright, noff);
+       SWAPVAR(sv->spl_ldatum, sv->spl_rdatum, datum);
+       gistentryinit(entrySL, sv->spl_ldatum, r, NULL, 0, FALSE);
+       gistentryinit(entrySR, sv->spl_rdatum, r, NULL, 0, FALSE);
    }
 
-   if ( sv->spl_ldatum_exists ) 
+   if (sv->spl_ldatum_exists)
        gistMakeUnionKey(giststate, attno, &entryL, false, &entrySL, false,
-                       &sv->spl_ldatum, &tmpBool);
+                        &sv->spl_ldatum, &tmpBool);
 
-   if ( sv->spl_rdatum_exists ) 
+   if (sv->spl_rdatum_exists)
        gistMakeUnionKey(giststate, attno, &entryR, false, &entrySR, false,
-                       &sv->spl_rdatum, &tmpBool);
+                        &sv->spl_rdatum, &tmpBool);
 
    sv->spl_ldatum_exists = sv->spl_rdatum_exists = false;
 }
@@ -251,20 +285,21 @@ supportSecondarySplit( Relation r, GISTSTATE *giststate, int attno, GIST_SPLITVE
  * get better split.
  * Returns TRUE and v->spl_equiv = NULL if left and right unions of attno columns are the same,
  * so caller may find better split
- * Returns TRUE and v->spl_equiv != NULL if there is tuples which may be freely moved 
+ * Returns TRUE and v->spl_equiv != NULL if there is tuples which may be freely moved
  */
 static bool
 gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVector *v,
                  IndexTuple *itup, int len, GISTSTATE *giststate)
 {
    GIST_SPLITVEC *sv = &v->splitVector;
+
    /*
     * now let the user-defined picksplit function set up the split vector; in
     * entryvec have no null value!!
     */
 
-   sv->spl_ldatum_exists = ( v->spl_lisnull[ attno ] ) ? false : true;
-   sv->spl_rdatum_exists = ( v->spl_risnull[ attno ] ) ? false : true;
+   sv->spl_ldatum_exists = (v->spl_lisnull[attno]) ? false : true;
+   sv->spl_rdatum_exists = (v->spl_risnull[attno]) ? false : true;
    sv->spl_ldatum = v->spl_lattr[attno];
    sv->spl_rdatum = v->spl_rattr[attno];
 
@@ -278,11 +313,12 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
    if (sv->spl_right[sv->spl_nright - 1] == InvalidOffsetNumber)
        sv->spl_right[sv->spl_nright - 1] = (OffsetNumber) (entryvec->n - 1);
 
-   if( sv->spl_ldatum_exists || sv->spl_rdatum_exists ) { 
-       elog(LOG,"PickSplit method of %d columns of index '%s' doesn't support secondary split",
-           attno + 1, RelationGetRelationName(r) );
+   if (sv->spl_ldatum_exists || sv->spl_rdatum_exists)
+   {
+       elog(LOG, "PickSplit method of %d columns of index '%s' doesn't support secondary split",
+            attno + 1, RelationGetRelationName(r));
 
-       supportSecondarySplit( r, giststate, attno, sv, v->spl_lattr[attno], v->spl_rattr[attno] ); 
+       supportSecondarySplit(r, giststate, attno, sv, v->spl_lattr[attno], v->spl_rattr[attno]);
    }
 
    v->spl_lattr[attno] = sv->spl_ldatum;
@@ -296,53 +332,64 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
     */
    v->spl_equiv = NULL;
 
-   if (giststate->tupdesc->natts > 1 && attno+1 != giststate->tupdesc->natts)
+   if (giststate->tupdesc->natts > 1 && attno + 1 != giststate->tupdesc->natts)
    {
-       if ( gistKeyIsEQ(giststate, attno, sv->spl_ldatum, sv->spl_rdatum) ) {
+       if (gistKeyIsEQ(giststate, attno, sv->spl_ldatum, sv->spl_rdatum))
+       {
            /*
-            * Left and right key's unions are equial, so
-            * we can get better split by following columns. Note,
-            * unions for attno columns are already done.
+            * Left and right key's unions are equial, so we can get better
+            * split by following columns. Note, unions for attno columns are
+            * already done.
             */
 
            return true;
-       } else {
+       }
+       else
+       {
            int         LenEquiv;
 
-           v->spl_equiv = (bool *) palloc0(sizeof(bool) * (entryvec->n+1));
+           v->spl_equiv = (bool *) palloc0(sizeof(bool) * (entryvec->n + 1));
 
            LenEquiv = gistfindgroup(r, giststate, entryvec->vector, v, attno);
 
            /*
-            * if possible, we should distribute equivalent tuples 
-            */
-           if (LenEquiv == 0 ) { 
+            * if possible, we should distribute equivalent tuples
+            */
+           if (LenEquiv == 0)
+           {
                gistunionsubkey(giststate, itup, v, attno + 1);
-           } else {
-               cleanupOffsets( sv->spl_left,  &sv->spl_nleft, v->spl_equiv, &LenEquiv );
-               cleanupOffsets( sv->spl_right, &sv->spl_nright, v->spl_equiv, &LenEquiv );
+           }
+           else
+           {
+               cleanupOffsets(sv->spl_left, &sv->spl_nleft, v->spl_equiv, &LenEquiv);
+               cleanupOffsets(sv->spl_right, &sv->spl_nright, v->spl_equiv, &LenEquiv);
 
                gistunionsubkey(giststate, itup, v, attno + 1);
-               if (LenEquiv == 1 ) {
+               if (LenEquiv == 1)
+               {
                    /*
-                    * In case with one tuple we just choose left-right 
-                    * by penalty. It's simplify user-defined pickSplit
+                    * In case with one tuple we just choose left-right by
+                    * penalty. It's simplify user-defined pickSplit
                     */
                    OffsetNumber toMove = InvalidOffsetNumber;
 
-                   for(toMove=FirstOffsetNumber;toMoven;toMove++) 
-                       if ( v->spl_equiv[ toMove ] )
+                   for (toMove = FirstOffsetNumber; toMove < entryvec->n; toMove++)
+                       if (v->spl_equiv[toMove])
                            break;
-                   Assert( toMove < entryvec->n );
-           
-                   placeOne( r, giststate, v, itup[ toMove-1 ], toMove, attno+1 );
-                   /* redo gistunionsubkey(): it will not degradate performance,
-                    * because it's very rarely */
+                   Assert(toMove < entryvec->n);
+
+                   placeOne(r, giststate, v, itup[toMove - 1], toMove, attno + 1);
+
+                   /*
+                    * redo gistunionsubkey(): it will not degradate
+                    * performance, because it's very rarely
+                    */
                    v->spl_equiv = NULL;
                    gistunionsubkey(giststate, itup, v, attno + 1);
 
                    return false;
-               } else if ( LenEquiv > 1 )
+               }
+               else if (LenEquiv > 1)
                    return true;
            }
        }
@@ -352,60 +399,65 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
 }
 
 /*
- * simple split page 
+ * simple split page
  */
 static void
-gistSplitHalf(GIST_SPLITVEC *v, int len) {
-   int i;
+gistSplitHalf(GIST_SPLITVEC *v, int len)
+{
+   int         i;
 
-   v->spl_nright   = v->spl_nleft      = 0;
+   v->spl_nright = v->spl_nleft = 0;
    v->spl_left = (OffsetNumber *) palloc(len * sizeof(OffsetNumber));
-   v->spl_right= (OffsetNumber *) palloc(len * sizeof(OffsetNumber));
-   for(i = 1; i <= len; i++)
-       if ( i)
-           v->spl_right[ v->spl_nright++ ] = i;
+   v->spl_right = (OffsetNumber *) palloc(len * sizeof(OffsetNumber));
+   for (i = 1; i <= len; i++)
+       if (i < len / 2)
+           v->spl_right[v->spl_nright++] = i;
        else
-           v->spl_left[ v->spl_nleft++ ] = i;
+           v->spl_left[v->spl_nleft++] = i;
 }
 
 /*
  * if it was invalid tuple then we need special processing.
- * We move all invalid tuples on right page. 
+ * We move all invalid tuples on right page.
  *
- * if there is no place on left page, gistSplit will be called one more 
+ * if there is no place on left page, gistSplit will be called one more
  * time for left page.
  *
  * Normally, we never exec this code, but after crash replay it's possible
  * to get 'invalid' tuples (probability is low enough)
  */
 static void
-gistSplitByInvalid(GISTSTATE *giststate, GistSplitVector *v, IndexTuple *itup, int len) {
-   int i;
-   static OffsetNumber offInvTuples[ MaxOffsetNumber ];
-   int          nOffInvTuples = 0;
+gistSplitByInvalid(GISTSTATE *giststate, GistSplitVector *v, IndexTuple *itup, int len)
+{
+   int         i;
+   static OffsetNumber offInvTuples[MaxOffsetNumber];
+   int         nOffInvTuples = 0;
 
    for (i = 1; i <= len; i++)
-       if ( GistTupleIsInvalid(itup[i - 1]) )
-           offInvTuples[ nOffInvTuples++ ] = i;
+       if (GistTupleIsInvalid(itup[i - 1]))
+           offInvTuples[nOffInvTuples++] = i;
 
-   if ( nOffInvTuples == len ) {
+   if (nOffInvTuples == len)
+   {
        /* corner case, all tuples are invalid */
-       v->spl_rightvalid= v->spl_leftvalid     = false;
-       gistSplitHalf( &v->splitVector, len );
-   } else {
-       GistSplitUnion    gsvp;
-               
+       v->spl_rightvalid = v->spl_leftvalid = false;
+       gistSplitHalf(&v->splitVector, len);
+   }
+   else
+   {
+       GistSplitUnion gsvp;
+
        v->splitVector.spl_right = offInvTuples;
        v->splitVector.spl_nright = nOffInvTuples;
        v->spl_rightvalid = false;
 
        v->splitVector.spl_left = (OffsetNumber *) palloc(len * sizeof(OffsetNumber));
        v->splitVector.spl_nleft = 0;
-       for(i = 1; i <= len; i++) 
-           if ( !GistTupleIsInvalid(itup[i - 1]) )
-               v->splitVector.spl_left[ v->splitVector.spl_nleft++ ] = i;
+       for (i = 1; i <= len; i++)
+           if (!GistTupleIsInvalid(itup[i - 1]))
+               v->splitVector.spl_left[v->splitVector.spl_nleft++] = i;
        v->spl_leftvalid = true;
-       
+
        gsvp.equiv = NULL;
        gsvp.attr = v->spl_lattr;
        gsvp.len = v->splitVector.spl_nleft;
@@ -418,52 +470,58 @@ gistSplitByInvalid(GISTSTATE *giststate, GistSplitVector *v, IndexTuple *itup, i
 
 /*
  * trys to split page by attno key, in a case of null
- * values move its to separate page. 
+ * values move its to separate page.
  */
 void
-gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, 
-       GistSplitVector *v, GistEntryVector *entryvec, int attno) {
-   int i;
-   static OffsetNumber offNullTuples[ MaxOffsetNumber ];
-   int          nOffNullTuples = 0;
+gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate,
+              GistSplitVector *v, GistEntryVector *entryvec, int attno)
+{
+   int         i;
+   static OffsetNumber offNullTuples[MaxOffsetNumber];
+   int         nOffNullTuples = 0;
 
-   for (i = 1; i <= len; i++) {
-       Datum       datum;
-       bool        IsNull;
+   for (i = 1; i <= len; i++)
+   {
+       Datum       datum;
+       bool        IsNull;
 
-       if (!GistPageIsLeaf(page) && GistTupleIsInvalid(itup[i - 1])) {
+       if (!GistPageIsLeaf(page) && GistTupleIsInvalid(itup[i - 1]))
+       {
            gistSplitByInvalid(giststate, v, itup, len);
            return;
        }
 
-       datum = index_getattr(itup[i - 1], attno+1, giststate->tupdesc, &IsNull);
+       datum = index_getattr(itup[i - 1], attno + 1, giststate->tupdesc, &IsNull);
        gistdentryinit(giststate, attno, &(entryvec->vector[i]),
                       datum, r, page, i,
                       FALSE, IsNull);
-       if ( IsNull )
-           offNullTuples[ nOffNullTuples++ ] = i;
+       if (IsNull)
+           offNullTuples[nOffNullTuples++] = i;
    }
 
    v->spl_leftvalid = v->spl_rightvalid = true;
 
-   if ( nOffNullTuples == len ) {
-       /* 
+   if (nOffNullTuples == len)
+   {
+       /*
         * Corner case: All keys in attno column are null, we should try to
-        * split by keys in next column. It all keys in all columns
-        * are NULL just split page half by half
+        * split by keys in next column. It all keys in all columns are NULL
+        * just split page half by half
         */
        v->spl_risnull[attno] = v->spl_lisnull[attno] = TRUE;
 
-       if ( attno+1 == r->rd_att->natts ) 
-           gistSplitHalf( &v->splitVector, len );
-       else 
-           gistSplitByKey(r, page, itup, len, giststate, v, entryvec, attno+1);
-   } else if ( nOffNullTuples > 0 ) {
-       int j=0;
-       
-       /* 
-        * We don't want to mix NULLs and not-NULLs keys
-        * on one page, so move nulls to right page
+       if (attno + 1 == r->rd_att->natts)
+           gistSplitHalf(&v->splitVector, len);
+       else
+           gistSplitByKey(r, page, itup, len, giststate, v, entryvec, attno + 1);
+   }
+   else if (nOffNullTuples > 0)
+   {
+       int         j = 0;
+
+       /*
+        * We don't want to mix NULLs and not-NULLs keys on one page, so move
+        * nulls to right page
         */
        v->splitVector.spl_right = offNullTuples;
        v->splitVector.spl_nright = nOffNullTuples;
@@ -471,61 +529,71 @@ gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *gist
 
        v->splitVector.spl_left = (OffsetNumber *) palloc(len * sizeof(OffsetNumber));
        v->splitVector.spl_nleft = 0;
-       for(i = 1; i <= len; i++) 
-           if ( jsplitVector.spl_nright && offNullTuples[j] == i ) 
+       for (i = 1; i <= len; i++)
+           if (j < v->splitVector.spl_nright && offNullTuples[j] == i)
                j++;
            else
-               v->splitVector.spl_left[ v->splitVector.spl_nleft++ ] = i;
+               v->splitVector.spl_left[v->splitVector.spl_nleft++] = i;
 
        v->spl_equiv = NULL;
        gistunionsubkey(giststate, itup, v, attno);
-   } else {
+   }
+   else
+   {
        /*
         * all keys are not-null
         */
-       entryvec->n = len+1;
+       entryvec->n = len + 1;
 
-       if ( gistUserPicksplit(r, entryvec, attno, v, itup, len, giststate) && attno+1 != r->rd_att->natts ) {
+       if (gistUserPicksplit(r, entryvec, attno, v, itup, len, giststate) && attno + 1 != r->rd_att->natts)
+       {
            /*
-            * Splitting on attno column is not optimized: there is a tuples which can be freely
-            * left or right page, we will try to split page by 
-            * following columns
+            * Splitting on attno column is not optimized: there is a tuples
+            * which can be freely left or right page, we will try to split
+            * page by following columns
             */
-           if ( v->spl_equiv == NULL ) {
-               /* simple case: left and right keys for attno column are equial */
-               gistSplitByKey(r, page, itup, len, giststate, v, entryvec, attno+1);
-           } else {
+           if (v->spl_equiv == NULL)
+           {
+               /*
+                * simple case: left and right keys for attno column are
+                * equial
+                */
+               gistSplitByKey(r, page, itup, len, giststate, v, entryvec, attno + 1);
+           }
+           else
+           {
                /* we should clean up vector from already distributed tuples */
-               IndexTuple  *newitup =  (IndexTuple*)palloc((len + 1) * sizeof(IndexTuple));
-               OffsetNumber    *map = (OffsetNumber*)palloc((len + 1) * sizeof(IndexTuple));
-               int newlen = 0;
+               IndexTuple *newitup = (IndexTuple *) palloc((len + 1) * sizeof(IndexTuple));
+               OffsetNumber *map = (OffsetNumber *) palloc((len + 1) * sizeof(IndexTuple));
+               int         newlen = 0;
                GIST_SPLITVEC backupSplit = v->splitVector;
 
-               for(i=0; i
-                   if ( v->spl_equiv[i+1] ) {
-                       map[ newlen ] = i+1;
-                       newitup[ newlen++ ] = itup[i];
+               for (i = 0; i < len; i++)
+                   if (v->spl_equiv[i + 1])
+                   {
+                       map[newlen] = i + 1;
+                       newitup[newlen++] = itup[i];
                    }
 
-               Assert( newlen>0 );
+               Assert(newlen > 0);
 
-               backupSplit.spl_left = (OffsetNumber*)palloc(sizeof(OffsetNumber)*len);
-               memcpy( backupSplit.spl_left, v->splitVector.spl_left, sizeof(OffsetNumber)*v->splitVector.spl_nleft);
-               backupSplit.spl_right = (OffsetNumber*)palloc(sizeof(OffsetNumber)*len);
-               memcpy( backupSplit.spl_right, v->splitVector.spl_right, sizeof(OffsetNumber)*v->splitVector.spl_nright);
+               backupSplit.spl_left = (OffsetNumber *) palloc(sizeof(OffsetNumber) * len);
+               memcpy(backupSplit.spl_left, v->splitVector.spl_left, sizeof(OffsetNumber) * v->splitVector.spl_nleft);
+               backupSplit.spl_right = (OffsetNumber *) palloc(sizeof(OffsetNumber) * len);
+               memcpy(backupSplit.spl_right, v->splitVector.spl_right, sizeof(OffsetNumber) * v->splitVector.spl_nright);
 
-               gistSplitByKey(r, page, newitup, newlen, giststate, v, entryvec, attno+1);
+               gistSplitByKey(r, page, newitup, newlen, giststate, v, entryvec, attno + 1);
 
                /* merge result of subsplit */
-               for(i=0;isplitVector.spl_nleft;i++)
-                   backupSplit.spl_left[ backupSplit.spl_nleft++ ] = map[ v->splitVector.spl_left[i]-1 ];
-               for(i=0;isplitVector.spl_nright;i++)
-                   backupSplit.spl_right[ backupSplit.spl_nright++ ] = map[ v->splitVector.spl_right[i]-1 ];
+               for (i = 0; i < v->splitVector.spl_nleft; i++)
+                   backupSplit.spl_left[backupSplit.spl_nleft++] = map[v->splitVector.spl_left[i] - 1];
+               for (i = 0; i < v->splitVector.spl_nright; i++)
+                   backupSplit.spl_right[backupSplit.spl_nright++] = map[v->splitVector.spl_right[i] - 1];
 
                v->splitVector = backupSplit;
                /* reunion left and right datums */
                gistunionsubkey(giststate, itup, v, attno);
            }
-       } 
+       }
    }
 }
index 9b1cfc0cf65db3bdc427d13553573cd2a08793f5..ff22bd2b6524708ba114f163e7098f20c7b23a41 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *         $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.19 2006/07/14 14:52:16 momjian Exp $
+ *         $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.20 2006/10/04 00:29:48 momjian Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
@@ -22,8 +22,8 @@
  * static *S used for temrorary storage (saves stack and palloc() call)
  */
 
-static Datum    attrS[INDEX_MAX_KEYS];
-static bool     isnullS[INDEX_MAX_KEYS];
+static Datum attrS[INDEX_MAX_KEYS];
+static bool isnullS[INDEX_MAX_KEYS];
 
 /*
  * Write itup vector to page, has no control of free space
@@ -57,14 +57,17 @@ gistfillbuffer(Relation r, Page page, IndexTuple *itup,
 bool
 gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
 {
-   unsigned int size = freespace, deleted = 0;
+   unsigned int size = freespace,
+               deleted = 0;
    int         i;
 
    for (i = 0; i < len; i++)
        size += IndexTupleSize(itvec[i]) + sizeof(ItemIdData);
 
-   if ( todelete != InvalidOffsetNumber ) {
-       IndexTuple itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, todelete));
+   if (todelete != InvalidOffsetNumber)
+   {
+       IndexTuple  itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, todelete));
+
        deleted = IndexTupleSize(itup) + sizeof(ItemIdData);
    }
 
@@ -72,11 +75,12 @@ gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size f
 }
 
 bool
-gistfitpage(IndexTuple *itvec, int len) {
-   int i;
-   Size size=0;
+gistfitpage(IndexTuple *itvec, int len)
+{
+   int         i;
+   Size        size = 0;
 
-   for(i=0;ii++)
+   for (i = 0; i < len; i++)
        size += IndexTupleSize(itvec[i]) + sizeof(ItemIdData);
 
    /* TODO: Consider fillfactor */
@@ -119,56 +123,64 @@ gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
  */
 
 IndexTupleData *
-gistfillitupvec(IndexTuple *vec, int veclen, int *memlen) {
-   char *ptr, *ret;
-   int i;
+gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
+{
+   char       *ptr,
+              *ret;
+   int         i;
+
+   *memlen = 0;
 
-   *memlen=0;
-                   
    for (i = 0; i < veclen; i++)
        *memlen += IndexTupleSize(vec[i]);
 
    ptr = ret = palloc(*memlen);
 
-   for (i = 0; i < veclen; i++) { 
+   for (i = 0; i < veclen; i++)
+   {
        memcpy(ptr, vec[i], IndexTupleSize(vec[i]));
        ptr += IndexTupleSize(vec[i]);
    }
 
-   return (IndexTupleData*)ret;
+   return (IndexTupleData *) ret;
 }
 
 /*
- * Make unions of keys in IndexTuple vector, return FALSE if itvec contains 
+ * Make unions of keys in IndexTuple vector, return FALSE if itvec contains
  * invalid tuple. Resulting Datums aren't compressed.
  */
 
-bool 
-gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, int startkey, 
-                   Datum *attr, bool *isnull ) {
+bool
+gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, int startkey,
+                  Datum *attr, bool *isnull)
+{
    int         i;
    GistEntryVector *evec;
-   int attrsize;
+   int         attrsize;
 
-   evec = (GistEntryVector *) palloc(  ( len + 2 )  * sizeof(GISTENTRY) + GEVHDRSZ);
+   evec = (GistEntryVector *) palloc((len + 2) * sizeof(GISTENTRY) + GEVHDRSZ);
 
-   for (i = startkey; i < giststate->tupdesc->natts; i++) {
-       int     j;
+   for (i = startkey; i < giststate->tupdesc->natts; i++)
+   {
+       int         j;
 
        evec->n = 0;
-       if ( !isnull[i] ) {
-           gistentryinit( evec->vector[evec->n], attr[i],
-                           NULL, NULL, (OffsetNumber) 0,
-                           FALSE);
+       if (!isnull[i])
+       {
+           gistentryinit(evec->vector[evec->n], attr[i],
+                         NULL, NULL, (OffsetNumber) 0,
+                         FALSE);
            evec->n++;
        }
 
-       for (j = 0; j < len; j++) {
-           Datum   datum;
-           bool    IsNull;
+       for (j = 0; j < len; j++)
+       {
+           Datum       datum;
+           bool        IsNull;
 
-           if (GistTupleIsInvalid(itvec[j])) 
-               return FALSE; /* signals that union with invalid tuple => result is invalid */
+           if (GistTupleIsInvalid(itvec[j]))
+               return FALSE;   /* signals that union with invalid tuple =>
+                                * result is invalid */
 
            datum = index_getattr(itvec[j], i + 1, giststate->tupdesc, &IsNull);
            if (IsNull)
@@ -183,19 +195,23 @@ gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, int startke
        }
 
        /* If this tuple vector was all NULLs, the union is NULL */
-       if ( evec->n == 0 ) {
+       if (evec->n == 0)
+       {
            attr[i] = (Datum) 0;
            isnull[i] = TRUE;
-       } else {
-           if (evec->n == 1) {
+       }
+       else
+       {
+           if (evec->n == 1)
+           {
                evec->n = 2;
                evec->vector[1] = evec->vector[0];
-           } 
+           }
 
            /* Make union and store in attr array */
            attr[i] = FunctionCall2(&giststate->unionFn[i],
-                                 PointerGetDatum(evec),
-                                 PointerGetDatum(&attrsize));
+                                   PointerGetDatum(evec),
+                                   PointerGetDatum(&attrsize));
 
            isnull[i] = FALSE;
        }
@@ -213,57 +229,67 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
 {
    memset(isnullS, TRUE, sizeof(bool) * giststate->tupdesc->natts);
 
-   if ( !gistMakeUnionItVec(giststate, itvec, len, 0, attrS, isnullS ) ) 
-           return gist_form_invalid_tuple(InvalidBlockNumber);
+   if (!gistMakeUnionItVec(giststate, itvec, len, 0, attrS, isnullS))
+       return gist_form_invalid_tuple(InvalidBlockNumber);
 
-   return  gistFormTuple(giststate, r, attrS, isnullS, false);
+   return gistFormTuple(giststate, r, attrS, isnullS, false);
 }
 
-/* 
+/*
  * makes union of two key
  */
 void
-gistMakeUnionKey( GISTSTATE *giststate, int attno,
-                   GISTENTRY   *entry1, bool isnull1,  
-                   GISTENTRY   *entry2, bool isnull2,
-                   Datum   *dst, bool *dstisnull ) {
+gistMakeUnionKey(GISTSTATE *giststate, int attno,
+                GISTENTRY *entry1, bool isnull1,
+                GISTENTRY *entry2, bool isnull2,
+                Datum *dst, bool *dstisnull)
+{
 
-   int dstsize;
+   int         dstsize;
 
-   static char storage[ 2 * sizeof(GISTENTRY) + GEVHDRSZ ];
-   GistEntryVector *evec = (GistEntryVector*)storage;
+   static char storage[2 * sizeof(GISTENTRY) + GEVHDRSZ];
+   GistEntryVector *evec = (GistEntryVector *) storage;
 
    evec->n = 2;
 
-   if ( isnull1 && isnull2 ) {
+   if (isnull1 && isnull2)
+   {
        *dstisnull = TRUE;
-       *dst = (Datum)0;
-   } else {
-       if ( isnull1 == FALSE && isnull2 == FALSE ) {
+       *dst = (Datum) 0;
+   }
+   else
+   {
+       if (isnull1 == FALSE && isnull2 == FALSE)
+       {
            evec->vector[0] = *entry1;
            evec->vector[1] = *entry2;
-       } else if ( isnull1 == FALSE ) {
+       }
+       else if (isnull1 == FALSE)
+       {
            evec->vector[0] = *entry1;
            evec->vector[1] = *entry1;
-       } else {
+       }
+       else
+       {
            evec->vector[0] = *entry2;
            evec->vector[1] = *entry2;
        }
 
        *dstisnull = FALSE;
        *dst = FunctionCall2(&giststate->unionFn[attno],
-                             PointerGetDatum(evec),
-                             PointerGetDatum(&dstsize));
+                            PointerGetDatum(evec),
+                            PointerGetDatum(&dstsize));
    }
 }
 
 bool
-gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b) {
-   bool result;
+gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
+{
+   bool        result;
 
    FunctionCall3(&giststate->equalFn[attno],
-                               a, b,
-                               PointerGetDatum(&result));
+                 a, b,
+                 PointerGetDatum(&result));
    return result;
 }
 
@@ -309,22 +335,24 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis
    gistDeCompressAtt(giststate, r, addtup, NULL,
                      (OffsetNumber) 0, addentries, addisnull);
 
-   for(i = 0; i < r->rd_att->natts; i++) {
-       gistMakeUnionKey( giststate, i,
-                           oldentries + i, oldisnull[i],
-                           addentries + i, addisnull[i],
-                           attrS + i, isnullS + i );
+   for (i = 0; i < r->rd_att->natts; i++)
+   {
+       gistMakeUnionKey(giststate, i,
+                        oldentries + i, oldisnull[i],
+                        addentries + i, addisnull[i],
+                        attrS + i, isnullS + i);
 
-       if ( neednew )
+       if (neednew)
            /* we already need new key, so we can skip check */
            continue;
 
-       if ( isnullS[i] )
+       if (isnullS[i])
            /* union of key may be NULL if and only if both keys are NULL */
            continue;
 
-       if ( !addisnull[i] ) {
-           if ( oldisnull[i] || gistKeyIsEQ(giststate, i, oldentries[i].key, attrS[i])==false )
+       if (!addisnull[i])
+       {
+           if (oldisnull[i] || gistKeyIsEQ(giststate, i, oldentries[i].key, attrS[i]) == false)
                neednew = true;
        }
    }
@@ -363,8 +391,8 @@ gistchoose(Relation r, Page p, IndexTuple it,   /* it has compressed entry */
                      it, NULL, (OffsetNumber) 0,
                      identry, isnull);
 
-   Assert( maxoff >= FirstOffsetNumber );
-   Assert( !GistPageIsLeaf(p) );
+   Assert(maxoff >= FirstOffsetNumber);
+   Assert(!GistPageIsLeaf(p));
 
    for (i = FirstOffsetNumber; i <= maxoff && sum_grow; i = OffsetNumberNext(i))
    {
@@ -484,7 +512,7 @@ gistFormTuple(GISTSTATE *giststate, Relation r,
        {
            gistcentryinit(giststate, i, ¢ry[i], attdata[i],
                           r, NULL, (OffsetNumber) 0,
-                          newValues, 
+                          newValues,
                           FALSE);
            compatt[i] = centry[i].key;
        }
@@ -500,18 +528,19 @@ gistpenalty(GISTSTATE *giststate, int attno,
            GISTENTRY *orig, bool isNullOrig,
            GISTENTRY *add, bool isNullAdd)
 {
-   float penalty = 0.0;
+   float       penalty = 0.0;
 
-   if ( giststate->penaltyFn[attno].fn_strict==FALSE || ( isNullOrig == FALSE && isNullAdd == FALSE ) ) 
+   if (giststate->penaltyFn[attno].fn_strict == FALSE || (isNullOrig == FALSE && isNullAdd == FALSE))
        FunctionCall3(&giststate->penaltyFn[attno],
                      PointerGetDatum(orig),
                      PointerGetDatum(add),
                      PointerGetDatum(&penalty));
-   else if ( isNullOrig && isNullAdd )
+   else if (isNullOrig && isNullAdd)
        penalty = 0.0;
    else
-       penalty = 1e10; /* try to prevent to mix null and non-null value */
-   
+       penalty = 1e10;         /* try to prevent to mix null and non-null
+                                * value */
+
    return penalty;
 }
 
index e5c73c8c2244e1bb837366808d058fa33384a7b2..5f5060280ddc51d68c9c81d535673ac8bdd7fea8 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.27 2006/09/21 20:31:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.28 2006/10/04 00:29:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -45,19 +45,24 @@ typedef struct
 } ArrayTuple;
 
 /*
- * Make union of keys on page 
+ * Make union of keys on page
  */
 static IndexTuple
-PageMakeUnionKey(GistVacuum *gv, Buffer buffer) {
-   Page    page = BufferGetPage( buffer );
+PageMakeUnionKey(GistVacuum *gv, Buffer buffer)
+{
+   Page        page = BufferGetPage(buffer);
    IndexTuple *vec,
-               tmp, res;
+               tmp,
+               res;
    int         veclen = 0;
    MemoryContext oldCtx = MemoryContextSwitchTo(gv->opCtx);
 
    vec = gistextractpage(page, &veclen);
-   /* we call gistunion() in temprorary context because user-defined functions called in gistunion()
-      may do not free all memory */
+
+   /*
+    * we call gistunion() in temprorary context because user-defined
+    * functions called in gistunion() may do not free all memory
+    */
    tmp = gistunion(gv->index, vec, veclen, &(gv->giststate));
    MemoryContextSwitchTo(oldCtx);
 
@@ -73,21 +78,25 @@ PageMakeUnionKey(GistVacuum *gv, Buffer buffer) {
 }
 
 static void
-gistDeleteSubtree( GistVacuum *gv, BlockNumber blkno ) {
-   Buffer  buffer;
-   Page    page;
+gistDeleteSubtree(GistVacuum *gv, BlockNumber blkno)
+{
+   Buffer      buffer;
+   Page        page;
 
    buffer = ReadBuffer(gv->index, blkno);
    LockBuffer(buffer, GIST_EXCLUSIVE);
    page = (Page) BufferGetPage(buffer);
 
-   if ( !GistPageIsLeaf(page) ) {
-       int     i;
+   if (!GistPageIsLeaf(page))
+   {
+       int         i;
+
+       for (i = FirstOffsetNumber; i <= PageGetMaxOffsetNumber(page); i = OffsetNumberNext(i))
+       {
+           ItemId      iid = PageGetItemId(page, i);
+           IndexTuple  idxtuple = (IndexTuple) PageGetItem(page, iid);
 
-       for (i = FirstOffsetNumber; i <= PageGetMaxOffsetNumber(page); i = OffsetNumberNext(i)) {
-           ItemId iid = PageGetItemId(page, i);
-           IndexTuple idxtuple = (IndexTuple) PageGetItem(page, iid);
-           gistDeleteSubtree(gv, ItemPointerGetBlockNumber(&(idxtuple->t_tid))); 
+           gistDeleteSubtree(gv, ItemPointerGetBlockNumber(&(idxtuple->t_tid)));
        }
    }
 
@@ -103,7 +112,7 @@ gistDeleteSubtree( GistVacuum *gv, BlockNumber blkno ) {
    {
        XLogRecData rdata[2];
        XLogRecPtr  recptr;
-       gistxlogPageDelete  xlrec;
+       gistxlogPageDelete xlrec;
 
        xlrec.node = gv->index->rd_node;
        xlrec.blkno = blkno;
@@ -125,31 +134,34 @@ gistDeleteSubtree( GistVacuum *gv, BlockNumber blkno ) {
    }
    else
        PageSetLSN(page, XLogRecPtrForTemp);
-   
+
    END_CRIT_SECTION();
 
    UnlockReleaseBuffer(buffer);
 }
 
-static Page    
-GistPageGetCopyPage( Page page ) {
-   Size    pageSize = PageGetPageSize( page );
-   Page tmppage;
+static Page
+GistPageGetCopyPage(Page page)
+{
+   Size        pageSize = PageGetPageSize(page);
+   Page        tmppage;
 
-   tmppage=(Page)palloc( pageSize );
-   memcpy( tmppage, page, pageSize );
+   tmppage = (Page) palloc(pageSize);
+   memcpy(tmppage, page, pageSize);
 
    return tmppage;
 }
 
 static ArrayTuple
-vacuumSplitPage(GistVacuum *gv, Page tempPage, Buffer buffer, IndexTuple *addon, int curlenaddon) {
+vacuumSplitPage(GistVacuum *gv, Page tempPage, Buffer buffer, IndexTuple *addon, int curlenaddon)
+{
    ArrayTuple  res = {NULL, 0, false};
    IndexTuple *vec;
    SplitedPageLayout *dist = NULL,
-                  *ptr;
-   int         i, veclen=0;
-   BlockNumber blkno = BufferGetBlockNumber(buffer);
+              *ptr;
+   int         i,
+               veclen = 0;
+   BlockNumber blkno = BufferGetBlockNumber(buffer);
    MemoryContext oldCtx = MemoryContextSwitchTo(gv->opCtx);
 
    vec = gistextractpage(tempPage, &veclen);
@@ -158,67 +170,73 @@ vacuumSplitPage(GistVacuum *gv, Page tempPage, Buffer buffer, IndexTuple *addon,
 
    MemoryContextSwitchTo(oldCtx);
 
-   if (blkno != GIST_ROOT_BLKNO) {
+   if (blkno != GIST_ROOT_BLKNO)
+   {
        /* if non-root split then we should not allocate new buffer */
        dist->buffer = buffer;
        dist->page = tempPage;
        /* during vacuum we never split leaf page */
        GistPageGetOpaque(dist->page)->flags = 0;
-   } else
+   }
+   else
        pfree(tempPage);
 
    res.itup = (IndexTuple *) palloc(sizeof(IndexTuple) * veclen);
    res.ituplen = 0;
 
    /* make new pages and fills them */
-   for (ptr = dist; ptr; ptr = ptr->next) {
-       char *data;
+   for (ptr = dist; ptr; ptr = ptr->next)
+   {
+       char       *data;
 
-       if ( ptr->buffer == InvalidBuffer ) {
-           ptr->buffer = gistNewBuffer( gv->index );
-           GISTInitBuffer( ptr->buffer, 0 );
+       if (ptr->buffer == InvalidBuffer)
+       {
+           ptr->buffer = gistNewBuffer(gv->index);
+           GISTInitBuffer(ptr->buffer, 0);
            ptr->page = BufferGetPage(ptr->buffer);
        }
-       ptr->block.blkno = BufferGetBlockNumber( ptr->buffer );
+       ptr->block.blkno = BufferGetBlockNumber(ptr->buffer);
 
-       data = (char*)(ptr->list);
-       for(i=0;iblock.num;i++) {
-           if ( PageAddItem(ptr->page, (Item)data, IndexTupleSize((IndexTuple)data), i+FirstOffsetNumber, LP_USED) == InvalidOffsetNumber )
+       data = (char *) (ptr->list);
+       for (i = 0; i < ptr->block.num; i++)
+       {
+           if (PageAddItem(ptr->page, (Item) data, IndexTupleSize((IndexTuple) data), i + FirstOffsetNumber, LP_USED) == InvalidOffsetNumber)
                elog(ERROR, "failed to add item to index page in \"%s\"", RelationGetRelationName(gv->index));
-           data += IndexTupleSize((IndexTuple)data);
+           data += IndexTupleSize((IndexTuple) data);
        }
 
        ItemPointerSetBlockNumber(&(ptr->itup->t_tid), ptr->block.blkno);
-       res.itup[ res.ituplen ] = (IndexTuple)palloc(IndexTupleSize(ptr->itup));
-       memcpy( res.itup[ res.ituplen ], ptr->itup, IndexTupleSize(ptr->itup) );
+       res.itup[res.ituplen] = (IndexTuple) palloc(IndexTupleSize(ptr->itup));
+       memcpy(res.itup[res.ituplen], ptr->itup, IndexTupleSize(ptr->itup));
        res.ituplen++;
    }
 
    START_CRIT_SECTION();
 
-   for (ptr = dist; ptr; ptr = ptr->next) {
+   for (ptr = dist; ptr; ptr = ptr->next)
+   {
        MarkBufferDirty(ptr->buffer);
        GistPageGetOpaque(ptr->page)->rightlink = InvalidBlockNumber;
    }
 
    /* restore splitted non-root page */
-   if (blkno != GIST_ROOT_BLKNO) {
-       PageRestoreTempPage( dist->page, BufferGetPage( dist->buffer ) );
-       dist->page = BufferGetPage( dist->buffer );
+   if (blkno != GIST_ROOT_BLKNO)
+   {
+       PageRestoreTempPage(dist->page, BufferGetPage(dist->buffer));
+       dist->page = BufferGetPage(dist->buffer);
    }
 
    if (!gv->index->rd_istemp)
    {
        XLogRecPtr  recptr;
        XLogRecData *rdata;
-       ItemPointerData key;        /* set key for incomplete
-                                    * insert */
+       ItemPointerData key;    /* set key for incomplete insert */
        char       *xlinfo;
 
        ItemPointerSet(&key, blkno, TUPLE_IS_VALID);
 
        rdata = formSplitRdata(gv->index->rd_node, blkno,
-                                          false, &key, dist);
+                              false, &key, dist);
        xlinfo = rdata->data;
 
        recptr = XLogInsert(RM_GIST_ID, XLOG_GIST_PAGE_SPLIT, rdata);
@@ -241,13 +259,12 @@ vacuumSplitPage(GistVacuum *gv, Page tempPage, Buffer buffer, IndexTuple *addon,
    {
        /* we must keep the buffer pin on the head page */
        if (BufferGetBlockNumber(ptr->buffer) != blkno)
-           UnlockReleaseBuffer( ptr->buffer );
+           UnlockReleaseBuffer(ptr->buffer);
    }
 
    if (blkno == GIST_ROOT_BLKNO)
    {
-       ItemPointerData key;        /* set key for incomplete
-                                    * insert */
+       ItemPointerData key;    /* set key for incomplete insert */
 
        ItemPointerSet(&key, blkno, TUPLE_IS_VALID);
 
@@ -266,7 +283,8 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
 {
    ArrayTuple  res = {NULL, 0, false};
    Buffer      buffer;
-   Page        page, tempPage = NULL;
+   Page        page,
+               tempPage = NULL;
    OffsetNumber i,
                maxoff;
    ItemId      iid;
@@ -278,7 +296,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
               *addon = NULL;
    bool        needwrite = false;
    OffsetNumber offToDelete[MaxOffsetNumber];
-   BlockNumber  blkToDelete[MaxOffsetNumber];
+   BlockNumber blkToDelete[MaxOffsetNumber];
    ItemPointerData *completed = NULL;
    int         ncompleted = 0,
                lencompleted = 16;
@@ -322,7 +340,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
            if (chldtuple.ituplen || chldtuple.emptypage)
            {
                /* update tuple or/and inserts new */
-               if ( chldtuple.emptypage )
+               if (chldtuple.emptypage)
                    blkToDelete[nBlkToDelete++] = ItemPointerGetBlockNumber(&(idxtuple->t_tid));
                offToDelete[nOffToDelete++] = i;
                PageIndexTupleDelete(tempPage, i);
@@ -333,7 +351,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
                if (chldtuple.ituplen)
                {
 
-                   Assert( chldtuple.emptypage == false );
+                   Assert(chldtuple.emptypage == false);
                    while (curlenaddon + chldtuple.ituplen >= lenaddon)
                    {
                        lenaddon *= 2;
@@ -367,56 +385,63 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
                }
            }
        }
-       
-       Assert( maxoff == PageGetMaxOffsetNumber(tempPage) );
+
+       Assert(maxoff == PageGetMaxOffsetNumber(tempPage));
 
        if (curlenaddon)
        {
            /* insert updated tuples */
-           if (gistnospace(tempPage, addon, curlenaddon, InvalidOffsetNumber, 0)) {
+           if (gistnospace(tempPage, addon, curlenaddon, InvalidOffsetNumber, 0))
+           {
                /* there is no space on page to insert tuples */
                res = vacuumSplitPage(gv, tempPage, buffer, addon, curlenaddon);
-               tempPage=NULL; /* vacuumSplitPage() free tempPage */
-               needwrite = needunion = false;      /* gistSplit already forms unions and writes pages */
-           } else
+               tempPage = NULL;    /* vacuumSplitPage() free tempPage */
+               needwrite = needunion = false;  /* gistSplit already forms
+                                                * unions and writes pages */
+           }
+           else
                /* enough free space */
                gistfillbuffer(gv->index, tempPage, addon, curlenaddon, InvalidOffsetNumber);
        }
    }
 
-   /* 
-    * If page is empty, we should remove pointer to it before
-    * deleting page (except root)
+   /*
+    * If page is empty, we should remove pointer to it before deleting page
+    * (except root)
     */
 
-   if ( blkno != GIST_ROOT_BLKNO && ( PageIsEmpty(page) || (tempPage && PageIsEmpty(tempPage)) ) ) {
+   if (blkno != GIST_ROOT_BLKNO && (PageIsEmpty(page) || (tempPage && PageIsEmpty(tempPage))))
+   {
        /*
-        * New version of page is empty, so leave it unchanged,
-        * upper call will mark our page as deleted.
-        * In case of page split we never will be here...
+        * New version of page is empty, so leave it unchanged, upper call
+        * will mark our page as deleted. In case of page split we never will
+        * be here...
         *
-        * If page was empty it can't become non-empty during processing 
+        * If page was empty it can't become non-empty during processing
         */
        res.emptypage = true;
        UnlockReleaseBuffer(buffer);
-   } else {
+   }
+   else
+   {
        /* write page and remove its childs if it need */
 
        START_CRIT_SECTION();
 
-       if ( tempPage && needwrite ) {
+       if (tempPage && needwrite)
+       {
            PageRestoreTempPage(tempPage, page);
            tempPage = NULL;
        }
 
-       /* Empty index */ 
-       if (PageIsEmpty(page) && blkno == GIST_ROOT_BLKNO )
+       /* Empty index */
+       if (PageIsEmpty(page) && blkno == GIST_ROOT_BLKNO)
        {
            needwrite = true;
            GistPageSetLeaf(page);
        }
 
-   
+
        if (needwrite)
        {
            MarkBufferDirty(buffer);
@@ -446,7 +471,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
 
        END_CRIT_SECTION();
 
-       if ( needunion && !PageIsEmpty(page) )
+       if (needunion && !PageIsEmpty(page))
        {
            res.itup = (IndexTuple *) palloc(sizeof(IndexTuple));
            res.ituplen = 1;
@@ -456,7 +481,7 @@ gistVacuumUpdate(GistVacuum *gv, BlockNumber blkno, bool needunion)
        UnlockReleaseBuffer(buffer);
 
        /* delete empty children, now we havn't any links to pointed subtrees */
-       for(i=0;i
+       for (i = 0; i < nBlkToDelete; i++)
            gistDeleteSubtree(gv, blkToDelete[i]);
 
        if (ncompleted && !gv->index->rd_istemp)
@@ -506,9 +531,10 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
        /* use heap's tuple count */
        Assert(info->num_heap_tuples >= 0);
        stats->std.num_index_tuples = info->num_heap_tuples;
+
        /*
-        * XXX the above is wrong if index is partial.  Would it be OK to
-        * just return NULL, or is there work we must do below?
+        * XXX the above is wrong if index is partial.  Would it be OK to just
+        * return NULL, or is there work we must do below?
         */
    }
 
@@ -545,8 +571,8 @@ gistvacuumcleanup(PG_FUNCTION_ARGS)
                        RelationGetRelationName(rel))));
 
    /*
-    * If vacuum full, we already have exclusive lock on the index.
-    * Otherwise, need lock unless it's local to this backend.
+    * If vacuum full, we already have exclusive lock on the index. Otherwise,
+    * need lock unless it's local to this backend.
     */
    if (info->vacuum_full)
        needLock = false;
@@ -725,7 +751,7 @@ gistbulkdelete(PG_FUNCTION_ARGS)
 
                if (callback(&(idxtuple->t_tid), callback_state))
                {
-                   todelete[ntodelete] = i-ntodelete;
+                   todelete[ntodelete] = i - ntodelete;
                    ntodelete++;
                    stats->std.tuples_removed += 1;
                }
@@ -739,7 +765,7 @@ gistbulkdelete(PG_FUNCTION_ARGS)
 
                MarkBufferDirty(buffer);
 
-               for(i=0;ii++)
+               for (i = 0; i < ntodelete; i++)
                    PageIndexTupleDelete(page, todelete[i]);
                GistMarkTuplesDeleted(page);
 
@@ -750,7 +776,7 @@ gistbulkdelete(PG_FUNCTION_ARGS)
                    gistxlogPageUpdate *xlinfo;
 
                    rdata = formUpdateRdata(rel->rd_node, buffer,
-                                           todelete, ntodelete, 
+                                           todelete, ntodelete,
                                            NULL, 0,
                                            NULL);
                    xlinfo = (gistxlogPageUpdate *) rdata->next->data;
index 9680ed96192c29da878d6c900b58368635d2611a..7ba2e6d52cc7d135f8e8c5c13b8fb092abf86551 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *          $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.23 2006/08/07 16:57:56 tgl Exp $
+ *          $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.24 2006/10/04 00:29:48 momjian Exp $
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
@@ -55,11 +55,11 @@ typedef struct gistIncompleteInsert
 
 
 static MemoryContext opCtx;        /* working memory for operations */
-static MemoryContext insertCtx;    /* holds incomplete_inserts list */
+static MemoryContext insertCtx; /* holds incomplete_inserts list */
 static List *incomplete_inserts;
 
 
-#define ItemPointerEQ(a, b)    \
+#define ItemPointerEQ(a, b) \
    ( ItemPointerGetOffsetNumber(a) == ItemPointerGetOffsetNumber(b) && \
      ItemPointerGetBlockNumber (a) == ItemPointerGetBlockNumber(b) )
 
@@ -72,8 +72,9 @@ pushIncompleteInsert(RelFileNode node, XLogRecPtr lsn, ItemPointerData key,
    MemoryContext oldCxt;
    gistIncompleteInsert *ninsert;
 
-   if ( !ItemPointerIsValid(&key) )
-       /* 
+   if (!ItemPointerIsValid(&key))
+
+       /*
         * if key is null then we should not store insertion as incomplete,
         * because it's a vacuum operation..
         */
@@ -108,8 +109,8 @@ pushIncompleteInsert(RelFileNode node, XLogRecPtr lsn, ItemPointerData key,
 
    /*
     * Stick the new incomplete insert onto the front of the list, not the
-    * back.  This is so that gist_xlog_cleanup will process incompletions
-    * in last-in-first-out order.
+    * back.  This is so that gist_xlog_cleanup will process incompletions in
+    * last-in-first-out order.
     */
    incomplete_inserts = lcons(ninsert, incomplete_inserts);
 
@@ -121,10 +122,10 @@ forgetIncompleteInsert(RelFileNode node, ItemPointerData key)
 {
    ListCell   *l;
 
-   if ( !ItemPointerIsValid(&key) )
+   if (!ItemPointerIsValid(&key))
        return;
 
-   if (incomplete_inserts==NIL)
+   if (incomplete_inserts == NIL)
        return;
 
    foreach(l, incomplete_inserts)
@@ -241,9 +242,12 @@ gistRedoPageUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot)
    if (GistPageIsLeaf(page) && xlrec.len == 0 && xlrec.data->ntodelete == 0)
        GistClearTuplesDeleted(page);
 
-   if ( !GistPageIsLeaf(page) && PageGetMaxOffsetNumber(page) == InvalidOffsetNumber && xldata->blkno == GIST_ROOT_BLKNO )
-       /* all links on non-leaf root page was deleted by vacuum full,
-          so root page becomes a leaf */
+   if (!GistPageIsLeaf(page) && PageGetMaxOffsetNumber(page) == InvalidOffsetNumber && xldata->blkno == GIST_ROOT_BLKNO)
+
+       /*
+        * all links on non-leaf root page was deleted by vacuum full, so root
+        * page becomes a leaf
+        */
        GistPageSetLeaf(page);
 
    GistPageGetOpaque(page)->rightlink = InvalidBlockNumber;
@@ -432,11 +436,11 @@ static void
 out_target(StringInfo buf, RelFileNode node, ItemPointerData key)
 {
    appendStringInfo(buf, "rel %u/%u/%u",
-           node.spcNode, node.dbNode, node.relNode);
-   if ( ItemPointerIsValid( &key ) )
+                    node.spcNode, node.dbNode, node.relNode);
+   if (ItemPointerIsValid(&key))
        appendStringInfo(buf, "; tid %u/%u",
-           ItemPointerGetBlockNumber(&key),
-           ItemPointerGetOffsetNumber(&key));
+                        ItemPointerGetBlockNumber(&key),
+                        ItemPointerGetOffsetNumber(&key));
 }
 
 static void
@@ -450,8 +454,8 @@ static void
 out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec)
 {
    appendStringInfo(buf, "page_delete: rel %u/%u/%u; blkno %u",
-           xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode,
-           xlrec->blkno);
+               xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode,
+                    xlrec->blkno);
 }
 
 static void
@@ -460,7 +464,7 @@ out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
    appendStringInfo(buf, "page_split: ");
    out_target(buf, xlrec->node, xlrec->key);
    appendStringInfo(buf, "; block number %u splits to %d pages",
-           xlrec->origblkno, xlrec->npage);
+                    xlrec->origblkno, xlrec->npage);
 }
 
 void
@@ -486,15 +490,15 @@ gist_desc(StringInfo buf, uint8 xl_info, char *rec)
            break;
        case XLOG_GIST_CREATE_INDEX:
            appendStringInfo(buf, "create_index: rel %u/%u/%u",
-                   ((RelFileNode *) rec)->spcNode,
-                   ((RelFileNode *) rec)->dbNode,
-                   ((RelFileNode *) rec)->relNode);
+                            ((RelFileNode *) rec)->spcNode,
+                            ((RelFileNode *) rec)->dbNode,
+                            ((RelFileNode *) rec)->relNode);
            break;
        case XLOG_GIST_INSERT_COMPLETE:
            appendStringInfo(buf, "complete_insert: rel %u/%u/%u",
-                   ((gistxlogInsertComplete *) rec)->node.spcNode,
-                   ((gistxlogInsertComplete *) rec)->node.dbNode,
-                   ((gistxlogInsertComplete *) rec)->node.relNode);
+                            ((gistxlogInsertComplete *) rec)->node.spcNode,
+                            ((gistxlogInsertComplete *) rec)->node.dbNode,
+                            ((gistxlogInsertComplete *) rec)->node.relNode);
            break;
        default:
            appendStringInfo(buf, "unknown gist op code %u", info);
@@ -547,22 +551,25 @@ gistxlogFindPath(Relation index, gistIncompleteInsert *insert)
        elog(ERROR, "lost parent for block %u", insert->origblkno);
 }
 
-static SplitedPageLayout*
-gistMakePageLayout(Buffer *buffers, int nbuffers) {
-   SplitedPageLayout   *res=NULL, *resptr;
+static SplitedPageLayout *
+gistMakePageLayout(Buffer *buffers, int nbuffers)
+{
+   SplitedPageLayout *res = NULL,
+              *resptr;
 
-   while( nbuffers-- > 0 ) {
-       Page page = BufferGetPage( buffers[ nbuffers ] );
-       IndexTuple* vec;
-       int veclen;
+   while (nbuffers-- > 0)
+   {
+       Page        page = BufferGetPage(buffers[nbuffers]);
+       IndexTuple *vec;
+       int         veclen;
 
-       resptr = (SplitedPageLayout*)palloc0( sizeof(SplitedPageLayout) );
+       resptr = (SplitedPageLayout *) palloc0(sizeof(SplitedPageLayout));
 
-       resptr->block.blkno = BufferGetBlockNumber( buffers[ nbuffers ] );
-       resptr->block.num = PageGetMaxOffsetNumber( page );
+       resptr->block.blkno = BufferGetBlockNumber(buffers[nbuffers]);
+       resptr->block.num = PageGetMaxOffsetNumber(page);
 
-       vec = gistextractpage( page, &veclen ); 
-       resptr->list = gistfillitupvec( vec, veclen, &(resptr->lenlist) );
+       vec = gistextractpage(page, &veclen);
+       resptr->list = gistfillitupvec(vec, veclen, &(resptr->lenlist));
 
        resptr->next = res;
        res = resptr;
@@ -580,7 +587,7 @@ gistMakePageLayout(Buffer *buffers, int nbuffers) {
  * Note that we assume the index is now in a valid state, except for the
  * unfinished insertion.  In particular it's safe to invoke gistFindPath();
  * there shouldn't be any garbage pages for it to run into.
- * 
+ *
  * To complete insert we can't use basic insertion algorithm because
  * during insertion we can't call user-defined support functions of opclass.
  * So, we insert 'invalid' tuples without real key and do it by separate algorithm.
@@ -607,7 +614,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
        itup[i] = gist_form_invalid_tuple(insert->blkno[i]);
 
    /*
-    * any insertion of itup[] should make LOG message about 
+    * any insertion of itup[] should make LOG message about
     */
 
    if (insert->origblkno == GIST_ROOT_BLKNO)
@@ -626,7 +633,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
        Buffer     *buffers;
        Page       *pages;
        int         numbuffer;
-       OffsetNumber    *todelete;
+       OffsetNumber *todelete;
 
        /* construct path */
        gistxlogFindPath(index, insert);
@@ -642,21 +649,22 @@ gistContinueInsert(gistIncompleteInsert *insert)
            int         j,
                        k,
                        pituplen = 0;
-           XLogRecData     *rdata;
-           XLogRecPtr      recptr;
-           Buffer  tempbuffer = InvalidBuffer;
-           int     ntodelete = 0;
+           XLogRecData *rdata;
+           XLogRecPtr  recptr;
+           Buffer      tempbuffer = InvalidBuffer;
+           int         ntodelete = 0;
 
            numbuffer = 1;
            buffers[0] = ReadBuffer(index, insert->path[i]);
            LockBuffer(buffers[0], GIST_EXCLUSIVE);
+
            /*
             * we check buffer, because we restored page earlier
             */
            gistcheckpage(index, buffers[0]);
 
            pages[0] = BufferGetPage(buffers[0]);
-           Assert( !GistPageIsLeaf(pages[0]) );
+           Assert(!GistPageIsLeaf(pages[0]));
 
            pituplen = PageGetMaxOffsetNumber(pages[0]);
 
@@ -678,12 +686,12 @@ gistContinueInsert(gistIncompleteInsert *insert)
                    }
            }
 
-           if ( ntodelete == 0 ) 
-               elog(PANIC,"gistContinueInsert: can't find pointer to page(s)");
+           if (ntodelete == 0)
+               elog(PANIC, "gistContinueInsert: can't find pointer to page(s)");
 
            /*
-            * we check space with subtraction only first tuple to delete, hope,
-            * that wiil be enough space....
+            * we check space with subtraction only first tuple to delete,
+            * hope, that wiil be enough space....
             */
 
            if (gistnospace(pages[0], itup, lenitup, *todelete, 0))
@@ -699,7 +707,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
 
                if (BufferGetBlockNumber(buffers[0]) == GIST_ROOT_BLKNO)
                {
-                   Buffer tmp;
+                   Buffer      tmp;
 
                    /*
                     * we split root, just copy content from root to new page
@@ -713,44 +721,48 @@ gistContinueInsert(gistIncompleteInsert *insert)
                    /* fill new page, root will be changed later */
                    tempbuffer = ReadBuffer(index, P_NEW);
                    LockBuffer(tempbuffer, GIST_EXCLUSIVE);
-                   memcpy( BufferGetPage(tempbuffer), pages[0], BufferGetPageSize(tempbuffer) );
+                   memcpy(BufferGetPage(tempbuffer), pages[0], BufferGetPageSize(tempbuffer));
 
                    /* swap buffers[0] (was root) and temp buffer */
                    tmp = buffers[0];
                    buffers[0] = tempbuffer;
-                   tempbuffer = tmp; /* now in tempbuffer GIST_ROOT_BLKNO, it is still unchanged */
+                   tempbuffer = tmp;   /* now in tempbuffer GIST_ROOT_BLKNO,
+                                        * it is still unchanged */
 
                    pages[0] = BufferGetPage(buffers[0]);
                }
 
                START_CRIT_SECTION();
 
-               for(j=0;jj++)
+               for (j = 0; j < ntodelete; j++)
                    PageIndexTupleDelete(pages[0], todelete[j]);
 
                rdata = formSplitRdata(index->rd_node, insert->path[i],
-                                       false, &(insert->key), 
-                                       gistMakePageLayout( buffers, numbuffer ) );
+                                      false, &(insert->key),
+                                    gistMakePageLayout(buffers, numbuffer));
 
-           } else {
+           }
+           else
+           {
                START_CRIT_SECTION();
 
-               for(j=0;jj++)
+               for (j = 0; j < ntodelete; j++)
                    PageIndexTupleDelete(pages[0], todelete[j]);
                gistfillbuffer(index, pages[0], itup, lenitup, InvalidOffsetNumber);
 
-               rdata = formUpdateRdata(index->rd_node, buffers[0], 
-                           todelete, ntodelete,
-                           itup, lenitup, &(insert->key)); 
+               rdata = formUpdateRdata(index->rd_node, buffers[0],
+                                       todelete, ntodelete,
+                                       itup, lenitup, &(insert->key));
            }
 
-           /* 
-            * use insert->key as mark for completion of insert (form*Rdata() above)
-            * for following possible replays
+           /*
+            * use insert->key as mark for completion of insert (form*Rdata()
+            * above) for following possible replays
             */
 
            /* write pages, we should mark it dirty befor XLogInsert() */
-           for (j = 0; j < numbuffer; j++) {
+           for (j = 0; j < numbuffer; j++)
+           {
                GistPageGetOpaque(pages[j])->rightlink = InvalidBlockNumber;
                MarkBufferDirty(buffers[j]);
            }
@@ -764,12 +776,14 @@ gistContinueInsert(gistIncompleteInsert *insert)
            END_CRIT_SECTION();
 
            lenitup = numbuffer;
-           for (j = 0; j < numbuffer; j++) {
+           for (j = 0; j < numbuffer; j++)
+           {
                itup[j] = gist_form_invalid_tuple(BufferGetBlockNumber(buffers[j]));
                UnlockReleaseBuffer(buffers[j]);
            }
 
-           if ( tempbuffer != InvalidBuffer ) {
+           if (tempbuffer != InvalidBuffer)
+           {
                /*
                 * it was a root split, so fill it by new values
                 */
@@ -780,9 +794,9 @@ gistContinueInsert(gistIncompleteInsert *insert)
    }
 
    ereport(LOG,
-   (errmsg("index %u/%u/%u needs VACUUM FULL or REINDEX to finish crash recovery",
+           (errmsg("index %u/%u/%u needs VACUUM FULL or REINDEX to finish crash recovery",
            insert->node.spcNode, insert->node.dbNode, insert->node.relNode),
-    errdetail("Incomplete insertion detected during crash replay.")));
+          errdetail("Incomplete insertion detected during crash replay.")));
 }
 
 void
index 3b05d11ee17bdec59f781dafc13a361463679d0c..1e2d779a14cfe58d914a126326d6714bbb1758f3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.47 2006/03/05 15:58:20 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.48 2006/10/04 00:29:48 momjian Exp $
  *
  * NOTES
  *   These functions are stored in pg_amproc.  For each operator class
@@ -138,9 +138,9 @@ hashtext(PG_FUNCTION_ARGS)
    Datum       result;
 
    /*
-    * Note: this is currently identical in behavior to hashvarlena, but
-    * keep it as a separate function in case we someday want to do something
-    * different in non-C locales.  (See also hashbpchar, if so.)
+    * Note: this is currently identical in behavior to hashvarlena, but keep
+    * it as a separate function in case we someday want to do something
+    * different in non-C locales.  (See also hashbpchar, if so.)
     */
    result = hash_any((unsigned char *) VARDATA(key),
                      VARSIZE(key) - VARHDRSZ);
index f5a1fcfd8149e7f67728071e73a1d69f2d722e20..696d4bf616ad2a0527659224ceeee31f1117b294 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.59 2006/07/03 22:45:36 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.60 2006/10/04 00:29:48 momjian Exp $
  *
  * NOTES
  *   Postgres hash pages look like ordinary relation pages.  The opaque
@@ -224,7 +224,7 @@ _hash_metapinit(Relation rel)
    /*
     * Determine the target fill factor (in tuples per bucket) for this index.
     * The idea is to make the fill factor correspond to pages about as full
-    * as the user-settable fillfactor parameter says.  We can compute it
+    * as the user-settable fillfactor parameter says.  We can compute it
     * exactly if the index datatype is fixed-width, but for var-width there's
     * some guessing involved.
     */
index 759f0b1f13b05726a83e538a615609dbb2c9832f..57acaf2bb8c896b8b69ac4d95c6baf88bf26bfd0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.219 2006/08/18 16:09:08 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.220 2006/10/04 00:29:48 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -133,9 +133,9 @@ heapgetpage(HeapScanDesc scan, BlockNumber page)
    snapshot = scan->rs_snapshot;
 
    /*
-    * We must hold share lock on the buffer content while examining
-    * tuple visibility.  Afterwards, however, the tuples we have found
-    * to be visible are guaranteed good as long as we hold the buffer pin.
+    * We must hold share lock on the buffer content while examining tuple
+    * visibility.  Afterwards, however, the tuples we have found to be
+    * visible are guaranteed good as long as we hold the buffer pin.
     */
    LockBuffer(buffer, BUFFER_LOCK_SHARE);
 
@@ -223,7 +223,7 @@ heapgettup(HeapScanDesc scan,
                tuple->t_data = NULL;
                return;
            }
-           page = 0;                           /* first page */
+           page = 0;           /* first page */
            heapgetpage(scan, page);
            lineoff = FirstOffsetNumber;        /* first offnum */
            scan->rs_inited = true;
@@ -231,8 +231,8 @@ heapgettup(HeapScanDesc scan,
        else
        {
            /* continue from previously returned page/tuple */
-           page = scan->rs_cblock;             /* current page */
-           lineoff =                           /* next offnum */
+           page = scan->rs_cblock;     /* current page */
+           lineoff =           /* next offnum */
                OffsetNumberNext(ItemPointerGetOffsetNumber(&(tuple->t_self)));
        }
 
@@ -263,7 +263,7 @@ heapgettup(HeapScanDesc scan,
        else
        {
            /* continue from previously returned page/tuple */
-           page = scan->rs_cblock;             /* current page */
+           page = scan->rs_cblock;     /* current page */
        }
 
        LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
@@ -273,12 +273,12 @@ heapgettup(HeapScanDesc scan,
 
        if (!scan->rs_inited)
        {
-           lineoff = lines;                    /* final offnum */
+           lineoff = lines;    /* final offnum */
            scan->rs_inited = true;
        }
        else
        {
-           lineoff =                           /* previous offnum */
+           lineoff =           /* previous offnum */
                OffsetNumberPrev(ItemPointerGetOffsetNumber(&(tuple->t_self)));
        }
        /* page and lineoff now reference the physically previous tid */
@@ -450,7 +450,7 @@ heapgettup_pagemode(HeapScanDesc scan,
                tuple->t_data = NULL;
                return;
            }
-           page = 0;                           /* first page */
+           page = 0;           /* first page */
            heapgetpage(scan, page);
            lineindex = 0;
            scan->rs_inited = true;
@@ -458,7 +458,7 @@ heapgettup_pagemode(HeapScanDesc scan,
        else
        {
            /* continue from previously returned page/tuple */
-           page = scan->rs_cblock;             /* current page */
+           page = scan->rs_cblock;     /* current page */
            lineindex = scan->rs_cindex + 1;
        }
 
@@ -487,7 +487,7 @@ heapgettup_pagemode(HeapScanDesc scan,
        else
        {
            /* continue from previously returned page/tuple */
-           page = scan->rs_cblock;             /* current page */
+           page = scan->rs_cblock;     /* current page */
        }
 
        dp = (Page) BufferGetPage(scan->rs_cbuf);
@@ -721,8 +721,8 @@ try_relation_open(Oid relationId, LOCKMODE lockmode)
        LockRelationOid(relationId, lockmode);
 
    /*
-    * Now that we have the lock, probe to see if the relation really
-    * exists or not.
+    * Now that we have the lock, probe to see if the relation really exists
+    * or not.
     */
    if (!SearchSysCacheExists(RELOID,
                              ObjectIdGetDatum(relationId),
@@ -764,7 +764,7 @@ relation_open_nowait(Oid relationId, LOCKMODE lockmode)
        if (!ConditionalLockRelationOid(relationId, lockmode))
        {
            /* try to throw error by name; relation could be deleted... */
-           char   *relname = get_rel_name(relationId);
+           char       *relname = get_rel_name(relationId);
 
            if (relname)
                ereport(ERROR,
@@ -774,8 +774,8 @@ relation_open_nowait(Oid relationId, LOCKMODE lockmode)
            else
                ereport(ERROR,
                        (errcode(ERRCODE_LOCK_NOT_AVAILABLE),
-                        errmsg("could not obtain lock on relation with OID %u",
-                               relationId)));
+                     errmsg("could not obtain lock on relation with OID %u",
+                            relationId)));
        }
    }
 
@@ -801,8 +801,8 @@ 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
-    * rel that has been dropped and recreated since the start of our
+    * 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 RelationIdGetRelation.
     * Note that relation_open does not need to do this, since a relation's
@@ -2723,7 +2723,7 @@ l3:
  * heap_inplace_update - update a tuple "in place" (ie, overwrite it)
  *
  * Overwriting violates both MVCC and transactional safety, so the uses
- * of this function in Postgres are extremely limited.  Nonetheless we
+ * of this function in Postgres are extremely limited. Nonetheless we
  * find some places to use it.
  *
  * The tuple cannot change size, and therefore it's reasonable to assume
@@ -2840,6 +2840,7 @@ heap_restrpos(HeapScanDesc scan)
    if (!ItemPointerIsValid(&scan->rs_mctid))
    {
        scan->rs_ctup.t_data = NULL;
+
        /*
         * unpin scan buffers
         */
@@ -2852,7 +2853,7 @@ heap_restrpos(HeapScanDesc scan)
    else
    {
        /*
-        * If we reached end of scan, rs_inited will now be false.  We must
+        * If we reached end of scan, rs_inited will now be false.  We must
         * reset it to true to keep heapgettup from doing the wrong thing.
         */
        scan->rs_inited = true;
@@ -2862,13 +2863,13 @@ heap_restrpos(HeapScanDesc scan)
            scan->rs_cindex = scan->rs_mindex;
            heapgettup_pagemode(scan,
                                NoMovementScanDirection,
-                               0,          /* needn't recheck scan keys */
+                               0,      /* needn't recheck scan keys */
                                NULL);
        }
        else
            heapgettup(scan,
                       NoMovementScanDirection,
-                      0,                   /* needn't recheck scan keys */
+                      0,       /* needn't recheck scan keys */
                       NULL);
    }
 }
@@ -2920,7 +2921,7 @@ log_heap_clean(Relation reln, Buffer buffer, OffsetNumber *unused, int uncnt)
 }
 
 /*
- * Perform XLogInsert for a heap-update operation.  Caller must already
+ * Perform XLogInsert for a heap-update operation. Caller must already
  * have modified the buffer(s) and marked them dirty.
  */
 static XLogRecPtr
@@ -3173,8 +3174,8 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record)
    if (record->xl_info & XLOG_HEAP_INIT_PAGE)
    {
        buffer = XLogReadBuffer(reln,
-                           ItemPointerGetBlockNumber(&(xlrec->target.tid)),
-                           true);
+                            ItemPointerGetBlockNumber(&(xlrec->target.tid)),
+                               true);
        Assert(BufferIsValid(buffer));
        page = (Page) BufferGetPage(buffer);
 
@@ -3183,13 +3184,13 @@ heap_xlog_insert(XLogRecPtr lsn, XLogRecord *record)
    else
    {
        buffer = XLogReadBuffer(reln,
-                           ItemPointerGetBlockNumber(&(xlrec->target.tid)),
-                           false);
+                            ItemPointerGetBlockNumber(&(xlrec->target.tid)),
+                               false);
        if (!BufferIsValid(buffer))
            return;
        page = (Page) BufferGetPage(buffer);
 
-       if (XLByteLE(lsn, PageGetLSN(page)))        /* changes are applied */
+       if (XLByteLE(lsn, PageGetLSN(page)))    /* changes are applied */
        {
            UnlockReleaseBuffer(buffer);
            return;
@@ -3308,6 +3309,7 @@ heap_xlog_update(XLogRecPtr lsn, XLogRecord *record, bool move)
        /* Set forward chain link in t_ctid */
        htup->t_ctid = xlrec->newtid;
    }
+
    /*
     * this test is ugly, but necessary to avoid thinking that insert change
     * is already applied
@@ -3345,7 +3347,7 @@ newt:;
            return;
        page = (Page) BufferGetPage(buffer);
 
-       if (XLByteLE(lsn, PageGetLSN(page)))        /* changes are applied */
+       if (XLByteLE(lsn, PageGetLSN(page)))    /* changes are applied */
        {
            UnlockReleaseBuffer(buffer);
            return;
@@ -3548,9 +3550,9 @@ static void
 out_target(StringInfo buf, xl_heaptid *target)
 {
    appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
-           target->node.spcNode, target->node.dbNode, target->node.relNode,
-           ItemPointerGetBlockNumber(&(target->tid)),
-           ItemPointerGetOffsetNumber(&(target->tid)));
+            target->node.spcNode, target->node.dbNode, target->node.relNode,
+                    ItemPointerGetBlockNumber(&(target->tid)),
+                    ItemPointerGetOffsetNumber(&(target->tid)));
 }
 
 void
@@ -3586,8 +3588,8 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
            appendStringInfo(buf, "update: ");
        out_target(buf, &(xlrec->target));
        appendStringInfo(buf, "; new %u/%u",
-               ItemPointerGetBlockNumber(&(xlrec->newtid)),
-               ItemPointerGetOffsetNumber(&(xlrec->newtid)));
+                        ItemPointerGetBlockNumber(&(xlrec->newtid)),
+                        ItemPointerGetOffsetNumber(&(xlrec->newtid)));
    }
    else if (info == XLOG_HEAP_MOVE)
    {
@@ -3599,24 +3601,24 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
            appendStringInfo(buf, "move: ");
        out_target(buf, &(xlrec->target));
        appendStringInfo(buf, "; new %u/%u",
-               ItemPointerGetBlockNumber(&(xlrec->newtid)),
-               ItemPointerGetOffsetNumber(&(xlrec->newtid)));
+                        ItemPointerGetBlockNumber(&(xlrec->newtid)),
+                        ItemPointerGetOffsetNumber(&(xlrec->newtid)));
    }
    else if (info == XLOG_HEAP_CLEAN)
    {
        xl_heap_clean *xlrec = (xl_heap_clean *) rec;
 
        appendStringInfo(buf, "clean: rel %u/%u/%u; blk %u",
-               xlrec->node.spcNode, xlrec->node.dbNode,
-               xlrec->node.relNode, xlrec->block);
+                        xlrec->node.spcNode, xlrec->node.dbNode,
+                        xlrec->node.relNode, xlrec->block);
    }
    else if (info == XLOG_HEAP_NEWPAGE)
    {
        xl_heap_newpage *xlrec = (xl_heap_newpage *) rec;
 
        appendStringInfo(buf, "newpage: rel %u/%u/%u; blk %u",
-               xlrec->node.spcNode, xlrec->node.dbNode,
-               xlrec->node.relNode, xlrec->blkno);
+                        xlrec->node.spcNode, xlrec->node.dbNode,
+                        xlrec->node.relNode, xlrec->blkno);
    }
    else if (info == XLOG_HEAP_LOCK)
    {
index 31386de167b42d93c6d363f09ab741d632297541..07c0a52990d43a85855d30bbeb9e9f6a0b044f29 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.64 2006/09/10 23:33:22 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.65 2006/10/04 00:29:48 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -1331,7 +1331,7 @@ toast_fetch_datum_slice(varattrib *attr, int32 sliceoffset, int32 length)
        VARATT_SIZEP(result) |= VARATT_FLAG_COMPRESSED;
 
    if (length == 0)
-       return result;      /* Can save a lot of work at this point! */
+       return result;          /* Can save a lot of work at this point! */
 
    startchunk = sliceoffset / TOAST_MAX_CHUNK_SIZE;
    endchunk = (sliceoffset + length - 1) / TOAST_MAX_CHUNK_SIZE;
index 347d2b5365a9d77e65760005623bef008e42f48a..26758cc1973a35f154ce25a156ecfc8069bd7f2c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.58 2006/07/31 20:08:59 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/index/genam.c,v 1.59 2006/10/04 00:29:48 momjian Exp $
  *
  * NOTES
  *   many of the old access method routines have been turned into
@@ -86,7 +86,7 @@ RelationGetIndexScan(Relation indexRelation,
    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 */
 
index 2663876f49452b7f49cc1574d7e9911e1ddc0f9b..493e9f0ad008b053f539dc73289df9fbfbe1c83b 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.94 2006/07/31 20:08:59 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.95 2006/10/04 00:29:48 momjian Exp $
  *
  * INTERFACE ROUTINES
  *     index_open      - open an index relation by relation OID
@@ -122,7 +122,7 @@ static IndexScanDesc index_beginscan_internal(Relation indexRelation,
  *     index_open - open an index relation by relation OID
  *
  *     If lockmode is not "NoLock", the specified kind of lock is
- *     obtained on the index.  (Generally, NoLock should only be
+ *     obtained on the index.  (Generally, NoLock should only be
  *     used if the caller knows it has some appropriate lock on the
  *     index already.)
  *
@@ -209,7 +209,7 @@ index_insert(Relation indexRelation,
  * index_getnext on this scan; index_getnext_indexitem will not use the
  * heapRelation link (nor the snapshot).  However, the caller had better
  * be holding some kind of lock on the heap relation in any case, to ensure
- * no one deletes it (or the index) out from under us.  Caller must also
+ * no one deletes it (or the index) out from under us. Caller must also
  * be holding a lock on the index.
  */
 IndexScanDesc
@@ -553,7 +553,7 @@ index_getmulti(IndexScanDesc scan,
  *
  *     callback routine tells whether a given main-heap tuple is
  *     to be deleted
- * 
+ *
  *     return value is an optional palloc'd struct of statistics
  * ----------------
  */
index 910d654443345ad3f0a3b2039b3f3e8eea8311d3..d74f1a336ae32b19b3179ffc78041acf1a21d084 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.143 2006/08/25 04:06:46 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.144 2006/10/04 00:29:48 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -252,7 +252,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
                     */
                    htup.t_self = itup->t_tid;
                    if (heap_fetch(heapRel, SnapshotSelf, &htup, &hbuffer,
-                                   false, NULL))
+                                  false, NULL))
                    {
                        /* Normal case --- it's still live */
                        ReleaseBuffer(hbuffer);
@@ -355,7 +355,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
  *         +  updates the metapage if a true root or fast root is split.
  *
  *     On entry, we must have the right buffer in which to do the
- *     insertion, and the buffer must be pinned and write-locked.  On return,
+ *     insertion, and the buffer must be pinned and write-locked.  On return,
  *     we will have dropped both the pin and the lock on the buffer.
  *
  *     If 'afteritem' is >0 then the new tuple must be inserted after the
@@ -608,7 +608,7 @@ _bt_insertonpg(Relation rel,
        if (!rel->rd_istemp)
        {
            xl_btree_insert xlrec;
-           BlockNumber xldownlink;
+           BlockNumber xldownlink;
            xl_btree_metadata xlmeta;
            uint8       xlinfo;
            XLogRecPtr  recptr;
@@ -888,16 +888,17 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
        sopaque = (BTPageOpaque) PageGetSpecialPointer(spage);
        if (sopaque->btpo_prev != ropaque->btpo_prev)
            elog(PANIC, "right sibling's left-link doesn't match");
+
        /*
         * Check to see if we can set the SPLIT_END flag in the right-hand
         * split page; this can save some I/O for vacuum since it need not
         * proceed to the right sibling.  We can set the flag if the right
-        * sibling has a different cycleid: that means it could not be part
-        * of a group of pages that were all split off from the same ancestor
+        * sibling has a different cycleid: that means it could not be part of
+        * a group of pages that were all split off from the same ancestor
         * page.  If you're confused, imagine that page A splits to A B and
         * then again, yielding A C B, while vacuum is in progress.  Tuples
         * originally in A could now be in either B or C, hence vacuum must
-        * examine both pages.  But if D, our right sibling, has a different
+        * examine both pages.  But if D, our right sibling, has a different
         * cycleid then it could not contain any tuples that were in A when
         * the vacuum started.
         */
@@ -911,8 +912,8 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
     *
     * NO EREPORT(ERROR) till right sibling is updated.  We can get away with
     * not starting the critical section till here because we haven't been
-    * scribbling on the original page yet, and we don't care about the
-    * new sibling until it's linked into the btree.
+    * scribbling on the original page yet, and we don't care about the new
+    * sibling until it's linked into the btree.
     */
    START_CRIT_SECTION();
 
@@ -947,8 +948,8 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
         * 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.  See comments
-        * for _bt_restore_page().
+        * and can be reconstructed by scanning the tuples.  See comments for
+        * _bt_restore_page().
         */
        xlrec.leftlen = ((PageHeader) leftpage)->pd_special -
            ((PageHeader) leftpage)->pd_upper;
@@ -1708,17 +1709,17 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
 static void
 _bt_vacuum_one_page(Relation rel, Buffer buffer)
 {
-   OffsetNumber    deletable[MaxOffsetNumber];
-   int             ndeletable = 0;
-   OffsetNumber    offnum,
-                   minoff,
-                   maxoff;
-   Page            page = BufferGetPage(buffer);
-   BTPageOpaque    opaque = (BTPageOpaque) PageGetSpecialPointer(page);
+   OffsetNumber deletable[MaxOffsetNumber];
+   int         ndeletable = 0;
+   OffsetNumber offnum,
+               minoff,
+               maxoff;
+   Page        page = BufferGetPage(buffer);
+   BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page);
 
    /*
-    * Scan over all items to see which ones need deleted
-    * according to LP_DELETE flags.
+    * Scan over all items to see which ones need deleted according to
+    * LP_DELETE flags.
     */
    minoff = P_FIRSTDATAKEY(opaque);
    maxoff = PageGetMaxOffsetNumber(page);
@@ -1726,7 +1727,7 @@ _bt_vacuum_one_page(Relation rel, Buffer buffer)
         offnum <= maxoff;
         offnum = OffsetNumberNext(offnum))
    {
-       ItemId itemId = PageGetItemId(page, offnum);
+       ItemId      itemId = PageGetItemId(page, offnum);
 
        if (ItemIdDeleted(itemId))
            deletable[ndeletable++] = offnum;
@@ -1734,10 +1735,11 @@ _bt_vacuum_one_page(Relation rel, Buffer buffer)
 
    if (ndeletable > 0)
        _bt_delitems(rel, buffer, deletable, ndeletable);
+
    /*
     * Note: if we didn't find any LP_DELETE items, then the page's
-    * BTP_HAS_GARBAGE hint bit is falsely set.  We do not bother
-    * expending a separate write to clear it, however.  We will clear
-    * it when we split the page.
+    * BTP_HAS_GARBAGE hint bit is falsely set.  We do not bother expending a
+    * separate write to clear it, however.  We will clear it when we split
+    * the page.
     */
 }
index 080e10c88cf4a701bc534bef98cca658bb530ca5..def14adf1f50c01ea45add2a1a61fefc149e4a91 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.99 2006/07/25 19:13:00 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.100 2006/10/04 00:29:49 momjian Exp $
  *
  * NOTES
  *    Postgres btree pages look like ordinary relation pages.  The opaque
@@ -124,10 +124,10 @@ _bt_getroot(Relation rel, int access)
 
        /*
         * Since the cache might be stale, we check the page more carefully
-        * here than normal.  We *must* check that it's not deleted.
-        * If it's not alone on its level, then we reject too --- this
-        * may be overly paranoid but better safe than sorry.  Note we
-        * don't check P_ISROOT, because that's not set in a "fast root".
+        * here than normal.  We *must* check that it's not deleted. If it's
+        * not alone on its level, then we reject too --- this may be overly
+        * paranoid but better safe than sorry.  Note we don't check P_ISROOT,
+        * because that's not set in a "fast root".
         */
        if (!P_IGNORE(rootopaque) &&
            rootopaque->btpo.level == rootlevel &&
@@ -662,18 +662,18 @@ _bt_delitems(Relation rel, Buffer buf,
    PageIndexMultiDelete(page, itemnos, nitems);
 
    /*
-    * We can clear the vacuum cycle ID since this page has certainly
-    * been processed by the current vacuum scan.
+    * We can clear the vacuum cycle ID since this page has certainly been
+    * processed by the current vacuum scan.
     */
    opaque = (BTPageOpaque) PageGetSpecialPointer(page);
    opaque->btpo_cycleid = 0;
 
    /*
     * Mark the page as not containing any LP_DELETE items.  This is not
-    * certainly true (there might be some that have recently been marked,
-    * but weren't included in our target-item list), but it will almost
-    * always be true and it doesn't seem worth an additional page scan
-    * to check it.  Remember that BTP_HAS_GARBAGE is only a hint anyway.
+    * certainly true (there might be some that have recently been marked, but
+    * weren't included in our target-item list), but it will almost always be
+    * true and it doesn't seem worth an additional page scan to check it.
+    * Remember that BTP_HAS_GARBAGE is only a hint anyway.
     */
    opaque->btpo_flags &= ~BTP_HAS_GARBAGE;
 
index fa5b162c908ddd1994d211d102e26a512a346349..c9a7a8b5b2917337875ec477d087ad43b7d75d33 100644 (file)
@@ -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.151 2006/09/21 20:31:22 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.152 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -55,7 +55,7 @@ typedef struct
    BlockNumber *freePages;
    int         nFreePages;     /* number of entries in freePages[] */
    int         maxFreePages;   /* allocated size of freePages[] */
-   BlockNumber totFreePages;   /* true total # of free pages */
+   BlockNumber totFreePages;   /* true total # of free pages */
    MemoryContext pagedelcontext;
 } BTVacState;
 
@@ -70,7 +70,7 @@ static void btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
             IndexBulkDeleteCallback callback, void *callback_state,
             BTCycleId cycleid);
 static void btvacuumpage(BTVacState *vstate, BlockNumber blkno,
-                        BlockNumber orig_blkno);
+            BlockNumber orig_blkno);
 
 
 /*
@@ -109,8 +109,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);
@@ -146,11 +146,11 @@ btbuild(PG_FUNCTION_ARGS)
 #endif   /* BTREE_BUILD_STATS */
 
    /*
-    * If we are reindexing a pre-existing index, it is critical to send out
-    * relcache invalidation SI message to ensure all backends re-read the
-    * index metapage.  We expect that the caller will ensure that happens
-    * (typically as a side effect of updating index stats, but it must
-    * happen even if the stats don't change!)
+    * If we are reindexing a pre-existing index, it is critical to send out a
+    * relcache invalidation SI message to ensure all backends re-read the
+    * index metapage.  We expect that the caller will ensure that happens
+    * (typically as a side effect of updating index stats, but it must happen
+    * even if the stats don't change!)
     */
 
    /*
@@ -252,11 +252,11 @@ btgettuple(PG_FUNCTION_ARGS)
        if (scan->kill_prior_tuple)
        {
            /*
-            * Yes, remember it for later.  (We'll deal with all such tuples
+            * Yes, remember it for later.  (We'll deal with all such tuples
             * at once right before leaving the index page.)  The test for
             * numKilled overrun is not just paranoia: if the caller reverses
             * direction in the indexscan then the same item might get entered
-            * multiple times.  It's not worth trying to optimize that, so we
+            * multiple times.  It's not worth trying to optimize that, so we
             * don't detect it, but instead just forget any excess entries.
             */
            if (so->killedItems == NULL)
@@ -316,8 +316,8 @@ btgetmulti(PG_FUNCTION_ARGS)
    while (ntids < max_tids)
    {
        /*
-        * Advance to next tuple within page.  This is the same as the
-        * easy case in _bt_next().
+        * Advance to next tuple within page.  This is the same as the easy
+        * case in _bt_next().
         */
        if (++so->currPos.itemIndex > so->currPos.lastItem)
        {
@@ -373,7 +373,7 @@ btrescan(PG_FUNCTION_ARGS)
            so->keyData = (ScanKey) palloc(scan->numberOfKeys * sizeof(ScanKeyData));
        else
            so->keyData = NULL;
-       so->killedItems = NULL;                 /* until needed */
+       so->killedItems = NULL; /* until needed */
        so->numKilled = 0;
        scan->opaque = so;
    }
@@ -461,9 +461,9 @@ btmarkpos(PG_FUNCTION_ARGS)
 
    /*
     * Just record the current itemIndex.  If we later step to next page
-    * before releasing the marked position, _bt_steppage makes a full copy
-    * of the currPos struct in markPos.  If (as often happens) the mark is
-    * moved before we leave the page, we don't have to do that work.
+    * before releasing the marked position, _bt_steppage makes a full copy of
+    * the currPos struct in markPos.  If (as often happens) the mark is moved
+    * before we leave the page, we don't have to do that work.
     */
    if (BTScanPosIsValid(so->currPos))
        so->markItemIndex = so->currPos.itemIndex;
@@ -485,11 +485,11 @@ btrestrpos(PG_FUNCTION_ARGS)
    if (so->markItemIndex >= 0)
    {
        /*
-        * The mark position is on the same page we are currently on.
-        * Just restore the itemIndex.
+        * The mark position is on the same page we are currently on. Just
+        * restore the itemIndex.
         */
        so->currPos.itemIndex = so->markItemIndex;
-   } 
+   }
    else
    {
        /* we aren't holding any read locks, but gotta drop the pin */
@@ -527,7 +527,7 @@ Datum
 btbulkdelete(PG_FUNCTION_ARGS)
 {
    IndexVacuumInfo *info = (IndexVacuumInfo *) PG_GETARG_POINTER(0);
-   IndexBulkDeleteResult * volatile stats = (IndexBulkDeleteResult *) PG_GETARG_POINTER(1);
+   IndexBulkDeleteResult *volatile stats = (IndexBulkDeleteResult *) PG_GETARG_POINTER(1);
    IndexBulkDeleteCallback callback = (IndexBulkDeleteCallback) PG_GETARG_POINTER(2);
    void       *callback_state = (void *) PG_GETARG_POINTER(3);
    Relation    rel = info->index;
@@ -569,10 +569,10 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
    IndexBulkDeleteResult *stats = (IndexBulkDeleteResult *) PG_GETARG_POINTER(1);
 
    /*
-    * If btbulkdelete was called, we need not do anything, just return
-    * the stats from the latest btbulkdelete call.  If it wasn't called,
-    * we must still do a pass over the index, to recycle any newly-recyclable
-    * pages and to obtain index statistics.
+    * If btbulkdelete was called, we need not do anything, just return the
+    * stats from the latest btbulkdelete call.  If it wasn't called, we must
+    * still do a pass over the index, to recycle any newly-recyclable pages
+    * and to obtain index statistics.
     *
     * Since we aren't going to actually delete any leaf items, there's no
     * need to go through all the vacuum-cycle-ID pushups.
@@ -586,8 +586,8 @@ btvacuumcleanup(PG_FUNCTION_ARGS)
    /*
     * During a non-FULL vacuum it's quite possible for us to be fooled by
     * concurrent page splits into double-counting some index tuples, so
-    * disbelieve any total that exceeds the underlying heap's count.
-    * (We can't check this during btbulkdelete.)
+    * disbelieve any total that exceeds the underlying heap's count. (We
+    * can't check this during btbulkdelete.)
     */
    if (!info->vacuum_full)
    {
@@ -622,8 +622,8 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
    bool        needLock;
 
    /*
-    * Reset counts that will be incremented during the scan; needed in
-    * case of multiple scans during a single VACUUM command
+    * Reset counts that will be incremented during the scan; needed in case
+    * of multiple scans during a single VACUUM command
     */
    stats->num_index_tuples = 0;
    stats->pages_deleted = 0;
@@ -647,24 +647,24 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
                                                  ALLOCSET_DEFAULT_MAXSIZE);
 
    /*
-    * The outer loop iterates over all index pages except the metapage,
-    * in physical order (we hope the kernel will cooperate in providing
+    * The outer loop iterates over all index pages except the metapage, in
+    * physical order (we hope the kernel will cooperate in providing
     * read-ahead for speed).  It is critical that we visit all leaf pages,
     * including ones added after we start the scan, else we might fail to
     * delete some deletable tuples.  Hence, we must repeatedly check the
     * relation length.  We must acquire the relation-extension lock while
     * doing so 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
+    * 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.)  Also, we need not worry if a page is added immediately after
+    * issue.)  Also, we need not worry if a page is added immediately after
     * we look; the page splitting code already has write-lock on the left
-    * page before it adds a right page, so we must already have processed
-    * any tuples due to be moved into such a page.
+    * page before it adds a right page, so we must already have processed any
+    * tuples due to be moved into such a page.
     *
     * We can skip locking for new or temp relations, however, since no one
     * else could be accessing them.
@@ -771,7 +771,7 @@ btvacuumpage(BTVacState *vstate, BlockNumber blkno, BlockNumber orig_blkno)
    void       *callback_state = vstate->callback_state;
    Relation    rel = info->index;
    bool        delete_now;
-   BlockNumber recurse_to;
+   BlockNumber recurse_to;
    Buffer      buf;
    Page        page;
    BTPageOpaque opaque;
@@ -796,10 +796,10 @@ restart:
        _bt_checkpage(rel, buf);
 
    /*
-    * If we are recursing, the only case we want to do anything with is
-    * live leaf page having the current vacuum cycle ID.  Any other state
-    * implies we already saw the page (eg, deleted it as being empty).
-    * In particular, we don't want to risk adding it to freePages twice.
+    * If we are recursing, the only case we want to do anything with is a
+    * live leaf page having the current vacuum cycle ID.  Any other state
+    * implies we already saw the page (eg, deleted it as being empty). In
+    * particular, we don't want to risk adding it to freePages twice.
     */
    if (blkno != orig_blkno)
    {
@@ -838,25 +838,24 @@ restart:
        OffsetNumber deletable[MaxOffsetNumber];
        int         ndeletable;
        OffsetNumber offnum,
-           minoff,
-           maxoff;
+                   minoff,
+                   maxoff;
 
        /*
-        * Trade in the initial read lock for a super-exclusive write
-        * lock on this page.  We must get such a lock on every leaf page
-        * over the course of the vacuum scan, whether or not it actually
-        * contains any deletable tuples --- see nbtree/README.
+        * Trade in the initial read lock for a super-exclusive write lock on
+        * this page.  We must get such a lock on every leaf page over the
+        * course of the vacuum scan, whether or not it actually contains any
+        * deletable tuples --- see nbtree/README.
         */
        LockBuffer(buf, BUFFER_LOCK_UNLOCK);
        LockBufferForCleanup(buf);
 
        /*
-        * Check whether we need to recurse back to earlier pages.  What
-        * we are concerned about is a page split that happened since we
-        * started the vacuum scan.  If the split moved some tuples to a
-        * lower page then we might have missed 'em.  If so, set up for
-        * tail recursion.  (Must do this before possibly clearing
-        * btpo_cycleid below!)
+        * Check whether we need to recurse back to earlier pages.  What we
+        * are concerned about is a page split that happened since we started
+        * the vacuum scan.  If the split moved some tuples to a lower page
+        * then we might have missed 'em.  If so, set up for tail recursion.
+        * (Must do this before possibly clearing btpo_cycleid below!)
         */
        if (vstate->cycleid != 0 &&
            opaque->btpo_cycleid == vstate->cycleid &&
@@ -866,8 +865,8 @@ restart:
            recurse_to = opaque->btpo_next;
 
        /*
-        * Scan over all items to see which ones need deleted
-        * according to the callback function.
+        * Scan over all items to see which ones need deleted according to the
+        * callback function.
         */
        ndeletable = 0;
        minoff = P_FIRSTDATAKEY(opaque);
@@ -890,8 +889,8 @@ restart:
        }
 
        /*
-        * Apply any needed deletes.  We issue just one _bt_delitems()
-        * call per page, so as to minimize WAL traffic.
+        * Apply any needed deletes.  We issue just one _bt_delitems() call
+        * per page, so as to minimize WAL traffic.
         */
        if (ndeletable > 0)
        {
@@ -908,8 +907,8 @@ restart:
             * have any deletions to do.  (If we do, _bt_delitems takes care
             * of this.)  This ensures we won't process the page again.
             *
-            * We treat this like a hint-bit update because there's no need
-            * to WAL-log it.
+            * We treat this like a hint-bit update because there's no need to
+            * WAL-log it.
             */
            if (vstate->cycleid != 0 &&
                opaque->btpo_cycleid == vstate->cycleid)
@@ -920,10 +919,10 @@ restart:
        }
 
        /*
-        * If it's now empty, try to delete; else count the live tuples.
-        * We don't delete when recursing, though, to avoid putting entries
-        * into freePages out-of-order (doesn't seem worth any extra code to
-        * handle the case).
+        * If it's now empty, try to delete; else count the live tuples. We
+        * don't delete when recursing, though, to avoid putting entries into
+        * freePages out-of-order (doesn't seem worth any extra code to handle
+        * the case).
         */
        if (minoff > maxoff)
            delete_now = (blkno == orig_blkno);
@@ -947,13 +946,12 @@ restart:
            stats->pages_deleted++;
 
        /*
-        * 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.)
+        * 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.)
         */
        if (ndel && info->vacuum_full)
        {
@@ -969,11 +967,11 @@ restart:
        _bt_relbuf(rel, buf);
 
    /*
-    * This is really tail recursion, but if the compiler is too stupid
-    * to optimize it as such, we'd eat an uncomfortably large amount of
-    * stack space per recursion level (due to the deletable[] array).
-    * A failure is improbable since the number of levels isn't likely to be
-    * large ... but just in case, let's hand-optimize into a loop.
+    * This is really tail recursion, but if the compiler is too stupid to
+    * optimize it as such, we'd eat an uncomfortably large amount of stack
+    * space per recursion level (due to the deletable[] array). A failure is
+    * improbable since the number of levels isn't likely to be large ... but
+    * just in case, let's hand-optimize into a loop.
     */
    if (recurse_to != P_NONE)
    {
index 07bc076e49b3026cf30cc0f38c3b7eadbb905549..6d9be1b0176636f17f90792eacb5df206914eb63 100644 (file)
@@ -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.106 2006/08/24 01:18:34 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.107 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,7 @@
 
 
 static bool _bt_readpage(IndexScanDesc scan, ScanDirection dir,
-                        OffsetNumber offnum);
+            OffsetNumber offnum);
 static bool _bt_steppage(IndexScanDesc scan, ScanDirection dir);
 static Buffer _bt_walk_left(Relation rel, Buffer buf);
 static bool _bt_endpoint(IndexScanDesc scan, ScanDirection dir);
@@ -417,7 +417,7 @@ _bt_compare(Relation rel,
  * _bt_first() -- Find the first item in a scan.
  *
  *     We need to be clever about the direction of scan, the search
- *     conditions, and the tree ordering.  We find the first item (or,
+ *     conditions, and the tree ordering.  We find the first item (or,
  *     if backwards scan, the last item) in the tree that satisfies the
  *     qualifications in the scan key.  On success exit, the page containing
  *     the current index tuple is pinned but not locked, and data about
@@ -604,7 +604,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
    {
        ScanKey     cur = startKeys[i];
 
-       Assert(cur->sk_attno == i+1);
+       Assert(cur->sk_attno == i + 1);
 
        if (cur->sk_flags & SK_ROW_HEADER)
        {
@@ -612,16 +612,17 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
             * Row comparison header: look to the first row member instead.
             *
             * The member scankeys are already in insertion format (ie, they
-            * have sk_func = 3-way-comparison function), but we have to
-            * watch out for nulls, which _bt_preprocess_keys didn't check.
-            * A null in the first row member makes the condition unmatchable,
-            * just like qual_ok = false.
+            * have sk_func = 3-way-comparison function), but we have to watch
+            * out for nulls, which _bt_preprocess_keys didn't check. A null
+            * in the first row member makes the condition unmatchable, just
+            * like qual_ok = false.
             */
            cur = (ScanKey) DatumGetPointer(cur->sk_argument);
            Assert(cur->sk_flags & SK_ROW_MEMBER);
            if (cur->sk_flags & SK_ISNULL)
                return false;
            memcpy(scankeys + i, cur, sizeof(ScanKeyData));
+
            /*
             * If the row comparison is the last positioning key we accepted,
             * try to add additional keys from the lower-order row members.
@@ -833,10 +834,10 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
     *
     * 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.  Adjust the starting offset if needed.
-    * (If this results in an offset before the first item or after the last
-    * one, _bt_readpage will report no items found, and then we'll step to
-    * the next page as needed.)
+    * the last item on this page.  Adjust the starting offset if needed. (If
+    * this results in an offset before the first item or after the last one,
+    * _bt_readpage will report no items found, and then we'll step to the
+    * next page as needed.)
     */
    if (goback)
        offnum = OffsetNumberPrev(offnum);
@@ -882,8 +883,8 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
    BTScanOpaque so = (BTScanOpaque) scan->opaque;
 
    /*
-    * Advance to next tuple on current page; or if there's no more,
-    * try to step to the next page with data.
+    * Advance to next tuple on current page; or if there's no more, try to
+    * step to the next page with data.
     */
    if (ScanDirectionIsForward(dir))
    {
@@ -954,8 +955,8 @@ _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum)
 
    /*
     * we must save the page's right-link while scanning it; this tells us
-    * where to step right to after we're done with these items.  There is
-    * no corresponding need for the left-link, since splits always go right.
+    * where to step right to after we're done with these items.  There is no
+    * corresponding need for the left-link, since splits always go right.
     */
    so->currPos.nextPage = opaque->btpo_next;
 
@@ -1055,8 +1056,8 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir)
        _bt_killitems(scan, true);
 
    /*
-    * Before we modify currPos, make a copy of the page data if there
-    * was a mark position that needs it.
+    * Before we modify currPos, make a copy of the page data if there was a
+    * mark position that needs it.
     */
    if (so->markItemIndex >= 0)
    {
@@ -1112,11 +1113,11 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir)
        so->currPos.moreRight = true;
 
        /*
-        * 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.
+        * 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.
         */
        for (;;)
        {
@@ -1136,9 +1137,9 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir)
                return false;
 
            /*
-            * Okay, we managed to move left to a non-deleted page.
-            * Done if it's not half-dead and contains matching tuples.
-            * 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 contains matching tuples. Else loop back
+            * and do it all again.
             */
            page = BufferGetPage(so->currPos.buf);
            opaque = (BTPageOpaque) PageGetSpecialPointer(page);
index da2b191d5c6f5b75cbc59f062be69781909c13e5..4951dca2182be1def65689c8a87f798dfae27e45 100644 (file)
@@ -57,7 +57,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.106 2006/07/14 14:52:17 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtsort.c,v 1.107 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,7 +125,7 @@ static void _bt_slideleft(Page page);
 static void _bt_sortaddtup(Page page, Size itemsize,
               IndexTuple itup, OffsetNumber itup_off);
 static void _bt_buildadd(BTWriteState *wstate, BTPageState *state,
-                        IndexTuple itup);
+            IndexTuple itup);
 static void _bt_uppershutdown(BTWriteState *wstate, BTPageState *state);
 static void _bt_load(BTWriteState *wstate,
         BTSpool *btspool, BTSpool *btspool2);
@@ -351,7 +351,7 @@ _bt_pagestate(BTWriteState *wstate, uint32 level)
        state->btps_full = (BLCKSZ * (100 - BTREE_NONLEAF_FILLFACTOR) / 100);
    else
        state->btps_full = RelationGetTargetPageFreeSpace(wstate->index,
-                                               BTREE_DEFAULT_FILLFACTOR);
+                                                  BTREE_DEFAULT_FILLFACTOR);
    /* no parent level, yet */
    state->btps_next = NULL;
 
@@ -464,8 +464,8 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup)
    Size        itupsz;
 
    /*
-    * This is a handy place to check for cancel interrupts during the
-    * btree load phase of index creation.
+    * This is a handy place to check for cancel interrupts during the btree
+    * load phase of index creation.
     */
    CHECK_FOR_INTERRUPTS();
 
@@ -499,10 +499,10 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup)
                "or use full text indexing.")));
 
    /*
-    * Check to see if page is "full".  It's definitely full if the item
-    * won't fit.  Otherwise, compare to the target freespace derived from
-    * the fillfactor.  However, we must put at least two items on each
-    * page, so disregard fillfactor if we don't have that many.
+    * Check to see if page is "full".  It's definitely full if the item won't
+    * fit.  Otherwise, compare to the target freespace derived from the
+    * fillfactor.  However, we must put at least two items on each page, so
+    * disregard fillfactor if we don't have that many.
     */
    if (pgspc < itupsz || (pgspc < state->btps_full && last_off > P_FIRSTKEY))
    {
index 8b680541121280a1200f35cd7a9658c1189eacec..a562ee6cbd2c346bdab64609cd9384470702404b 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.78 2006/07/25 19:13:00 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtutils.c,v 1.79 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,8 +28,8 @@
 
 static void _bt_mark_scankey_required(ScanKey skey);
 static bool _bt_check_rowcompare(ScanKey skey,
-                                IndexTuple tuple, TupleDesc tupdesc,
-                                ScanDirection dir, bool *continuescan);
+                    IndexTuple tuple, TupleDesc tupdesc,
+                    ScanDirection dir, bool *continuescan);
 
 
 /*
@@ -83,7 +83,7 @@ _bt_mkscankey(Relation rel, IndexTuple itup)
  *     comparison data ultimately used must match the key datatypes.
  *
  *     The result cannot be used with _bt_compare(), unless comparison
- *     data is first stored into the key entries.  Currently this
+ *     data is first stored into the key entries.  Currently this
  *     routine is only called by nbtsort.c and tuplesort.c, which have
  *     their own comparison routines.
  */
@@ -388,7 +388,7 @@ _bt_preprocess_keys(IndexScanDesc scan)
 
            /*
             * Emit the cleaned-up keys into the outkeys[] array, and then
-            * mark them if they are required.  They are required (possibly
+            * mark them if they are required.  They are required (possibly
             * only in one direction) if all attrs before this one had "=".
             */
            for (j = BTMaxStrategyNumber; --j >= 0;)
@@ -461,7 +461,7 @@ _bt_preprocess_keys(IndexScanDesc scan)
  * Mark a scankey as "required to continue the scan".
  *
  * Depending on the operator type, the key may be required for both scan
- * directions or just one.  Also, if the key is a row comparison header,
+ * directions or just one. Also, if the key is a row comparison header,
  * we have to mark the appropriate subsidiary ScanKeys as required.  In
  * such cases, the first subsidiary key is required, but subsequent ones
  * are required only as long as they correspond to successive index columns.
@@ -472,12 +472,12 @@ _bt_preprocess_keys(IndexScanDesc scan)
  * scribbling on a data structure belonging to the index AM's caller, not on
  * our private copy.  This should be OK because the marking will not change
  * from scan to scan within a query, and so we'd just re-mark the same way
- * anyway on a rescan.  Something to keep an eye on though.
+ * anyway on a rescan. Something to keep an eye on though.
  */
 static void
 _bt_mark_scankey_required(ScanKey skey)
 {
-   int     addflags;
+   int         addflags;
 
    switch (skey->sk_strategy)
    {
@@ -503,8 +503,8 @@ _bt_mark_scankey_required(ScanKey skey)
 
    if (skey->sk_flags & SK_ROW_HEADER)
    {
-       ScanKey subkey = (ScanKey) DatumGetPointer(skey->sk_argument);
-       AttrNumber attno = skey->sk_attno;
+       ScanKey     subkey = (ScanKey) DatumGetPointer(skey->sk_argument);
+       AttrNumber  attno = skey->sk_attno;
 
        /* First subkey should be same as the header says */
        Assert(subkey->sk_attno == attno);
@@ -558,12 +558,12 @@ _bt_checkkeys(IndexScanDesc scan,
    *continuescan = true;       /* default assumption */
 
    /*
-    * If the scan specifies not to return killed tuples, then we treat
-    * a killed tuple as not passing the qual.  Most of the time, it's a
-    * win to not bother examining the tuple's index keys, but just return
+    * If the scan specifies not to return killed tuples, then we treat a
+    * killed tuple as not passing the qual.  Most of the time, it's a win to
+    * not bother examining the tuple's index keys, but just return
     * immediately with continuescan = true to proceed to the next tuple.
-    * However, if this is the last tuple on the page, we should check
-    * the index keys to prevent uselessly advancing to the next page.
+    * However, if this is the last tuple on the page, we should check the
+    * index keys to prevent uselessly advancing to the next page.
     */
    if (scan->ignore_killed_tuples && ItemIdDeleted(iid))
    {
@@ -580,9 +580,10 @@ _bt_checkkeys(IndexScanDesc scan,
            if (offnum > P_FIRSTDATAKEY(opaque))
                return false;
        }
+
        /*
-        * OK, we want to check the keys, but we'll return FALSE even
-        * if the tuple passes the key tests.
+        * OK, we want to check the keys, but we'll return FALSE even if the
+        * tuple passes the key tests.
         */
        tuple_valid = false;
    }
@@ -734,10 +735,9 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, TupleDesc tupdesc,
        {
            /*
             * Unlike the simple-scankey case, this isn't a disallowed case.
-            * But it can never match.  If all the earlier row comparison
-            * columns are required for the scan direction, we can stop
-            * the scan, because there can't be another tuple that will
-            * succeed.
+            * But it can never match.  If all the earlier row comparison
+            * columns are required for the scan direction, we can stop the
+            * scan, because there can't be another tuple that will succeed.
             */
            if (subkey != (ScanKey) DatumGetPointer(skey->sk_argument))
                subkey--;
@@ -771,7 +771,7 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, TupleDesc tupdesc,
     */
    switch (subkey->sk_strategy)
    {
-       /* EQ and NE cases aren't allowed here */
+           /* EQ and NE cases aren't allowed here */
        case BTLessStrategyNumber:
            result = (cmpresult < 0);
            break;
@@ -795,8 +795,8 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, TupleDesc tupdesc,
    {
        /*
         * Tuple fails this qual.  If it's a required qual for the current
-        * scan direction, then we can conclude no further tuples will
-        * pass, either.  Note we have to look at the deciding column, not
+        * scan direction, then we can conclude no further tuples will pass,
+        * either.  Note we have to look at the deciding column, not
         * necessarily the first or last column of the row condition.
         */
        if ((subkey->sk_flags & SK_BT_REQFWD) &&
@@ -822,7 +822,7 @@ _bt_check_rowcompare(ScanKey skey, IndexTuple tuple, TupleDesc tupdesc,
  * is sufficient for setting LP_DELETE hint bits.
  *
  * We match items by heap TID before assuming they are the right ones to
- * delete.  We cope with cases where items have moved right due to insertions.
+ * delete. We cope with cases where items have moved right due to insertions.
  * If an item has moved off the current page due to a split, we'll fail to
  * find it and do nothing (this is not an error case --- we assume the item
  * will eventually get marked in a future indexscan).  Note that because we
@@ -856,9 +856,9 @@ _bt_killitems(IndexScanDesc scan, bool haveLock)
 
    for (i = 0; i < so->numKilled; i++)
    {
-       int             itemIndex = so->killedItems[i];
-       BTScanPosItem  *kitem = &so->currPos.items[itemIndex];
-       OffsetNumber    offnum = kitem->indexOffset;
+       int         itemIndex = so->killedItems[i];
+       BTScanPosItem *kitem = &so->currPos.items[itemIndex];
+       OffsetNumber offnum = kitem->indexOffset;
 
        Assert(itemIndex >= so->currPos.firstItem &&
               itemIndex <= so->currPos.lastItem);
@@ -881,9 +881,9 @@ _bt_killitems(IndexScanDesc scan, bool haveLock)
    }
 
    /*
-    * 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.
     *
     * Whenever we mark anything LP_DELETEd, we also set the page's
     * BTP_HAS_GARBAGE flag, which is likewise just a hint.
@@ -898,8 +898,8 @@ _bt_killitems(IndexScanDesc scan, bool haveLock)
        LockBuffer(so->currPos.buf, BUFFER_LOCK_UNLOCK);
 
    /*
-    * Always reset the scan state, so we don't look for same items
-    * on other pages.
+    * Always reset the scan state, so we don't look for same items on other
+    * pages.
     */
    so->numKilled = 0;
 }
@@ -908,8 +908,8 @@ _bt_killitems(IndexScanDesc scan, bool haveLock)
 /*
  * The following routines manage a shared-memory area in which we track
  * assignment of "vacuum cycle IDs" to currently-active btree vacuuming
- * operations.  There is a single counter which increments each time we
- * start a vacuum to assign it a cycle ID.  Since multiple vacuums could
+ * operations. There is a single counter which increments each time we
+ * start a vacuum to assign it a cycle ID. Since multiple vacuums could
  * be active concurrently, we have to track the cycle ID for each active
  * vacuum; this requires at most MaxBackends entries (usually far fewer).
  * We assume at most one vacuum can be active for a given index.
@@ -987,7 +987,8 @@ _bt_start_vacuum(Relation rel)
    LWLockAcquire(BtreeVacuumLock, LW_EXCLUSIVE);
 
    /* Assign the next cycle ID, being careful to avoid zero */
-   do {
+   do
+   {
        result = ++(btvacinfo->cycle_ctr);
    } while (result == 0);
 
index 88962ccfcecbaf04c6a1b896797b7ab3d7266bd0..e22ce04bbc16cbe6efe90d3712e4e6e7b489aa02 100644 (file)
@@ -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.37 2006/08/07 16:57:56 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.38 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -82,7 +82,7 @@ forget_matching_split(RelFileNode node, BlockNumber downlink, bool is_root)
  * in correct itemno sequence, but physically the opposite order from the
  * original, because we insert them in the opposite of itemno order.  This
  * does not matter in any current btree code, but it's something to keep an
- * eye on.  Is it worth changing just on general principles?
+ * eye on. Is it worth changing just on general principles?
  */
 static void
 _bt_restore_page(Page page, char *from, int len)
@@ -155,7 +155,7 @@ btree_xlog_insert(bool isleaf, bool ismeta,
    char       *datapos;
    int         datalen;
    xl_btree_metadata md;
-   BlockNumber downlink = 0;
+   BlockNumber downlink = 0;
 
    datapos = (char *) xlrec + SizeOfBtreeInsert;
    datalen = record->xl_len - SizeOfBtreeInsert;
@@ -180,7 +180,7 @@ btree_xlog_insert(bool isleaf, bool ismeta,
    if (!(record->xl_info & XLR_BKP_BLOCK_1))
    {
        buffer = XLogReadBuffer(reln,
-                           ItemPointerGetBlockNumber(&(xlrec->target.tid)),
+                            ItemPointerGetBlockNumber(&(xlrec->target.tid)),
                                false);
        if (BufferIsValid(buffer))
        {
@@ -193,7 +193,7 @@ btree_xlog_insert(bool isleaf, bool ismeta,
            else
            {
                if (PageAddItem(page, (Item) datapos, datalen,
-                               ItemPointerGetOffsetNumber(&(xlrec->target.tid)),
+                           ItemPointerGetOffsetNumber(&(xlrec->target.tid)),
                                LP_USED) == InvalidOffsetNumber)
                    elog(PANIC, "btree_insert_redo: failed to add item");
 
@@ -225,7 +225,7 @@ btree_xlog_split(bool onleft, bool isroot,
    OffsetNumber targetoff;
    BlockNumber leftsib;
    BlockNumber rightsib;
-   BlockNumber downlink = 0;
+   BlockNumber downlink = 0;
    Buffer      buffer;
    Page        page;
    BTPageOpaque pageop;
@@ -376,8 +376,8 @@ btree_xlog_delete(XLogRecPtr lsn, XLogRecord *record)
    }
 
    /*
-    * Mark the page as not containing any LP_DELETE items --- see comments
-    * in _bt_delitems().
+    * Mark the page as not containing any LP_DELETE items --- see comments in
+    * _bt_delitems().
     */
    opaque = (BTPageOpaque) PageGetSpecialPointer(page);
    opaque->btpo_flags &= ~BTP_HAS_GARBAGE;
@@ -543,7 +543,7 @@ btree_xlog_newroot(XLogRecPtr lsn, XLogRecord *record)
    Buffer      buffer;
    Page        page;
    BTPageOpaque pageop;
-   BlockNumber downlink = 0;
+   BlockNumber downlink = 0;
 
    reln = XLogOpenRelation(xlrec->node);
    buffer = XLogReadBuffer(reln, xlrec->rootblk, true);
@@ -637,9 +637,9 @@ static void
 out_target(StringInfo buf, xl_btreetid *target)
 {
    appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
-           target->node.spcNode, target->node.dbNode, target->node.relNode,
-           ItemPointerGetBlockNumber(&(target->tid)),
-           ItemPointerGetOffsetNumber(&(target->tid)));
+            target->node.spcNode, target->node.dbNode, target->node.relNode,
+                    ItemPointerGetBlockNumber(&(target->tid)),
+                    ItemPointerGetOffsetNumber(&(target->tid)));
 }
 
 void
@@ -680,7 +680,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
                appendStringInfo(buf, "split_l: ");
                out_target(buf, &(xlrec->target));
                appendStringInfo(buf, "; oth %u; rgh %u",
-                       xlrec->otherblk, xlrec->rightblk);
+                                xlrec->otherblk, xlrec->rightblk);
                break;
            }
        case XLOG_BTREE_SPLIT_R:
@@ -690,7 +690,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
                appendStringInfo(buf, "split_r: ");
                out_target(buf, &(xlrec->target));
                appendStringInfo(buf, "; oth %u; rgh %u",
-                       xlrec->otherblk, xlrec->rightblk);
+                                xlrec->otherblk, xlrec->rightblk);
                break;
            }
        case XLOG_BTREE_SPLIT_L_ROOT:
@@ -700,7 +700,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
                appendStringInfo(buf, "split_l_root: ");
                out_target(buf, &(xlrec->target));
                appendStringInfo(buf, "; oth %u; rgh %u",
-                       xlrec->otherblk, xlrec->rightblk);
+                                xlrec->otherblk, xlrec->rightblk);
                break;
            }
        case XLOG_BTREE_SPLIT_R_ROOT:
@@ -710,7 +710,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
                appendStringInfo(buf, "split_r_root: ");
                out_target(buf, &(xlrec->target));
                appendStringInfo(buf, "; oth %u; rgh %u",
-                       xlrec->otherblk, xlrec->rightblk);
+                                xlrec->otherblk, xlrec->rightblk);
                break;
            }
        case XLOG_BTREE_DELETE:
@@ -718,8 +718,8 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
                xl_btree_delete *xlrec = (xl_btree_delete *) rec;
 
                appendStringInfo(buf, "delete: rel %u/%u/%u; blk %u",
-                       xlrec->node.spcNode, xlrec->node.dbNode,
-                       xlrec->node.relNode, xlrec->block);
+                                xlrec->node.spcNode, xlrec->node.dbNode,
+                                xlrec->node.relNode, xlrec->block);
                break;
            }
        case XLOG_BTREE_DELETE_PAGE:
@@ -730,7 +730,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
                appendStringInfo(buf, "delete_page: ");
                out_target(buf, &(xlrec->target));
                appendStringInfo(buf, "; dead %u; left %u; right %u",
-                       xlrec->deadblk, xlrec->leftblk, xlrec->rightblk);
+                           xlrec->deadblk, xlrec->leftblk, xlrec->rightblk);
                break;
            }
        case XLOG_BTREE_NEWROOT:
@@ -738,9 +738,9 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
                xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
 
                appendStringInfo(buf, "newroot: rel %u/%u/%u; root %u lev %u",
-                       xlrec->node.spcNode, xlrec->node.dbNode,
-                       xlrec->node.relNode,
-                       xlrec->rootblk, xlrec->level);
+                                xlrec->node.spcNode, xlrec->node.dbNode,
+                                xlrec->node.relNode,
+                                xlrec->rootblk, xlrec->level);
                break;
            }
        default:
index 0621d3bc60449657ba12ffdb05e61a53d26b3e7f..f57bdefa3a0d3a97bea89ffc5993a0dad355dce2 100644 (file)
@@ -24,7 +24,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.39 2006/07/13 16:49:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.40 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -414,7 +414,7 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record)
 void
 clog_desc(StringInfo buf, uint8 xl_info, char *rec)
 {
-   uint8           info = xl_info & ~XLR_INFO_MASK;
+   uint8       info = xl_info & ~XLR_INFO_MASK;
 
    if (info == CLOG_ZEROPAGE)
    {
index ae5272286a2d4c4a9455eac79675688649d18531..167d65fd2d7aff17a3560229b15958d68c99a3bb 100644 (file)
@@ -42,7 +42,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.20 2006/07/20 00:46:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.21 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1493,10 +1493,10 @@ CheckPointMultiXact(void)
 
    /*
     * Truncate the SLRU files.  This could be done at any time, but
-    * checkpoint seems a reasonable place for it.  There is one exception:
-    * if we are called during xlog recovery, then shared->latest_page_number
-    * isn't valid (because StartupMultiXact hasn't been called yet) and
-    * so SimpleLruTruncate would get confused.  It seems best not to risk
+    * checkpoint seems a reasonable place for it.  There is one exception: if
+    * we are called during xlog recovery, then shared->latest_page_number
+    * isn't valid (because StartupMultiXact hasn't been called yet) and so
+    * SimpleLruTruncate would get confused.  It seems best not to risk
     * removing any data during recovery anyway, so don't truncate.
     */
    if (!InRecovery)
@@ -1917,7 +1917,7 @@ multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
        int         i;
 
        appendStringInfo(buf, "create multixact %u offset %u:",
-               xlrec->mid, xlrec->moff);
+                        xlrec->mid, xlrec->moff);
        for (i = 0; i < xlrec->nxids; i++)
            appendStringInfo(buf, " %u", xlrec->xids[i]);
    }
index 7c3884628be686bf67dd66f9f2e9e4f7ea713e30..08bb3598ac9c4b4524fa97c94a6ec16a3780be07 100644 (file)
@@ -41,7 +41,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.38 2006/07/14 14:52:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.39 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -92,8 +92,8 @@
 
 typedef struct SlruFlushData
 {
-   int         num_files;                      /* # files actually open */
-   int         fd[MAX_FLUSH_BUFFERS];          /* their FD's */
+   int         num_files;      /* # files actually open */
+   int         fd[MAX_FLUSH_BUFFERS];  /* their FD's */
    int         segno[MAX_FLUSH_BUFFERS];       /* their log seg#s */
 } SlruFlushData;
 
@@ -113,7 +113,7 @@ typedef struct SlruFlushData
  * page_lru_count entries to be "reset" to lower values than they should have,
  * in case a process is delayed while it executes this macro.  With care in
  * SlruSelectLRUPage(), this does little harm, and in any case the absolute
- * worst possible consequence is a nonoptimal choice of page to evict.  The
+ * worst possible consequence is a nonoptimal choice of page to evict. The
  * gain from allowing concurrent reads of SLRU pages seems worth it.
  */
 #define SlruRecentlyUsed(shared, slotno)   \
@@ -158,13 +158,13 @@ SimpleLruShmemSize(int nslots)
 
    /* we assume nslots isn't so large as to risk overflow */
    sz = MAXALIGN(sizeof(SlruSharedData));
-   sz += MAXALIGN(nslots * sizeof(char *));            /* page_buffer[] */
+   sz += MAXALIGN(nslots * sizeof(char *));    /* page_buffer[] */
    sz += MAXALIGN(nslots * sizeof(SlruPageStatus));    /* page_status[] */
-   sz += MAXALIGN(nslots * sizeof(bool));              /* page_dirty[] */
-   sz += MAXALIGN(nslots * sizeof(int));               /* page_number[] */
-   sz += MAXALIGN(nslots * sizeof(int));               /* page_lru_count[] */
-   sz += MAXALIGN(nslots * sizeof(LWLockId));          /* buffer_locks[] */
-   
+   sz += MAXALIGN(nslots * sizeof(bool));      /* page_dirty[] */
+   sz += MAXALIGN(nslots * sizeof(int));       /* page_number[] */
+   sz += MAXALIGN(nslots * sizeof(int));       /* page_lru_count[] */
+   sz += MAXALIGN(nslots * sizeof(LWLockId));  /* buffer_locks[] */
+
    return BUFFERALIGN(sz) + BLCKSZ * nslots;
 }
 
@@ -653,9 +653,9 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
         * Easiest way to deal with that is to accept references to
         * nonexistent files here and in SlruPhysicalReadPage.)
         *
-        * Note: it is possible for more than one backend to be executing
-        * this code simultaneously for different pages of the same file.
-        * Hence, don't use O_EXCL or O_TRUNC or anything like that.
+        * Note: it is possible for more than one backend to be executing this
+        * code simultaneously for different pages of the same file. Hence,
+        * don't use O_EXCL or O_TRUNC or anything like that.
         */
        SlruFileName(ctl, path, segno);
        fd = BasicOpenFile(path, O_RDWR | O_CREAT | PG_BINARY,
@@ -759,22 +759,22 @@ SlruReportIOError(SlruCtl ctl, int pageno, TransactionId xid)
            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)));
+                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)));
+              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)));
+               errdetail("Could not write to file \"%s\" at offset %u: %m.",
+                         path, offset)));
            break;
        case SLRU_FSYNC_FAILED:
            ereport(ERROR,
index 6c37d097fc215cf8d3a8352daf773729ec6cf8ff..bd0b9b131e6ec25c049914812d1d588186121452 100644 (file)
@@ -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.23 2006/10/03 21:21:35 momjian Exp $
+ *     $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.24 2006/10/04 00:29:49 momjian Exp $
  *
  * NOTES
  *     Each global transaction is associated with a global transaction
@@ -1250,8 +1250,8 @@ RemoveTwoPhaseFile(TransactionId xid, bool giveWarning)
        if (errno != ENOENT || giveWarning)
            ereport(WARNING,
                    (errcode_for_file_access(),
-                  errmsg("could not remove twophase state file \"%s\": %m",
-                         path)));
+                    errmsg("could not remove twophase state file \"%s\": %m",
+                           path)));
 }
 
 /*
index 101f065489f37d70ddd810534332fee811abe9fe..04e9840cb5d9060e3db444c6939ca01514b98756 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.74 2006/09/26 17:21:39 alvherre Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.75 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -133,10 +133,10 @@ GetNewTransactionId(bool isSubXact)
    {
        /*
         * Use volatile pointer to prevent code rearrangement; other backends
-        * could be examining my subxids info concurrently, and we don't
-        * want them to see an invalid intermediate state, such as
-        * incrementing nxids before filling the array entry.  Note we are
-        * assuming that TransactionId and int fetch/store are atomic.
+        * could be examining my subxids info concurrently, and we don't want
+        * them to see an invalid intermediate state, such as incrementing
+        * nxids before filling the array entry.  Note we are assuming that
+        * TransactionId and int fetch/store are atomic.
         */
        volatile PGPROC *myproc = MyProc;
 
@@ -144,7 +144,7 @@ GetNewTransactionId(bool isSubXact)
            myproc->xid = xid;
        else
        {
-           int     nxids = myproc->subxids.nxids;
+           int         nxids = myproc->subxids.nxids;
 
            if (nxids < PGPROC_MAX_CACHED_SUBXIDS)
            {
@@ -196,7 +196,7 @@ SetTransactionIdLimit(TransactionId oldest_datminxid,
     * The place where we actually get into deep trouble is halfway around
     * from the oldest existing XID.  (This calculation is probably off by one
     * or two counts, because the special XIDs reduce the size of the loop a
-    * little bit.  But we throw in plenty of slop below, so it doesn't
+    * little bit.  But we throw in plenty of slop below, so it doesn't
     * matter.)
     */
    xidWrapLimit = oldest_datminxid + (MaxTransactionId >> 1);
index 6fda0ce1f970f6bd26369ab0598329f1bdb9f2f4..8e1724989cb4d2038c4bea29aba638637f6d4b23 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.226 2006/08/27 19:11:46 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.227 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1376,12 +1376,12 @@ StartTransaction(void)
 
    XactLockTableInsert(s->transactionId);
 
-   PG_TRACE1 (transaction__start, s->transactionId);
+   PG_TRACE1(transaction__start, s->transactionId);
 
    /*
-    * set transaction_timestamp() (a/k/a now()).  We want this to be the
-    * same as the first command's statement_timestamp(), so don't do a
-    * fresh GetCurrentTimestamp() call (which'd be expensive anyway).
+    * set transaction_timestamp() (a/k/a now()).  We want this to be the same
+    * as the first command's statement_timestamp(), so don't do a fresh
+    * GetCurrentTimestamp() call (which'd be expensive anyway).
     */
    xactStartTimestamp = stmtStartTimestamp;
 
@@ -1521,7 +1521,7 @@ CommitTransaction(void)
        LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
        MyProc->xid = InvalidTransactionId;
        MyProc->xmin = InvalidTransactionId;
-       MyProc->inVacuum = false;   /* must be cleared with xid/xmin */
+       MyProc->inVacuum = false;       /* must be cleared with xid/xmin */
 
        /* Clear the subtransaction-XID cache too while holding the lock */
        MyProc->subxids.nxids = 0;
@@ -1530,7 +1530,7 @@ CommitTransaction(void)
        LWLockRelease(ProcArrayLock);
    }
 
-   PG_TRACE1 (transaction__commit, s->transactionId);
+   PG_TRACE1(transaction__commit, s->transactionId);
 
    /*
     * This is all post-commit cleanup.  Note that if an error is raised here,
@@ -1921,7 +1921,7 @@ AbortTransaction(void)
        LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
        MyProc->xid = InvalidTransactionId;
        MyProc->xmin = InvalidTransactionId;
-       MyProc->inVacuum = false;   /* must be cleared with xid/xmin */
+       MyProc->inVacuum = false;       /* must be cleared with xid/xmin */
 
        /* Clear the subtransaction-XID cache too while holding the lock */
        MyProc->subxids.nxids = 0;
@@ -1930,7 +1930,7 @@ AbortTransaction(void)
        LWLockRelease(ProcArrayLock);
    }
 
-   PG_TRACE1 (transaction__abort, s->transactionId);
+   PG_TRACE1(transaction__abort, s->transactionId);
 
    /*
     * Post-abort cleanup.  See notes in CommitTransaction() concerning
@@ -4206,8 +4206,8 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
    int         i;
 
    appendStringInfo(buf, "%04u-%02u-%02u %02u:%02u:%02u",
-           tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
-           tm->tm_hour, tm->tm_min, tm->tm_sec);
+                    tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+                    tm->tm_hour, tm->tm_min, tm->tm_sec);
    if (xlrec->nrels > 0)
    {
        appendStringInfo(buf, "; rels:");
@@ -4216,7 +4216,7 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
            RelFileNode rnode = xlrec->xnodes[i];
 
            appendStringInfo(buf, " %u/%u/%u",
-                   rnode.spcNode, rnode.dbNode, rnode.relNode);
+                            rnode.spcNode, rnode.dbNode, rnode.relNode);
        }
    }
    if (xlrec->nsubxacts > 0)
@@ -4237,8 +4237,8 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
    int         i;
 
    appendStringInfo(buf, "%04u-%02u-%02u %02u:%02u:%02u",
-           tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
-           tm->tm_hour, tm->tm_min, tm->tm_sec);
+                    tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+                    tm->tm_hour, tm->tm_min, tm->tm_sec);
    if (xlrec->nrels > 0)
    {
        appendStringInfo(buf, "; rels:");
@@ -4247,7 +4247,7 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
            RelFileNode rnode = xlrec->xnodes[i];
 
            appendStringInfo(buf, " %u/%u/%u",
-                   rnode.spcNode, rnode.dbNode, rnode.relNode);
+                            rnode.spcNode, rnode.dbNode, rnode.relNode);
        }
    }
    if (xlrec->nsubxacts > 0)
@@ -4264,7 +4264,7 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
 void
 xact_desc(StringInfo buf, uint8 xl_info, char *rec)
 {
-   uint8           info = xl_info & ~XLR_INFO_MASK;
+   uint8       info = xl_info & ~XLR_INFO_MASK;
 
    if (info == XLOG_XACT_COMMIT)
    {
index 16fb6b5e5e8ea61b85b895dd37c4069a16bc86f3..7b5780b66dabae12fede06dc8c4b471612e28e97 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.249 2006/08/21 16:16:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.250 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -349,9 +349,9 @@ typedef struct XLogCtlInsert
  */
 typedef struct XLogCtlWrite
 {
-   XLogwrtResult LogwrtResult;     /* current value of LogwrtResult */
-   int         curridx;            /* cache index of next block to write */
-   time_t      lastSegSwitchTime;  /* time of last xlog segment switch */
+   XLogwrtResult LogwrtResult; /* current value of LogwrtResult */
+   int         curridx;        /* cache index of next block to write */
+   time_t      lastSegSwitchTime;      /* time of last xlog segment switch */
 } XLogCtlWrite;
 
 /*
@@ -481,7 +481,7 @@ static bool InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath,
                       bool use_lock);
 static int XLogFileOpen(uint32 log, uint32 seg);
 static int XLogFileRead(uint32 log, uint32 seg, int emode);
-static void    XLogFileClose(void);
+static void XLogFileClose(void);
 static bool RestoreArchivedFile(char *path, const char *xlogfname,
                    const char *recovername, off_t expectedSize);
 static int PreallocXlogFiles(XLogRecPtr endptr);
@@ -506,7 +506,7 @@ static void issue_xlog_fsync(void);
 static void xlog_outrec(StringInfo buf, XLogRecord *record);
 #endif
 static bool read_backup_label(XLogRecPtr *checkPointLoc,
-                             XLogRecPtr *minRecoveryLoc);
+                 XLogRecPtr *minRecoveryLoc);
 static void rm_redo_error_callback(void *arg);
 
 
@@ -697,9 +697,9 @@ begin:;
    /*
     * NOTE: We disallow len == 0 because it provides a useful bit of extra
     * error checking in ReadRecord.  This means that all callers of
-    * XLogInsert must supply at least some not-in-a-buffer data.  However,
-    * we make an exception for XLOG SWITCH records because we don't want
-    * them to ever cross a segment boundary.
+    * XLogInsert must supply at least some not-in-a-buffer data.  However, we
+    * make an exception for XLOG SWITCH records because we don't want them to
+    * ever cross a segment boundary.
     */
    if (len == 0 && !isLogSwitch)
        elog(PANIC, "invalid xlog record length %u", len);
@@ -752,8 +752,8 @@ begin:;
     * checkpoint, so it's better to be slow in this case and fast otherwise.
     *
     * If we aren't doing full-page writes then RedoRecPtr doesn't actually
-    * affect the contents of the XLOG record, so we'll update our local
-    * copy but not force a recomputation.
+    * affect the contents of the XLOG record, so we'll update our local copy
+    * but not force a recomputation.
     */
    if (!XLByteEQ(RedoRecPtr, Insert->RedoRecPtr))
    {
@@ -782,10 +782,10 @@ begin:;
    }
 
    /*
-    * Also check to see if forcePageWrites was just turned on; if we
-    * weren't already doing full-page writes then go back and recompute.
-    * (If it was just turned off, we could recompute the record without
-    * full pages, but we choose not to bother.)
+    * Also check to see if forcePageWrites was just turned on; if we weren't
+    * already doing full-page writes then go back and recompute. (If it was
+    * just turned off, we could recompute the record without full pages, but
+    * we choose not to bother.)
     */
    if (Insert->forcePageWrites && !doPageWrites)
    {
@@ -870,11 +870,11 @@ begin:;
    INSERT_RECPTR(RecPtr, Insert, curridx);
 
    /*
-    * If the record is an XLOG_SWITCH, and we are exactly at the start
-    * of a segment, we need not insert it (and don't want to because
-    * we'd like consecutive switch requests to be no-ops).  Instead,
-    * make sure everything is written and flushed through the end of
-    * the prior segment, and return the prior segment's end address.
+    * If the record is an XLOG_SWITCH, and we are exactly at the start of a
+    * segment, we need not insert it (and don't want to because we'd like
+    * consecutive switch requests to be no-ops).  Instead, make sure
+    * everything is written and flushed through the end of the prior segment,
+    * and return the prior segment's end address.
     */
    if (isLogSwitch &&
        (RecPtr.xrecoff % XLogSegSize) == SizeOfXLogLongPHD)
@@ -926,7 +926,7 @@ begin:;
 #ifdef WAL_DEBUG
    if (XLOG_DEBUG)
    {
-       StringInfoData  buf;
+       StringInfoData buf;
 
        initStringInfo(&buf);
        appendStringInfo(&buf, "INSERT @ %X/%X: ",
@@ -1019,8 +1019,8 @@ begin:;
        LWLockAcquire(WALWriteLock, LW_EXCLUSIVE);
 
        /*
-        * Flush through the end of the page containing XLOG_SWITCH,
-        * and perform end-of-segment actions (eg, notifying archiver).
+        * Flush through the end of the page containing XLOG_SWITCH, and
+        * perform end-of-segment actions (eg, notifying archiver).
         */
        WriteRqst = XLogCtl->xlblocks[curridx];
        FlushRqst.Write = WriteRqst;
@@ -1667,8 +1667,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible, bool xlog_switch)
             * switch.
             *
             * This is also the right place to notify the Archiver that the
-            * segment is ready to copy to archival storage, and to update
-            * the timer for archive_timeout.
+            * segment is ready to copy to archival storage, and to update the
+            * timer for archive_timeout.
             */
            if (finishing_seg || (xlog_switch && last_iteration))
            {
@@ -2300,36 +2300,35 @@ XLogFileClose(void)
    Assert(openLogFile >= 0);
 
    /*
-    * posix_fadvise is problematic on many platforms: on older x86 Linux
-    * it just dumps core, and there are reports of problems on PPC platforms
-    * as well.  The following is therefore disabled for the time being.
-    * We could consider some kind of configure test to see if it's safe to
-    * use, but since we lack hard evidence that there's any useful performance
-    * gain to be had, spending time on that seems unprofitable for now.
+    * posix_fadvise is problematic on many platforms: on older x86 Linux it
+    * just dumps core, and there are reports of problems on PPC platforms as
+    * well.  The following is therefore disabled for the time being. We could
+    * consider some kind of configure test to see if it's safe to use, but
+    * since we lack hard evidence that there's any useful performance gain to
+    * be had, spending time on that seems unprofitable for now.
     */
 #ifdef NOT_USED
 
    /*
     * WAL segment files will not be re-read in normal operation, so we advise
-    * OS to release any cached pages.  But do not do so if WAL archiving is
+    * OS to release any cached pages.  But do not do so if WAL archiving is
     * active, because archiver process could use the cache to read the WAL
     * segment.
     *
-    * While O_DIRECT works for O_SYNC, posix_fadvise() works for fsync()
-    * and O_SYNC, and some platforms only have posix_fadvise().
+    * While O_DIRECT works for O_SYNC, posix_fadvise() works for fsync() and
+    * O_SYNC, and some platforms only have posix_fadvise().
     */
 #if defined(HAVE_DECL_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
    if (!XLogArchivingActive())
        posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED);
 #endif
-
-#endif /* NOT_USED */
+#endif   /* NOT_USED */
 
    if (close(openLogFile))
        ereport(PANIC,
-           (errcode_for_file_access(),
-           errmsg("could not close log file %u, segment %u: %m",
-                  openLogId, openLogSeg)));
+               (errcode_for_file_access(),
+                errmsg("could not close log file %u, segment %u: %m",
+                       openLogId, openLogSeg)));
    openLogFile = -1;
 }
 
@@ -2978,8 +2977,8 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
 got_record:;
 
    /*
-    * xl_len == 0 is bad data for everything except XLOG SWITCH, where
-    * it is required.
+    * xl_len == 0 is bad data for everything except XLOG SWITCH, where it is
+    * required.
     */
    if (record->xl_rmid == RM_XLOG_ID && record->xl_info == XLOG_SWITCH)
    {
@@ -3168,6 +3167,7 @@ got_record:;
    EndRecPtr.xrecoff = RecPtr->xrecoff + MAXALIGN(total_len);
    ReadRecPtr = *RecPtr;
    memcpy(buffer, record, total_len);
+
    /*
     * Special processing if it's an XLOG SWITCH record
     */
@@ -3177,10 +3177,11 @@ got_record:;
        EndRecPtr.xrecoff += XLogSegSize - 1;
        EndRecPtr.xrecoff -= EndRecPtr.xrecoff % XLogSegSize;
        nextRecord = NULL;      /* definitely not on same page */
+
        /*
-        * Pretend that readBuf contains the last page of the segment.
-        * This is just to avoid Assert failure in StartupXLOG if XLOG
-        * ends with this segment.
+        * Pretend that readBuf contains the last page of the segment. This is
+        * just to avoid Assert failure in StartupXLOG if XLOG ends with this
+        * segment.
         */
        readOff = XLogSegSize - XLOG_BLCKSZ;
    }
@@ -3661,7 +3662,7 @@ static void
 WriteControlFile(void)
 {
    int         fd;
-   char        buffer[PG_CONTROL_SIZE]; /* need not be aligned */
+   char        buffer[PG_CONTROL_SIZE];        /* need not be aligned */
    char       *localeptr;
 
    /*
@@ -3846,9 +3847,9 @@ ReadControlFile(void)
    if (ControlFile->xlog_blcksz != XLOG_BLCKSZ)
        ereport(FATAL,
                (errmsg("database files are incompatible with server"),
-            errdetail("The database cluster was initialized with XLOG_BLCKSZ %d,"
-                      " but the server was compiled with XLOG_BLCKSZ %d.",
-                      ControlFile->xlog_blcksz, XLOG_BLCKSZ),
+       errdetail("The database cluster was initialized with XLOG_BLCKSZ %d,"
+                 " but the server was compiled with XLOG_BLCKSZ %d.",
+                 ControlFile->xlog_blcksz, XLOG_BLCKSZ),
                 errhint("It looks like you need to recompile or initdb.")));
    if (ControlFile->xlog_seg_size != XLOG_SEG_SIZE)
        ereport(FATAL,
@@ -4027,7 +4028,7 @@ XLOGShmemInit(void)
     * Do basic initialization of XLogCtl shared data. (StartupXLOG will fill
     * in additional info.)
     */
-   XLogCtl->XLogCacheByte = (Size) XLOG_BLCKSZ * XLOGbuffers;
+   XLogCtl->XLogCacheByte = (Size) XLOG_BLCKSZ *XLOGbuffers;
 
    XLogCtl->XLogCacheBlck = XLOGbuffers - 1;
    XLogCtl->Insert.currpage = (XLogPageHeader) (XLogCtl->pages);
@@ -4649,10 +4650,10 @@ StartupXLOG(void)
                    " you will have to use the last backup for recovery.")));
    else if (ControlFile->state == DB_IN_ARCHIVE_RECOVERY)
        ereport(LOG,
-          (errmsg("database system was interrupted while in recovery at log time %s",
-                  str_time(ControlFile->checkPointCopy.time)),
-           errhint("If this has occurred more than once some data may be corrupted"
-                   " and you may need to choose an earlier recovery target.")));
+               (errmsg("database system was interrupted while in recovery at log time %s",
+                       str_time(ControlFile->checkPointCopy.time)),
+                errhint("If this has occurred more than once some data may be corrupted"
+               " and you may need to choose an earlier recovery target.")));
    else if (ControlFile->state == DB_IN_PRODUCTION)
        ereport(LOG,
                (errmsg("database system was interrupted at %s",
@@ -4812,10 +4813,10 @@ StartupXLOG(void)
        int         rmid;
 
        /*
-        * Update pg_control to show that we are recovering and to show
-        * the selected checkpoint as the place we are starting from.
-        * We also mark pg_control with any minimum recovery stop point
-        * obtained from a backup history file.
+        * Update pg_control to show that we are recovering and to show the
+        * selected checkpoint as the place we are starting from. We also mark
+        * pg_control with any minimum recovery stop point obtained from a
+        * backup history file.
         */
        if (InArchiveRecovery)
        {
@@ -4839,12 +4840,12 @@ StartupXLOG(void)
        UpdateControlFile();
 
        /*
-        * If there was a backup label file, it's done its job and the
-        * info has now been propagated into pg_control.  We must get rid of
-        * the label file so that if we crash during recovery, we'll pick up
-        * at the latest recovery restartpoint instead of going all the way
-        * back to the backup start point.  It seems prudent though to just
-        * rename the file out of the way rather than delete it completely.
+        * If there was a backup label file, it's done its job and the info
+        * has now been propagated into pg_control.  We must get rid of the
+        * label file so that if we crash during recovery, we'll pick up at
+        * the latest recovery restartpoint instead of going all the way back
+        * to the backup start point.  It seems prudent though to just rename
+        * the file out of the way rather than delete it completely.
         */
        if (haveBackupLabel)
        {
@@ -4884,7 +4885,7 @@ StartupXLOG(void)
        {
            bool        recoveryContinue = true;
            bool        recoveryApply = true;
-           ErrorContextCallback    errcontext;
+           ErrorContextCallback errcontext;
 
            InRedo = true;
            ereport(LOG,
@@ -4899,17 +4900,17 @@ StartupXLOG(void)
 #ifdef WAL_DEBUG
                if (XLOG_DEBUG)
                {
-                   StringInfoData  buf;
+                   StringInfoData buf;
 
                    initStringInfo(&buf);
                    appendStringInfo(&buf, "REDO @ %X/%X; LSN %X/%X: ",
-                           ReadRecPtr.xlogid, ReadRecPtr.xrecoff,
-                           EndRecPtr.xlogid, EndRecPtr.xrecoff);
+                                    ReadRecPtr.xlogid, ReadRecPtr.xrecoff,
+                                    EndRecPtr.xlogid, EndRecPtr.xrecoff);
                    xlog_outrec(&buf, record);
                    appendStringInfo(&buf, " - ");
                    RmgrTable[record->xl_rmid].rm_desc(&buf,
                                                       record->xl_info,
-                                                      XLogRecGetData(record));
+                                                    XLogRecGetData(record));
                    elog(LOG, "%s", buf.data);
                    pfree(buf.data);
                }
@@ -5383,9 +5384,9 @@ GetRecentNextXid(void)
 void
 GetNextXidAndEpoch(TransactionId *xid, uint32 *epoch)
 {
-   uint32          ckptXidEpoch;
-   TransactionId   ckptXid;
-   TransactionId   nextXid;
+   uint32      ckptXidEpoch;
+   TransactionId ckptXid;
+   TransactionId nextXid;
 
    /* Must read checkpoint info first, else have race condition */
    {
@@ -5718,7 +5719,7 @@ CheckPointGuts(XLogRecPtr checkPointRedo)
    CheckPointCLOG();
    CheckPointSUBTRANS();
    CheckPointMultiXact();
-   FlushBufferPool();     /* performs all required fsyncs */
+   FlushBufferPool();          /* performs all required fsyncs */
    /* We deliberately delay 2PC checkpointing as long as possible */
    CheckPointTwoPhase(checkPointRedo);
 }
@@ -5735,12 +5736,12 @@ CheckPointGuts(XLogRecPtr checkPointRedo)
 static void
 RecoveryRestartPoint(const CheckPoint *checkPoint)
 {
-   int     elapsed_secs;
-   int     rmid;
+   int         elapsed_secs;
+   int         rmid;
 
    /*
-    * Do nothing if the elapsed time since the last restartpoint is less
-    * than half of checkpoint_timeout.  (We use a value less than
+    * Do nothing if the elapsed time since the last restartpoint is less than
+    * half of checkpoint_timeout.  (We use a value less than
     * checkpoint_timeout so that variations in the timing of checkpoints on
     * the master, or speed of transmission of WAL segments to a slave, won't
     * make the slave skip a restartpoint once it's synced with the master.)
@@ -5770,9 +5771,9 @@ RecoveryRestartPoint(const CheckPoint *checkPoint)
    CheckPointGuts(checkPoint->redo);
 
    /*
-    * Update pg_control so that any subsequent crash will restart from
-    * this checkpoint.  Note: ReadRecPtr gives the XLOG address of the
-    * checkpoint record itself.
+    * Update pg_control so that any subsequent crash will restart from this
+    * checkpoint.  Note: ReadRecPtr gives the XLOG address of the checkpoint
+    * record itself.
     */
    ControlFile->prevCheckPoint = ControlFile->checkPoint;
    ControlFile->checkPoint = ReadRecPtr;
@@ -5926,7 +5927,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
 void
 xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
 {
-   uint8           info = xl_info & ~XLR_INFO_MASK;
+   uint8       info = xl_info & ~XLR_INFO_MASK;
 
    if (info == XLOG_CHECKPOINT_SHUTDOWN ||
        info == XLOG_CHECKPOINT_ONLINE)
@@ -5934,15 +5935,15 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
        CheckPoint *checkpoint = (CheckPoint *) rec;
 
        appendStringInfo(buf, "checkpoint: redo %X/%X; undo %X/%X; "
-               "tli %u; xid %u/%u; oid %u; multi %u; offset %u; %s",
-               checkpoint->redo.xlogid, checkpoint->redo.xrecoff,
-               checkpoint->undo.xlogid, checkpoint->undo.xrecoff,
-               checkpoint->ThisTimeLineID,
-               checkpoint->nextXidEpoch, checkpoint->nextXid,
-               checkpoint->nextOid,
-               checkpoint->nextMulti,
-               checkpoint->nextMultiOffset,
-               (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
+                        "tli %u; xid %u/%u; oid %u; multi %u; offset %u; %s",
+                        checkpoint->redo.xlogid, checkpoint->redo.xrecoff,
+                        checkpoint->undo.xlogid, checkpoint->undo.xrecoff,
+                        checkpoint->ThisTimeLineID,
+                        checkpoint->nextXidEpoch, checkpoint->nextXid,
+                        checkpoint->nextOid,
+                        checkpoint->nextMulti,
+                        checkpoint->nextMultiOffset,
+                (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
    }
    else if (info == XLOG_NEXTOID)
    {
@@ -5973,7 +5974,7 @@ xlog_outrec(StringInfo buf, XLogRecord *record)
    for (i = 0; i < XLR_MAX_BKP_BLOCKS; i++)
    {
        if (record->xl_info & XLR_SET_BKP_BLOCK(i))
-           appendStringInfo(buf, "; bkpb%d", i+1);
+           appendStringInfo(buf, "; bkpb%d", i + 1);
    }
 
    appendStringInfo(buf, ": %s", RmgrTable[record->xl_rmid].rm_name);
@@ -6142,18 +6143,18 @@ pg_start_backup(PG_FUNCTION_ARGS)
     * Mark backup active in shared memory.  We must do full-page WAL writes
     * during an on-line backup even if not doing so at other times, because
     * it's quite possible for the backup dump to obtain a "torn" (partially
-    * written) copy of a database page if it reads the page concurrently
-    * with our write to the same page.  This can be fixed as long as the
-    * first write to the page in the WAL sequence is a full-page write.
-    * Hence, we turn on forcePageWrites and then force a CHECKPOINT, to
-    * ensure there are no dirty pages in shared memory that might get
-    * dumped while the backup is in progress without having a corresponding
-    * WAL record.  (Once the backup is complete, we need not force full-page
-    * writes anymore, since we expect that any pages not modified during
-    * the backup interval must have been correctly captured by the backup.)
+    * written) copy of a database page if it reads the page concurrently with
+    * our write to the same page.  This can be fixed as long as the first
+    * write to the page in the WAL sequence is a full-page write. Hence, we
+    * turn on forcePageWrites and then force a CHECKPOINT, to ensure there
+    * are no dirty pages in shared memory that might get dumped while the
+    * backup is in progress without having a corresponding WAL record.  (Once
+    * the backup is complete, we need not force full-page writes anymore,
+    * since we expect that any pages not modified during the backup interval
+    * must have been correctly captured by the backup.)
     *
-    * We must hold WALInsertLock to change the value of forcePageWrites,
-    * to ensure adequate interlocking against XLogInsert().
+    * We must hold WALInsertLock to change the value of forcePageWrites, to
+    * ensure adequate interlocking against XLogInsert().
     */
    LWLockAcquire(WALInsertLock, LW_EXCLUSIVE);
    if (XLogCtl->Insert.forcePageWrites)
@@ -6171,7 +6172,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
    PG_TRY();
    {
        /*
-        * Force a CHECKPOINT.  Aside from being necessary to prevent torn
+        * Force a CHECKPOINT.  Aside from being necessary to prevent torn
         * page problems, this guarantees that two successive backup runs will
         * have different checkpoint positions and hence different history
         * file names, even if nothing happened in between.
@@ -6303,10 +6304,9 @@ pg_stop_backup(PG_FUNCTION_ARGS)
    LWLockRelease(WALInsertLock);
 
    /*
-    * Force a switch to a new xlog segment file, so that the backup
-    * is valid as soon as archiver moves out the current segment file.
-    * We'll report the end address of the XLOG SWITCH record as the backup
-    * stopping point.
+    * Force a switch to a new xlog segment file, so that the backup is valid
+    * as soon as archiver moves out the current segment file. We'll report
+    * the end address of the XLOG SWITCH record as the backup stopping point.
     */
    stoppoint = RequestXLogSwitch();
 
@@ -6392,9 +6392,9 @@ pg_stop_backup(PG_FUNCTION_ARGS)
                        BACKUP_LABEL_FILE)));
 
    /*
-    * Clean out any no-longer-needed history files.  As a side effect,
-    * this will post a .ready file for the newly created history file,
-    * notifying the archiver that history file may be archived immediately.
+    * Clean out any no-longer-needed history files.  As a side effect, this
+    * will post a .ready file for the newly created history file, notifying
+    * the archiver that history file may be archived immediately.
     */
    CleanupBackupHistory();
 
@@ -6415,7 +6415,7 @@ Datum
 pg_switch_xlog(PG_FUNCTION_ARGS)
 {
    text       *result;
-   XLogRecPtr switchpoint;
+   XLogRecPtr  switchpoint;
    char        location[MAXFNAMELEN];
 
    if (!superuser())
@@ -6514,17 +6514,17 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
    uint32      xrecoff;
    XLogRecPtr  locationpoint;
    char        xlogfilename[MAXFNAMELEN];
-   Datum       values[2];
-   bool        isnull[2];
-   TupleDesc   resultTupleDesc;
-   HeapTuple   resultHeapTuple;
-   Datum       result;
+   Datum       values[2];
+   bool        isnull[2];
+   TupleDesc   resultTupleDesc;
+   HeapTuple   resultHeapTuple;
+   Datum       result;
 
    /*
     * Read input and parse
     */
    locationstr = DatumGetCString(DirectFunctionCall1(textout,
-                                               PointerGetDatum(location)));
+                                                PointerGetDatum(location)));
 
    if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
        ereport(ERROR,
@@ -6536,8 +6536,8 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
    locationpoint.xrecoff = uxrecoff;
 
    /*
-    * Construct a tuple descriptor for the result row.  This must match
-    * this function's pg_proc entry!
+    * Construct a tuple descriptor for the result row.  This must match this
+    * function's pg_proc entry!
     */
    resultTupleDesc = CreateTemplateTupleDesc(2, false);
    TupleDescInitEntry(resultTupleDesc, (AttrNumber) 1, "file_name",
@@ -6593,7 +6593,7 @@ pg_xlogfile_name(PG_FUNCTION_ARGS)
    char        xlogfilename[MAXFNAMELEN];
 
    locationstr = DatumGetCString(DirectFunctionCall1(textout,
-                                               PointerGetDatum(location)));
+                                                PointerGetDatum(location)));
 
    if (sscanf(locationstr, "%X/%X", &uxlogid, &uxrecoff) != 2)
        ereport(ERROR,
@@ -6608,7 +6608,7 @@ pg_xlogfile_name(PG_FUNCTION_ARGS)
    XLogFileName(xlogfilename, ThisTimeLineID, xlogid, xlogseg);
 
    result = DatumGetTextP(DirectFunctionCall1(textin,
-                                              CStringGetDatum(xlogfilename)));
+                                            CStringGetDatum(xlogfilename)));
    PG_RETURN_TEXT_P(result);
 }
 
@@ -6734,8 +6734,8 @@ read_backup_label(XLogRecPtr *checkPointLoc, XLogRecPtr *minRecoveryLoc)
 static void
 rm_redo_error_callback(void *arg)
 {
-   XLogRecord      *record = (XLogRecord *) arg;
-   StringInfoData   buf;
+   XLogRecord *record = (XLogRecord *) arg;
+   StringInfoData buf;
 
    initStringInfo(&buf);
    RmgrTable[record->xl_rmid].rm_desc(&buf,
index d7fb9359dec3f1b19a3ac78bdb9d28529acfec6e..e1d3b70001165bd6fdfbf3347093641b05ab10a9 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.47 2006/07/14 14:52:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.48 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -172,8 +172,8 @@ XLogCheckInvalidPages(void)
    hash_seq_init(&status, invalid_page_tab);
 
    /*
-    * Our strategy is to emit WARNING messages for all remaining entries
-    * and only PANIC after we've dumped all the available info.
+    * Our strategy is to emit WARNING messages for all remaining entries and
+    * only PANIC after we've dumped all the available info.
     */
    while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
    {
@@ -255,7 +255,7 @@ XLogReadBuffer(Relation reln, BlockNumber blkno, bool init)
    if (!init)
    {
        /* check that page has been initialized */
-       Page    page = (Page) BufferGetPage(buffer);
+       Page        page = (Page) BufferGetPage(buffer);
 
        if (PageIsNew((PageHeader) page))
        {
index 06d8a5ca4fc056de949b3e89adb53eb12149b726..70b9172cd7fcd8649d4da0aa62f9f73b4a91e0a1 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.224 2006/08/15 22:36:17 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.225 2006/10/04 00:29:49 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -381,8 +381,8 @@ BootstrapMain(int argc, char *argv[])
 
    /*
     * When we are 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.
+    * InitPostgres pushups, but there are a couple of things that need to get
+    * lit up even in a dummy process.
     */
    if (IsUnderPostmaster)
    {
@@ -421,6 +421,7 @@ BootstrapMain(int argc, char *argv[])
        case BS_XLOG_STARTUP:
            bootstrap_signals();
            StartupXLOG();
+
            /*
             * These next two functions don't consider themselves critical,
             * but we'd best PANIC anyway if they fail.
@@ -1229,7 +1230,7 @@ AddStr(char *str, int strlength, int mderef)
  *     We postpone actually building the indexes until just before we're
  *     finished with initialization, however.  This is because the indexes
  *     themselves have catalog entries, and those have to be included in the
- *     indexes on those catalogs.  Doing it in two phases is the simplest
+ *     indexes on those catalogs.  Doing it in two phases is the simplest
  *     way of making sure the indexes have the right contents at the end.
  */
 void
index e74c9b4410e7c0f1a427b3b16b679fda83eb7b4b..27ca6e011aa37bca5c772de6f88a1b5b2de29105 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.131 2006/09/05 21:08:35 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.132 2006/10/04 00:29:50 momjian Exp $
  *
  * NOTES
  *   See acl.h.
@@ -53,9 +53,9 @@ static List *objectNamesToOids(GrantObjectType objtype, List *objnames);
 static AclMode string_to_privilege(const char *privname);
 static const char *privilege_to_string(AclMode privilege);
 static AclMode restrict_and_check_grant(bool is_grant, AclMode avail_goptions,
-                                       bool all_privs, AclMode privileges,
-                                       Oid objectId, Oid grantorId,
-                                       AclObjectKind objkind, char *objname);
+                        bool all_privs, AclMode privileges,
+                        Oid objectId, Oid grantorId,
+                        AclObjectKind objkind, char *objname);
 static AclMode pg_aclmask(AclObjectKind objkind, Oid table_oid, Oid roleid,
           AclMode mask, AclMaskHow how);
 
@@ -156,8 +156,8 @@ restrict_and_check_grant(bool is_grant, AclMode avail_goptions, bool all_privs,
                         AclMode privileges, Oid objectId, Oid grantorId,
                         AclObjectKind objkind, char *objname)
 {
-   AclMode this_privileges;
-   AclMode whole_mask;
+   AclMode     this_privileges;
+   AclMode     whole_mask;
 
    switch (objkind)
    {
@@ -189,9 +189,9 @@ restrict_and_check_grant(bool is_grant, AclMode avail_goptions, bool all_privs,
    }
 
    /*
-    * 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.
+    * 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.
     */
    if (avail_goptions == ACL_NO_RIGHTS)
    {
@@ -203,11 +203,10 @@ restrict_and_check_grant(bool is_grant, AclMode avail_goptions, bool all_privs,
 
    /*
     * 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.)
+    * 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 (is_grant)
@@ -215,18 +214,18 @@ restrict_and_check_grant(bool is_grant, AclMode avail_goptions, bool all_privs,
        if (this_privileges == 0)
            ereport(WARNING,
                    (errcode(ERRCODE_WARNING_PRIVILEGE_NOT_GRANTED),
-                    errmsg("no privileges were granted for \"%s\"", objname)));
+                 errmsg("no privileges were granted for \"%s\"", objname)));
        else if (!all_privs && this_privileges != privileges)
            ereport(WARNING,
                    (errcode(ERRCODE_WARNING_PRIVILEGE_NOT_GRANTED),
-                    errmsg("not all privileges were granted for \"%s\"", objname)));
+            errmsg("not all privileges were granted for \"%s\"", objname)));
    }
    else
    {
        if (this_privileges == 0)
            ereport(WARNING,
                    (errcode(ERRCODE_WARNING_PRIVILEGE_NOT_REVOKED),
-                    errmsg("no privileges could be revoked for \"%s\"", objname)));
+             errmsg("no privileges could be revoked for \"%s\"", objname)));
        else if (!all_privs && this_privileges != privileges)
            ereport(WARNING,
                    (errcode(ERRCODE_WARNING_PRIVILEGE_NOT_REVOKED),
@@ -285,11 +284,11 @@ ExecuteGrantStmt(GrantStmt *stmt)
     */
    switch (stmt->objtype)
    {
-       /*
-        *  Because this might be a sequence, we test both relation
-        *  and sequence bits, and later do a more limited test
-        *  when we know the object type.
-        */
+           /*
+            * Because this might be a sequence, we test both relation and
+            * sequence bits, and later do a more limited test when we know
+            * the object type.
+            */
        case ACL_OBJECT_RELATION:
            all_privileges = ACL_ALL_RIGHTS_RELATION | ACL_ALL_RIGHTS_SEQUENCE;
            errormsg = _("invalid privilege type %s for relation");
@@ -329,6 +328,7 @@ ExecuteGrantStmt(GrantStmt *stmt)
    if (stmt->privileges == NIL)
    {
        istmt.all_privs = true;
+
        /*
         * will be turned into ACL_ALL_RIGHTS_* by the internal routines
         * depending on the object type
@@ -595,28 +595,28 @@ ExecGrant_Relation(InternalGrant *istmt)
        }
        else
            this_privileges = istmt->privileges;
-       
+
        /*
-        *  The GRANT TABLE syntax can be used for sequences and
-        *  non-sequences, so we have to look at the relkind to
-        *  determine the supported permissions.  The OR of
-        *  table and sequence permissions were already checked.
+        * The GRANT TABLE syntax can be used for sequences and non-sequences,
+        * so we have to look at the relkind to determine the supported
+        * permissions.  The OR of table and sequence permissions were already
+        * checked.
         */
        if (istmt->objtype == ACL_OBJECT_RELATION)
        {
            if (pg_class_tuple->relkind == RELKIND_SEQUENCE)
            {
                /*
-                *  For backward compatibility, throw just a warning
-                *  for invalid sequence permissions when using the
-                *  non-sequence GRANT syntax is used.
+                * For backward compatibility, throw just a warning for
+                * invalid sequence permissions when using the non-sequence
+                * GRANT syntax is used.
                 */
                if (this_privileges & ~((AclMode) ACL_ALL_RIGHTS_SEQUENCE))
                {
                    /*
-                    *  Mention the object name because the user needs to
-                    *  know which operations succeeded.  This is required
-                    *  because WARNING allows the command to continue.
+                    * Mention the object name because the user needs to know
+                    * which operations succeeded.  This is required because
+                    * WARNING allows the command to continue.
                     */
                    ereport(WARNING,
                            (errcode(ERRCODE_INVALID_GRANT_OPERATION),
@@ -628,15 +628,16 @@ ExecGrant_Relation(InternalGrant *istmt)
            else
            {
                if (this_privileges & ~((AclMode) ACL_ALL_RIGHTS_RELATION))
+
                    /*
-                    *  USAGE is the only permission supported by sequences
-                    *  but not by non-sequences.  Don't mention the object
-                    *  name because we didn't in the combined TABLE |
-                    *  SEQUENCE check.
+                    * USAGE is the only permission supported by sequences but
+                    * not by non-sequences.  Don't mention the object name
+                    * because we didn't in the combined TABLE | SEQUENCE
+                    * check.
                     */
                    ereport(ERROR,
                            (errcode(ERRCODE_INVALID_GRANT_OPERATION),
-                            errmsg("invalid privilege type USAGE for table")));
+                         errmsg("invalid privilege type USAGE for table")));
            }
        }
 
@@ -660,15 +661,15 @@ ExecGrant_Relation(InternalGrant *istmt)
                            &grantorId, &avail_goptions);
 
        /*
-        * Restrict the privileges to what we can actually grant, and emit
-        * the standards-mandated warning and error messages.
+        * Restrict the privileges to what we can actually grant, and emit the
+        * standards-mandated warning and error messages.
         */
        this_privileges =
            restrict_and_check_grant(istmt->is_grant, avail_goptions,
                                     istmt->all_privs, this_privileges,
                                     relOid, grantorId,
-                                    pg_class_tuple->relkind == RELKIND_SEQUENCE
-                                       ? ACL_KIND_SEQUENCE : ACL_KIND_CLASS,
+                                 pg_class_tuple->relkind == RELKIND_SEQUENCE
+                                    ? ACL_KIND_SEQUENCE : ACL_KIND_CLASS,
                                     NameStr(pg_class_tuple->relname));
 
        /*
@@ -777,8 +778,8 @@ ExecGrant_Database(InternalGrant *istmt)
                            &grantorId, &avail_goptions);
 
        /*
-        * Restrict the privileges to what we can actually grant, and emit
-        * the standards-mandated warning and error messages.
+        * Restrict the privileges to what we can actually grant, and emit the
+        * standards-mandated warning and error messages.
         */
        this_privileges =
            restrict_and_check_grant(istmt->is_grant, avail_goptions,
@@ -893,8 +894,8 @@ ExecGrant_Function(InternalGrant *istmt)
                            &grantorId, &avail_goptions);
 
        /*
-        * Restrict the privileges to what we can actually grant, and emit
-        * the standards-mandated warning and error messages.
+        * Restrict the privileges to what we can actually grant, and emit the
+        * standards-mandated warning and error messages.
         */
        this_privileges =
            restrict_and_check_grant(istmt->is_grant, avail_goptions,
@@ -1019,8 +1020,8 @@ ExecGrant_Language(InternalGrant *istmt)
                            &grantorId, &avail_goptions);
 
        /*
-        * Restrict the privileges to what we can actually grant, and emit
-        * the standards-mandated warning and error messages.
+        * Restrict the privileges to what we can actually grant, and emit the
+        * standards-mandated warning and error messages.
         */
        this_privileges =
            restrict_and_check_grant(istmt->is_grant, avail_goptions,
@@ -1136,8 +1137,8 @@ ExecGrant_Namespace(InternalGrant *istmt)
                            &grantorId, &avail_goptions);
 
        /*
-        * Restrict the privileges to what we can actually grant, and emit
-        * the standards-mandated warning and error messages.
+        * Restrict the privileges to what we can actually grant, and emit the
+        * standards-mandated warning and error messages.
         */
        this_privileges =
            restrict_and_check_grant(istmt->is_grant, avail_goptions,
@@ -1259,8 +1260,8 @@ ExecGrant_Tablespace(InternalGrant *istmt)
                            &grantorId, &avail_goptions);
 
        /*
-        * Restrict the privileges to what we can actually grant, and emit
-        * the standards-mandated warning and error messages.
+        * Restrict the privileges to what we can actually grant, and emit the
+        * standards-mandated warning and error messages.
         */
        this_privileges =
            restrict_and_check_grant(istmt->is_grant, avail_goptions,
@@ -1565,7 +1566,7 @@ pg_class_aclmask(Oid table_oid, Oid roleid,
     *
     * 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
-    * themselves.  ACL_USAGE is if we ever have system sequences.
+    * themselves.  ACL_USAGE is if we ever have system sequences.
     */
    if ((mask & (ACL_INSERT | ACL_UPDATE | ACL_DELETE | ACL_USAGE)) &&
        IsSystemClass(classForm) &&
@@ -1602,7 +1603,7 @@ pg_class_aclmask(Oid table_oid, Oid roleid,
    {
        /* No ACL, so build default ACL */
        acl = acldefault(classForm->relkind == RELKIND_SEQUENCE ?
-                           ACL_OBJECT_SEQUENCE : ACL_OBJECT_RELATION,
+                        ACL_OBJECT_SEQUENCE : ACL_OBJECT_RELATION,
                         ownerId);
        aclDatum = (Datum) 0;
    }
index 5d99acafc95c207ac6a243a3d3bb4c4a86ec89d2..d302f023a9c376f4b03496db95284778703b9d0f 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.67 2006/07/31 20:09:00 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.68 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -233,7 +233,7 @@ IsReservedName(const char *name)
  *
  * Hard-wiring this list is pretty grotty, but we really need it so that
  * we can compute the locktag for a relation (and then lock it) without
- * having already read its pg_class entry.  If we try to retrieve relisshared
+ * having already read its pg_class entry. If we try to retrieve relisshared
  * from pg_class with no pre-existing lock, there is a race condition against
  * anyone who is concurrently committing a change to the pg_class entry:
  * since we read system catalog entries under SnapshotNow, it's possible
index 7007e83873459a4eba71eaab825c55f2792c1830..cab4f1006bc6c1f4e97ffc389bee146d1dbf042d 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.59 2006/08/20 21:56:16 alvherre Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.60 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -63,6 +63,7 @@ struct ObjectAddresses
    int         numrefs;        /* current number of references */
    int         maxrefs;        /* current size of palloc'd array */
 };
+
 /* typedef ObjectAddresses appears in dependency.h */
 
 /* for find_expr_references_walker */
@@ -244,8 +245,8 @@ performMultipleDeletions(const ObjectAddresses *objects,
 {
    ObjectAddresses *implicit;
    ObjectAddresses *alreadyDeleted;
-   Relation        depRel;
-   int             i;
+   Relation    depRel;
+   int         i;
 
    implicit = new_object_addresses();
    alreadyDeleted = new_object_addresses();
@@ -271,8 +272,8 @@ performMultipleDeletions(const ObjectAddresses *objects,
            continue;
 
        /*
-        * Add the objects dependent on this one to the global list of implicit
-        * objects.
+        * Add the objects dependent on this one to the global list of
+        * implicit objects.
         */
        findAutoDeletableObjects(&obj, implicit, depRel, false);
    }
@@ -707,8 +708,8 @@ recursiveDeletion(const ObjectAddress *object,
     */
 
    /*
-    * Step 3: delete the object itself, and save it to the list of
-    * deleted objects if appropiate.
+    * Step 3: delete the object itself, and save it to the list of deleted
+    * objects if appropiate.
     */
    doDeletion(object);
    if (alreadyDeleted != NULL)
@@ -1284,7 +1285,7 @@ find_expr_references_walker(Node *node,
    }
    if (IsA(node, RelabelType))
    {
-       RelabelType    *relab = (RelabelType *) node;
+       RelabelType *relab = (RelabelType *) node;
 
        /* since there is no function dependency, need to depend on type */
        add_object_address(OCLASS_TYPE, relab->resulttype, 0,
@@ -1300,7 +1301,7 @@ find_expr_references_walker(Node *node,
    }
    if (IsA(node, RowExpr))
    {
-       RowExpr    *rowexpr = (RowExpr *) node;
+       RowExpr    *rowexpr = (RowExpr *) node;
 
        add_object_address(OCLASS_TYPE, rowexpr->row_typeid, 0,
                           context->addrs);
@@ -1471,7 +1472,7 @@ object_address_comparator(const void *a, const void *b)
 ObjectAddresses *
 new_object_addresses(void)
 {
-   ObjectAddresses   *addrs;
+   ObjectAddresses *addrs;
 
    addrs = palloc(sizeof(ObjectAddresses));
 
index e1f3e194b63f6a4b8fe133ece6ebc90817f556b8..d30556d48c15d0b71fc2a4aca70a1836a263ed63 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.312 2006/08/02 01:59:44 joe Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.313 2006/10/04 00:29:50 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -607,8 +607,8 @@ InsertPgClassTuple(Relation pg_class_desc,
    tup = heap_formtuple(RelationGetDescr(pg_class_desc), values, nulls);
 
    /*
-    * The new tuple must have the oid already chosen for the rel.  Sure
-    * would be embarrassing to do this sort of thing in polite company.
+    * The new tuple must have the oid already chosen for the rel.  Sure would
+    * be embarrassing to do this sort of thing in polite company.
     */
    HeapTupleSetOid(tup, new_rel_oid);
 
@@ -666,8 +666,8 @@ AddNewRelationTuple(Relation pg_class_desc,
    else
    {
        /*
-        * Other relations will not have Xids in them, so set the initial value
-        * to InvalidTransactionId.
+        * Other relations will not have Xids in them, so set the initial
+        * value to InvalidTransactionId.
         */
        new_rel_reltup->relminxid = InvalidTransactionId;
        new_rel_reltup->relvacuumxid = InvalidTransactionId;
@@ -1975,7 +1975,7 @@ RemoveStatistics(Oid relid, AttrNumber attnum)
  * with the heap relation to zero tuples.
  *
  * The routine will truncate and then reconstruct the indexes on
- * the specified relation.  Caller must hold exclusive lock on rel.
+ * the specified relation. Caller must hold exclusive lock on rel.
  */
 static void
 RelationTruncateIndexes(Relation heapRelation)
@@ -2103,7 +2103,7 @@ heap_truncate_check_FKs(List *relations, bool tempTables)
        return;
 
    /*
-    * Otherwise, must scan pg_constraint.  We make one pass with all the
+    * Otherwise, must scan pg_constraint.  We make one pass with all the
     * relations considered; if this finds nothing, then all is well.
     */
    dependents = heap_truncate_find_FKs(oids);
@@ -2119,19 +2119,19 @@ heap_truncate_check_FKs(List *relations, bool tempTables)
     */
    foreach(cell, oids)
    {
-       Oid     relid = lfirst_oid(cell);
-       ListCell *cell2;
+       Oid         relid = lfirst_oid(cell);
+       ListCell   *cell2;
 
        dependents = heap_truncate_find_FKs(list_make1_oid(relid));
 
        foreach(cell2, dependents)
        {
-           Oid     relid2 = lfirst_oid(cell2);
+           Oid         relid2 = lfirst_oid(cell2);
 
            if (!list_member_oid(oids, relid2))
            {
-               char   *relname = get_rel_name(relid);
-               char   *relname2 = get_rel_name(relid2);
+               char       *relname = get_rel_name(relid);
+               char       *relname2 = get_rel_name(relid2);
 
                if (tempTables)
                    ereport(ERROR,
@@ -2145,9 +2145,9 @@ heap_truncate_check_FKs(List *relations, bool tempTables)
                             errmsg("cannot truncate a table referenced in a foreign key constraint"),
                             errdetail("Table \"%s\" references \"%s\".",
                                       relname2, relname),
-                            errhint("Truncate table \"%s\" at the same time, "
-                                    "or use TRUNCATE ... CASCADE.",
-                                    relname2)));
+                          errhint("Truncate table \"%s\" at the same time, "
+                                  "or use TRUNCATE ... CASCADE.",
+                                  relname2)));
            }
        }
    }
@@ -2164,7 +2164,7 @@ heap_truncate_check_FKs(List *relations, bool tempTables)
  * behavior to change depending on chance locations of rows in pg_constraint.)
  *
  * Note: caller should already have appropriate lock on all rels mentioned
- * in relationIds.  Since adding or dropping an FK requires exclusive lock
+ * in relationIds. Since adding or dropping an FK requires exclusive lock
  * on both rels, this ensures that the answer will be stable.
  */
 List *
@@ -2176,8 +2176,8 @@ heap_truncate_find_FKs(List *relationIds)
    HeapTuple   tuple;
 
    /*
-    * Must scan pg_constraint.  Right now, it is a seqscan because
-    * there is no available index on confrelid.
+    * Must scan pg_constraint.  Right now, it is a seqscan because there is
+    * no available index on confrelid.
     */
    fkeyRel = heap_open(ConstraintRelationId, AccessShareLock);
 
index 60a30ce3727fd8b25c824ed8f8141a0db38fe3db..290cd27688160bc41723a66722cea235be466b56 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.273 2006/08/25 04:06:46 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.274 2006/10/04 00:29:50 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -58,7 +58,9 @@ typedef struct
 {
    Tuplesortstate *tuplesort;  /* for sorting the index TIDs */
    /* statistics (for debug purposes only): */
-   double htups, itups, tups_inserted;
+   double      htups,
+               itups,
+               tups_inserted;
 } v_i_state;
 
 /* non-export function prototypes */
@@ -449,7 +451,7 @@ UpdateIndexRelation(Oid indexoid,
  * allow_system_table_mods: allow table to be a system catalog
  * skip_build: true to skip the index_build() step for the moment; caller
  *     must do it later (typically via reindex_index())
- * concurrent: if true, do not lock the table against writers.  The index
+ * concurrent: if true, do not lock the table against writers. The index
  *     will be marked "invalid" and the caller must take additional steps
  *     to fix it up.
  *
@@ -486,7 +488,7 @@ index_create(Oid heapRelationId,
     * (but not VACUUM).
     */
    heapRelation = heap_open(heapRelationId,
-                            (concurrent ? ShareUpdateExclusiveLock : ShareLock));
+                       (concurrent ? ShareUpdateExclusiveLock : ShareLock));
 
    /*
     * The index will be in the same namespace as its parent table, and is
@@ -509,8 +511,8 @@ index_create(Oid heapRelationId,
                 errmsg("user-defined indexes on system catalog tables are not supported")));
 
    /*
-    * concurrent index build on a system catalog is unsafe because we tend
-    * to release locks before committing in catalogs
+    * concurrent index build on a system catalog is unsafe because we tend to
+    * release locks before committing in catalogs
     */
    if (concurrent &&
        IsSystemRelation(heapRelation))
@@ -766,8 +768,8 @@ index_create(Oid heapRelationId,
    {
        /*
         * Caller is responsible for filling the index later on.  However,
-        * we'd better make sure that the heap relation is correctly marked
-        * as having an index.
+        * we'd better make sure that the heap relation is correctly marked as
+        * having an index.
         */
        index_update_stats(heapRelation,
                           true,
@@ -932,7 +934,7 @@ BuildIndexInfo(Relation index)
 
    /* other info */
    ii->ii_Unique = indexStruct->indisunique;
-   ii->ii_Concurrent = false;          /* assume normal case */
+   ii->ii_Concurrent = false;  /* assume normal case */
 
    return ii;
 }
@@ -1018,7 +1020,7 @@ FormIndexDatum(IndexInfo *indexInfo,
  * index_update_stats --- update pg_class entry after CREATE INDEX or REINDEX
  *
  * This routine updates the pg_class row of either an index or its parent
- * relation after CREATE INDEX or REINDEX.  Its rather bizarre API is designed
+ * relation after CREATE INDEX or REINDEX. Its rather bizarre API is designed
  * to ensure we can do all the necessary work in just one update.
  *
  * hasindex: set relhasindex to this value
@@ -1031,7 +1033,7 @@ FormIndexDatum(IndexInfo *indexInfo,
  *
  * NOTE: an important side-effect of this operation is that an SI invalidation
  * message is sent out to all backends --- including me --- causing relcache
- * entries to be flushed or updated with the new data.  This must happen even
+ * entries to be flushed or updated with the new data. This must happen even
  * if we find that no change is needed in the pg_class row.  When updating
  * a heap entry, this ensures that other backends find out about the new
  * index.  When updating an index, it's important because some index AMs
@@ -1041,7 +1043,7 @@ static void
 index_update_stats(Relation rel, bool hasindex, bool isprimary,
                   Oid reltoastidxid, double reltuples)
 {
-   BlockNumber relpages = RelationGetNumberOfBlocks(rel);
+   BlockNumber relpages = RelationGetNumberOfBlocks(rel);
    Oid         relid = RelationGetRelid(rel);
    Relation    pg_class;
    HeapTuple   tuple;
@@ -1054,9 +1056,9 @@ index_update_stats(Relation rel, bool hasindex, bool isprimary,
     *
     * 1. In bootstrap mode, we have no choice --- UPDATE wouldn't work.
     *
-    * 2. We could be reindexing pg_class itself, in which case we can't
-    * move its pg_class row because CatalogUpdateIndexes might not know
-    * about all the indexes yet (see reindex_relation).
+    * 2. We could be reindexing pg_class itself, in which case we can't move
+    * its pg_class row because CatalogUpdateIndexes might not know about all
+    * the indexes yet (see reindex_relation).
     *
     * 3. Because we execute CREATE INDEX with just share lock on the parent
     * rel (to allow concurrent index creations), an ordinary update could
@@ -1069,24 +1071,24 @@ index_update_stats(Relation rel, bool hasindex, bool isprimary,
     * 4. Even with just a single CREATE INDEX, there's a risk factor because
     * someone else might be trying to open the rel while we commit, and this
     * creates a race condition as to whether he will see both or neither of
-    * the pg_class row versions as valid.  Again, a non-transactional update
+    * the pg_class row versions as valid.  Again, a non-transactional update
     * avoids the risk.  It is indeterminate which state of the row the other
     * process will see, but it doesn't matter (if he's only taking
     * AccessShareLock, then it's not critical that he see relhasindex true).
     *
     * It is safe to use a non-transactional update even though our
-    * transaction could still fail before committing.  Setting relhasindex
+    * transaction could still fail before committing.  Setting relhasindex
     * true is safe even if there are no indexes (VACUUM will eventually fix
-    * it), and of course the relpages and reltuples counts are correct (or
-    * at least more so than the old values) regardless.
+    * it), and of course the relpages and reltuples counts are correct (or at
+    * least more so than the old values) regardless.
     */
 
    pg_class = heap_open(RelationRelationId, RowExclusiveLock);
 
    /*
-    * Make a copy of the tuple to update.  Normally we use the syscache,
-    * but we can't rely on that during bootstrap or while reindexing
-    * pg_class itself.
+    * Make a copy of the tuple to update.  Normally we use the syscache, but
+    * we can't rely on that during bootstrap or while reindexing pg_class
+    * itself.
     */
    if (IsBootstrapProcessingMode() ||
        ReindexIsProcessingHeap(RelationRelationId))
@@ -1245,7 +1247,7 @@ setNewRelfilenode(Relation relation)
  * index_build - invoke access-method-specific index build procedure
  *
  * On entry, the index's catalog entries are valid, and its physical disk
- * file has been created but is empty.  We call the AM-specific build
+ * file has been created but is empty. We call the AM-specific build
  * procedure to fill in the index contents.  We then update the pg_class
  * entries of the index and heap relation as needed, using statistics
  * returned by ambuild as well as data passed by the caller.
@@ -1365,22 +1367,21 @@ IndexBuildHeapScan(Relation heapRelation,
                        estate);
 
    /*
-    * Prepare for scan of the base relation.  In a normal index build,
-    * we use SnapshotAny because we must retrieve all tuples and do our own
-    * time qual checks (because we have to index RECENTLY_DEAD tuples).
-    * In a concurrent build, we take a regular MVCC snapshot and index
-    * whatever's live according to that.  During bootstrap we just use
-    * SnapshotNow.
+    * Prepare for scan of the base relation.  In a normal index build, we use
+    * SnapshotAny because we must retrieve all tuples and do our own time
+    * qual checks (because we have to index RECENTLY_DEAD tuples). In a
+    * concurrent build, we take a regular MVCC snapshot and index whatever's
+    * live according to that.  During bootstrap we just use SnapshotNow.
     */
    if (IsBootstrapProcessingMode())
    {
        snapshot = SnapshotNow;
-       OldestXmin = InvalidTransactionId;          /* not used */
+       OldestXmin = InvalidTransactionId;      /* not used */
    }
    else if (indexInfo->ii_Concurrent)
    {
        snapshot = CopySnapshot(GetTransactionSnapshot());
-       OldestXmin = InvalidTransactionId;          /* not used */
+       OldestXmin = InvalidTransactionId;      /* not used */
    }
    else
    {
@@ -1391,8 +1392,8 @@ IndexBuildHeapScan(Relation heapRelation,
 
    scan = heap_beginscan(heapRelation, /* relation */
                          snapshot,     /* seeself */
-                         0,            /* number of keys */
-                         NULL);        /* scan key */
+                         0,    /* number of keys */
+                         NULL);    /* scan key */
 
    reltuples = 0;
 
@@ -1435,9 +1436,9 @@ IndexBuildHeapScan(Relation heapRelation,
                    /*
                     * If tuple is recently deleted then we must index it
                     * anyway to preserve MVCC semantics.  (Pre-existing
-                    * transactions could try to use the index after we
-                    * finish building it, and may need to see such tuples.)
-                    * Exclude it from unique-checking, however.
+                    * transactions could try to use the index after we finish
+                    * building it, and may need to see such tuples.) Exclude
+                    * it from unique-checking, however.
                     */
                    indexIt = true;
                    tupleIsAlive = false;
@@ -1573,7 +1574,7 @@ IndexBuildHeapScan(Relation heapRelation,
  * which is passed to validate_index().  Any tuples that are valid according
  * to this snap, but are not in the index, must be added to the index.
  * (Any tuples committed live after the snap will be inserted into the
- * index by their originating transaction.  Any tuples committed dead before
+ * index by their originating transaction. Any tuples committed dead before
  * the snap need not be indexed, because we will wait out all transactions
  * that might care about them before we mark the index valid.)
  *
@@ -1582,7 +1583,7 @@ IndexBuildHeapScan(Relation heapRelation,
  * ever say "delete it".  (This should be faster than a plain indexscan;
  * also, not all index AMs support full-index indexscan.)  Then we sort the
  * TIDs, and finally scan the table doing a "merge join" against the TID list
- * to see which tuples are missing from the index.  Thus we will ensure that
+ * to see which tuples are missing from the index. Thus we will ensure that
  * all tuples valid according to the reference snapshot are in the index.
  *
  * Building a unique index this way is tricky: we might try to insert a
@@ -1598,7 +1599,7 @@ IndexBuildHeapScan(Relation heapRelation,
  * were alive at the time of the reference snapshot are gone; this is
  * necessary to be sure there are none left with a serializable snapshot
  * older than the reference (and hence possibly able to see tuples we did
- * not index).  Then we mark the index valid and commit.
+ * not index). Then we mark the index valid and commit.
  *
  * Doing two full table scans is a brute-force strategy.  We could try to be
  * cleverer, eg storing new tuples in a special area of the table (perhaps
@@ -1608,10 +1609,11 @@ IndexBuildHeapScan(Relation heapRelation,
 void
 validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
 {
-   Relation heapRelation, indexRelation;
-   IndexInfo *indexInfo;
+   Relation    heapRelation,
+               indexRelation;
+   IndexInfo  *indexInfo;
    IndexVacuumInfo ivinfo;
-   v_i_state state;
+   v_i_state   state;
 
    /* Open and lock the parent heap relation */
    heapRelation = heap_open(heapId, ShareUpdateExclusiveLock);
@@ -1619,9 +1621,9 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
    indexRelation = index_open(indexId, RowExclusiveLock);
 
    /*
-    * Fetch info needed for index_insert.  (You might think this should
-    * be passed in from DefineIndex, but its copy is long gone due to
-    * having been built in a previous transaction.)
+    * Fetch info needed for index_insert.  (You might think this should be
+    * passed in from DefineIndex, but its copy is long gone due to having
+    * been built in a previous transaction.)
     */
    indexInfo = BuildIndexInfo(indexRelation);
 
@@ -1675,7 +1677,7 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
 static bool
 validate_index_callback(ItemPointer itemptr, void *opaque)
 {
-   v_i_state *state = (v_i_state *) opaque;
+   v_i_state  *state = (v_i_state *) opaque;
 
    tuplesort_putdatum(state->tuplesort, PointerGetDatum(itemptr), false);
    state->itups += 1;
@@ -1703,9 +1705,10 @@ validate_index_heapscan(Relation heapRelation,
    TupleTableSlot *slot;
    EState     *estate;
    ExprContext *econtext;
+
    /* state variables for the merge */
    ItemPointer indexcursor = NULL;
-   bool tuplesort_empty = false;
+   bool        tuplesort_empty = false;
 
    /*
     * sanity checks
@@ -1734,8 +1737,8 @@ validate_index_heapscan(Relation heapRelation,
     */
    scan = heap_beginscan(heapRelation, /* relation */
                          snapshot,     /* seeself */
-                         0,            /* number of keys */
-                         NULL);        /* scan key */
+                         0,    /* number of keys */
+                         NULL);    /* scan key */
 
    /*
     * Scan all tuples matching the snapshot.
@@ -1749,15 +1752,15 @@ validate_index_heapscan(Relation heapRelation,
        state->htups += 1;
 
        /*
-        * "merge" by skipping through the index tuples until we find or
-        * pass the current heap tuple.
+        * "merge" by skipping through the index tuples until we find or pass
+        * the current heap tuple.
         */
        while (!tuplesort_empty &&
               (!indexcursor ||
                ItemPointerCompare(indexcursor, heapcursor) < 0))
        {
-           Datum ts_val;
-           bool ts_isnull;
+           Datum       ts_val;
+           bool        ts_isnull;
 
            if (indexcursor)
                pfree(indexcursor);
@@ -1774,7 +1777,7 @@ validate_index_heapscan(Relation heapRelation,
             * We've overshot which means this heap tuple is missing from the
             * index, so insert it.
             */
-           bool    check_unique;
+           bool        check_unique;
 
            MemoryContextReset(econtext->ecxt_per_tuple_memory);
 
@@ -1793,7 +1796,7 @@ validate_index_heapscan(Relation heapRelation,
 
            /*
             * For the current heap tuple, extract all the attributes we use
-            * in this index, and note which are null.  This also performs
+            * in this index, and note which are null.  This also performs
             * evaluation of any expressions needed.
             */
            FormIndexDatum(indexInfo,
@@ -1803,11 +1806,11 @@ validate_index_heapscan(Relation heapRelation,
                           isnull);
 
            /*
-            * If the tuple is already committed dead, we still have to
-            * put it in the index (because some xacts might be able to
-            * see it), but we might as well suppress uniqueness checking.
-            * This is just an optimization because the index AM is not
-            * supposed to raise a uniqueness failure anyway.
+            * If the tuple is already committed dead, we still have to put it
+            * in the index (because some xacts might be able to see it), but
+            * we might as well suppress uniqueness checking. This is just an
+            * optimization because the index AM is not supposed to raise a
+            * uniqueness failure anyway.
             */
            if (indexInfo->ii_Unique)
            {
index abd3547e5e6b7acdb033a3625a2e0ec1f6a70183..1d6162ca12e458c6f57c16f08c9611dfd7d8d7bf 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.87 2006/09/14 22:05:06 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.88 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -718,7 +718,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
                                 ObjectIdGetDatum(namespaceId));
        if (HeapTupleIsValid(opertup))
        {
-           Oid     result = HeapTupleGetOid(opertup);
+           Oid         result = HeapTupleGetOid(opertup);
 
            ReleaseSysCache(opertup);
            return result;
@@ -741,9 +741,9 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
    }
 
    /*
-    * We have to find the list member that is first in the search path,
-    * if there's more than one.  This doubly-nested loop looks ugly,
-    * but in practice there should usually be few catlist members.
+    * We have to find the list member that is first in the search path, if
+    * there's more than one.  This doubly-nested loop looks ugly, but in
+    * practice there should usually be few catlist members.
     */
    recomputeNamespacePath();
 
@@ -759,7 +759,7 @@ OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
 
            if (operform->oprnamespace == namespaceId)
            {
-               Oid     result = HeapTupleGetOid(opertup);
+               Oid         result = HeapTupleGetOid(opertup);
 
                ReleaseSysCacheList(catlist);
                return result;
index 747543e077d553ed496837d50c327b829d77aec8..6420defe4fb392c0dee471d6b390438de32a592d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.82 2006/07/27 19:52:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/pg_aggregate.c,v 1.83 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -89,15 +89,15 @@ AggregateCreate(const char *aggName,
    }
 
    /*
-    * If transtype is polymorphic, must have polymorphic argument also;
-    * else we will have no way to deduce the actual transtype.
+    * If transtype is polymorphic, must have polymorphic argument also; else
+    * we will have no way to deduce the actual transtype.
     */
    if (!hasPolyArg &&
        (aggTransType == ANYARRAYOID || aggTransType == 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 at least one argument of either type.")));
+                errdetail("An aggregate using \"anyarray\" or \"anyelement\" as transition type must have at least one argument of either type.")));
 
    /* find the transfn */
    nargs_transfn = numArgs + 1;
@@ -133,8 +133,8 @@ AggregateCreate(const char *aggName,
 
    /*
     * If the transfn is strict and the initval is NULL, make sure first 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.
+    * 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)
    {
@@ -211,7 +211,7 @@ AggregateCreate(const char *aggName,
                              PROVOLATILE_IMMUTABLE,    /* volatility (not
                                                         * needed for agg) */
                              buildoidvector(aggArgTypes,
-                                            numArgs),  /* paramTypes */
+                                            numArgs),  /* paramTypes */
                              PointerGetDatum(NULL),    /* allParamTypes */
                              PointerGetDatum(NULL),    /* parameterModes */
                              PointerGetDatum(NULL));   /* parameterNames */
@@ -355,7 +355,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 */
index 99cdf5e7e6ae6832d733db75d5fe67048b42c04c..b0c59862512a5813d36a72b392af8edfca0931cc 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.22 2006/08/21 00:57:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/pg_depend.c,v 1.23 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -264,7 +264,7 @@ changeDependencyFor(Oid classId, Oid objectId,
  * Detect whether a sequence is marked as "owned" by a column
  *
  * An ownership marker is an AUTO dependency from the sequence to the
- * column.  If we find one, store the identity of the owning column
+ * column. If we find one, store the identity of the owning column
  * into *tableId and *colId and return TRUE; else return FALSE.
  *
  * Note: if there's more than one such pg_depend entry then you get
index 85e3d968d489a170197b8bdfd625550b988163c1..5195cb06be99e13449caa270cc16794163e4b06d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.14 2006/08/21 00:57:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.15 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1101,9 +1101,9 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
 
        while ((tuple = systable_getnext(scan)) != NULL)
        {
-           ObjectAddress   obj;
-           GrantObjectType objtype;
-           InternalGrant   istmt;
+           ObjectAddress obj;
+           GrantObjectType objtype;
+           InternalGrant istmt;
            Form_pg_shdepend sdepForm = (Form_pg_shdepend) GETSTRUCT(tuple);
 
            /* We only operate on objects in the current database */
@@ -1112,7 +1112,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior)
 
            switch (sdepForm->deptype)
            {
-               /* Shouldn't happen */
+                   /* Shouldn't happen */
                case SHARED_DEPENDENCY_PIN:
                case SHARED_DEPENDENCY_INVALID:
                    elog(ERROR, "unexpected dependency type");
@@ -1267,10 +1267,11 @@ shdepReassignOwned(List *roleids, Oid newrole)
                    break;
 
                case RelationRelationId:
+
                    /*
-                    * Pass recursing = true so that we don't fail on
-                    * indexes, owned sequences, etc when we happen
-                    * to visit them before their parent table.
+                    * Pass recursing = true so that we don't fail on indexes,
+                    * owned sequences, etc when we happen to visit them
+                    * before their parent table.
                     */
                    ATExecChangeOwner(sdepForm->objid, newrole, true);
                    break;
index 1b9eea29dcca7c74036575dbe34d5b67c6191a19..32de0b90dc1f14d2808299454ee254bb4a5fe96d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.107 2006/07/14 14:52:18 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/pg_type.c,v 1.108 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -73,34 +73,34 @@ TypeShellMake(const char *typeName, Oid typeNamespace)
    /*
     * initialize *values with the type name and dummy values
     *
-    * The representational details are the same as int4 ... it doesn't
-    * really matter what they are so long as they are consistent.  Also
-    * note that we give it typtype = 'p' (pseudotype) as extra insurance
-    * that it won't be mistaken for a usable type.
+    * The representational details are the same as int4 ... it doesn't really
+    * matter what they are so long as they are consistent.  Also note that we
+    * give it typtype = 'p' (pseudotype) as extra insurance that it won't be
+    * mistaken for a usable type.
     */
    i = 0;
    namestrcpy(&name, typeName);
    values[i++] = NameGetDatum(&name);  /* typname */
    values[i++] = ObjectIdGetDatum(typeNamespace);      /* typnamespace */
    values[i++] = ObjectIdGetDatum(GetUserId());        /* typowner */
-   values[i++] = Int16GetDatum(sizeof(int4));          /* typlen */
-   values[i++] = BoolGetDatum(true);                   /* typbyval */
-   values[i++] = CharGetDatum('p');                    /* typtype */
-   values[i++] = BoolGetDatum(false);                  /* typisdefined */
+   values[i++] = Int16GetDatum(sizeof(int4));  /* typlen */
+   values[i++] = BoolGetDatum(true);   /* typbyval */
+   values[i++] = CharGetDatum('p');    /* typtype */
+   values[i++] = BoolGetDatum(false);  /* typisdefined */
    values[i++] = CharGetDatum(DEFAULT_TYPDELIM);       /* typdelim */
-   values[i++] = ObjectIdGetDatum(InvalidOid);         /* typrelid */
-   values[i++] = ObjectIdGetDatum(InvalidOid);         /* typelem */
-   values[i++] = ObjectIdGetDatum(F_SHELL_IN);         /* typinput */
+   values[i++] = ObjectIdGetDatum(InvalidOid); /* typrelid */
+   values[i++] = ObjectIdGetDatum(InvalidOid); /* typelem */
+   values[i++] = ObjectIdGetDatum(F_SHELL_IN); /* typinput */
    values[i++] = ObjectIdGetDatum(F_SHELL_OUT);        /* typoutput */
-   values[i++] = ObjectIdGetDatum(InvalidOid);         /* typreceive */
-   values[i++] = ObjectIdGetDatum(InvalidOid);         /* typsend */
-   values[i++] = ObjectIdGetDatum(InvalidOid);         /* typanalyze */
-   values[i++] = CharGetDatum('i');                    /* typalign */
-   values[i++] = CharGetDatum('p');                    /* typstorage */
-   values[i++] = BoolGetDatum(false);                  /* typnotnull */
-   values[i++] = ObjectIdGetDatum(InvalidOid);         /* typbasetype */
-   values[i++] = Int32GetDatum(-1);                    /* typtypmod */
-   values[i++] = Int32GetDatum(0);                     /* typndims */
+   values[i++] = ObjectIdGetDatum(InvalidOid); /* typreceive */
+   values[i++] = ObjectIdGetDatum(InvalidOid); /* typsend */
+   values[i++] = ObjectIdGetDatum(InvalidOid); /* typanalyze */
+   values[i++] = CharGetDatum('i');    /* typalign */
+   values[i++] = CharGetDatum('p');    /* typstorage */
+   values[i++] = BoolGetDatum(false);  /* typnotnull */
+   values[i++] = ObjectIdGetDatum(InvalidOid); /* typbasetype */
+   values[i++] = Int32GetDatum(-1);    /* typtypmod */
+   values[i++] = Int32GetDatum(0);     /* typndims */
    nulls[i++] = 'n';           /* typdefaultbin */
    nulls[i++] = 'n';           /* typdefault */
 
index aa3e7b8feffb19a3de6aa74913f9e3d110080349..c4416d5e0193da49c3e927d0aed2f26f64dc24fe 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.2 2006/08/25 04:06:47 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.3 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -70,7 +70,7 @@ AlterTableCreateToastTable(Oid relOid)
 void
 BootstrapToastTable(char *relName, Oid toastOid, Oid toastIndexOid)
 {
-   Relation rel;
+   Relation    rel;
 
    rel = heap_openrv(makeRangeVar(NULL, relName), AccessExclusiveLock);
 
index 7923199f638408abef5ab8e38f1a94c5f03039dc..e072a23f2708e1166e6d1ec819835552985de6c8 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.40 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.41 2006/10/04 00:29:50 momjian Exp $
  *
  * DESCRIPTION
  *   The "DefineFoo" routines take the parse tree and pick out the
@@ -58,7 +58,7 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
    TypeName   *transType = NULL;
    char       *initval = NULL;
    Oid        *aggArgTypes;
-   int         numArgs;
+   int         numArgs;
    Oid         transTypeId;
    ListCell   *pl;
 
@@ -122,8 +122,8 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
    if (oldstyle)
    {
        /*
-        * Old style: use basetype parameter.  This supports aggregates
-        * of zero or one input, with input type ANY meaning zero inputs.
+        * Old style: use basetype parameter.  This supports aggregates of
+        * zero or one input, with input type ANY meaning zero inputs.
         *
         * Historically we allowed the command to look like basetype = 'ANY'
         * so we must do a case-insensitive comparison for the name ANY. Ugh.
@@ -150,8 +150,8 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
        /*
         * New style: args is a list of TypeNames (possibly zero of 'em).
         */
-       ListCell *lc;
-       int i = 0;
+       ListCell   *lc;
+       int         i = 0;
 
        if (baseType != NULL)
            ereport(ERROR,
@@ -162,7 +162,7 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
        aggArgTypes = (Oid *) palloc(sizeof(Oid) * numArgs);
        foreach(lc, args)
        {
-           TypeName *curTypeName = (TypeName *) lfirst(lc);
+           TypeName   *curTypeName = (TypeName *) lfirst(lc);
 
            aggArgTypes[i++] = typenameTypeId(NULL, curTypeName);
        }
@@ -171,9 +171,9 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
    /*
     * look up the aggregate's transtype.
     *
-    * transtype can't be a pseudo-type, since we need to be
-    * able to store values of the transtype.  However, we can allow
-    * polymorphic transtype in some cases (AggregateCreate will check).
+    * transtype can't be a pseudo-type, since we need to be able to store
+    * values of the transtype.  However, we can allow polymorphic transtype
+    * in some cases (AggregateCreate will check).
     */
    transTypeId = typenameTypeId(NULL, transType);
    if (get_typtype(transTypeId) == 'p' &&
@@ -189,7 +189,7 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
     */
    AggregateCreate(aggName,    /* aggregate name */
                    aggNamespace,       /* namespace */
-                   aggArgTypes,        /* input data type(s) */
+                   aggArgTypes,    /* input data type(s) */
                    numArgs,
                    transfuncName,      /* step function name */
                    finalfuncName,      /* final function name */
@@ -289,7 +289,7 @@ RenameAggregate(List *name, List *args, 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))));
 
    /* must be owner */
index f9e41e3531bdcfc050f5300e540f9e56d7c71ed1..1ce768f0463ae09f0fdb88475a4d03eb79c6d813 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.98 2006/09/17 22:50:31 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.99 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -129,12 +129,11 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
    CHECK_FOR_INTERRUPTS();
 
    /*
-    * Open the relation, getting ShareUpdateExclusiveLock to ensure that
-    * two ANALYZEs don't run on it concurrently.  (This also locks out
-    * a concurrent VACUUM, which doesn't matter much at the moment but
-    * might matter if we ever try to accumulate stats on dead tuples.)
-    * If the rel has been dropped since we last saw it, we don't need
-    * to process it.
+    * Open the relation, getting ShareUpdateExclusiveLock to ensure that two
+    * ANALYZEs don't run on it concurrently.  (This also locks out a
+    * concurrent VACUUM, which doesn't matter much at the moment but might
+    * matter if we ever try to accumulate stats on dead tuples.) If the rel
+    * has been dropped since we last saw it, we don't need to process it.
     */
    onerel = try_relation_open(relid, ShareUpdateExclusiveLock);
    if (!onerel)
@@ -216,8 +215,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt)
            if (i == InvalidAttrNumber)
                ereport(ERROR,
                        (errcode(ERRCODE_UNDEFINED_COLUMN),
-                        errmsg("column \"%s\" of relation \"%s\" does not exist",
-                               col, RelationGetRelationName(onerel))));
+                   errmsg("column \"%s\" of relation \"%s\" does not exist",
+                          col, RelationGetRelationName(onerel))));
            vacattrstats[tcnt] = examine_attribute(onerel, i);
            if (vacattrstats[tcnt] != NULL)
                tcnt++;
index bd2301dd62e95c4762324f57932535995b344d0b..665c66cad5e16941344250faac2420e79a2a9401 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.153 2006/08/18 16:09:08 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.154 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -288,7 +288,7 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
        tuple = SearchSysCache(INDEXRELID,
                               ObjectIdGetDatum(rvtc->indexOid),
                               0, 0, 0);
-       if (!HeapTupleIsValid(tuple))       /* probably can't happen */
+       if (!HeapTupleIsValid(tuple))   /* probably can't happen */
        {
            relation_close(OldHeap, AccessExclusiveLock);
            return;
@@ -350,7 +350,7 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck)
                 errmsg("cannot cluster on partial index \"%s\"",
                        RelationGetRelationName(OldIndex))));
 
-   if (!OldIndex->rd_am->amclusterable) 
+   if (!OldIndex->rd_am->amclusterable)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                 errmsg("cannot cluster on index \"%s\" because access method does not support clustering",
index f54243a49554f3ae828b02000070c3f94f60162e..df4416d37c2d0e02170b4066d7f97b38404801e6 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.91 2006/09/05 21:08:35 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.92 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -261,11 +261,12 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
  * If the comment given is null or an empty string, instead delete any
  * existing comment for the specified key.
  */
-void CreateSharedComments(Oid oid, Oid classoid, char *comment)
+void
+CreateSharedComments(Oid oid, Oid classoid, char *comment)
 {
    Relation    shdescription;
-   ScanKeyData skey[2];
-   SysScanDesc sd;
+   ScanKeyData skey[2];
+   SysScanDesc sd;
    HeapTuple   oldtuple;
    HeapTuple   newtuple = NULL;
    Datum       values[Natts_pg_shdescription];
@@ -294,18 +295,18 @@ void CreateSharedComments(Oid oid, Oid classoid, char *comment)
    /* Use the index to search for a matching old tuple */
 
    ScanKeyInit(&skey[0],
-           Anum_pg_shdescription_objoid,
-           BTEqualStrategyNumber, F_OIDEQ,
-           ObjectIdGetDatum(oid));
+               Anum_pg_shdescription_objoid,
+               BTEqualStrategyNumber, F_OIDEQ,
+               ObjectIdGetDatum(oid));
    ScanKeyInit(&skey[1],
-           Anum_pg_shdescription_classoid,
-           BTEqualStrategyNumber, F_OIDEQ,
-           ObjectIdGetDatum(classoid));
+               Anum_pg_shdescription_classoid,
+               BTEqualStrategyNumber, F_OIDEQ,
+               ObjectIdGetDatum(classoid));
 
    shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock);
 
    sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true,
-           SnapshotNow, 2, skey);
+                           SnapshotNow, 2, skey);
 
    while ((oldtuple = systable_getnext(sd)) != NULL)
    {
@@ -316,11 +317,11 @@ void CreateSharedComments(Oid oid, Oid classoid, char *comment)
        else
        {
            newtuple = heap_modifytuple(oldtuple, RelationGetDescr(shdescription),
-                   values, nulls, replaces);
+                                       values, nulls, replaces);
            simple_heap_update(shdescription, &oldtuple->t_self, newtuple);
        }
 
-       break;  /* Assume there can be only one match */
+       break;                  /* Assume there can be only one match */
    }
 
    systable_endscan(sd);
@@ -330,7 +331,7 @@ void CreateSharedComments(Oid oid, Oid classoid, char *comment)
    if (newtuple == NULL && comment != NULL)
    {
        newtuple = heap_formtuple(RelationGetDescr(shdescription),
-               values, nulls);
+                                 values, nulls);
        simple_heap_insert(shdescription, newtuple);
    }
 
@@ -405,25 +406,25 @@ void
 DeleteSharedComments(Oid oid, Oid classoid)
 {
    Relation    shdescription;
-   ScanKeyData skey[2];
-   SysScanDesc sd;
+   ScanKeyData skey[2];
+   SysScanDesc sd;
    HeapTuple   oldtuple;
 
    /* Use the index to search for all matching old tuples */
 
    ScanKeyInit(&skey[0],
-           Anum_pg_shdescription_objoid,
-           BTEqualStrategyNumber, F_OIDEQ,
-           ObjectIdGetDatum(oid));
+               Anum_pg_shdescription_objoid,
+               BTEqualStrategyNumber, F_OIDEQ,
+               ObjectIdGetDatum(oid));
    ScanKeyInit(&skey[1],
-           Anum_pg_shdescription_classoid,
-           BTEqualStrategyNumber, F_OIDEQ,
-           ObjectIdGetDatum(classoid));
+               Anum_pg_shdescription_classoid,
+               BTEqualStrategyNumber, F_OIDEQ,
+               ObjectIdGetDatum(classoid));
 
    shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock);
 
    sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true,
-           SnapshotNow, 2, skey);
+                           SnapshotNow, 2, skey);
 
    while ((oldtuple = systable_getnext(sd)) != NULL)
        simple_heap_delete(shdescription, &oldtuple->t_self);
@@ -620,8 +621,8 @@ CommentDatabase(List *qualname, char *comment)
 static void
 CommentTablespace(List *qualname, char *comment)
 {
-   char    *tablespace;
-   Oid     oid;
+   char       *tablespace;
+   Oid         oid;
 
    if (list_length(qualname) != 1)
        ereport(ERROR,
@@ -657,8 +658,8 @@ CommentTablespace(List *qualname, char *comment)
 static void
 CommentRole(List *qualname, char *comment)
 {
-   char *role;
-   Oid oid;
+   char       *role;
+   Oid         oid;
 
    if (list_length(qualname) != 1)
        ereport(ERROR,
@@ -672,7 +673,7 @@ CommentRole(List *qualname, char *comment)
    if (!has_privs_of_role(GetUserId(), oid))
        ereport(ERROR,
                (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                errmsg("must be member of role \"%s\" to comment upon it", role)));
+         errmsg("must be member of role \"%s\" to comment upon it", role)));
 
    /* Call CreateSharedComments() to create/drop the comments */
    CreateSharedComments(oid, AuthIdRelationId, comment);
index 23d9742234d86e380ea47a0ed48254dd97ea8577..0cbfc237ff2ca7ad36cc6c567008d66b0d838bae 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.271 2006/08/31 03:17:50 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.272 2006/10/04 00:29:50 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -88,8 +88,8 @@ typedef struct CopyStateData
    /* low-level state data */
    CopyDest    copy_dest;      /* type of copy source/destination */
    FILE       *copy_file;      /* used if copy_dest == COPY_FILE */
-   StringInfo  fe_msgbuf;      /* used for all dests during COPY TO, only
-                                * for dest == COPY_NEW_FE in COPY FROM */
+   StringInfo  fe_msgbuf;      /* used for all dests during COPY TO, only for
+                                * dest == COPY_NEW_FE in COPY FROM */
    bool        fe_copy;        /* true for all FE copy dests */
    bool        fe_eof;         /* true if detected end of copy data */
    EolType     eol_type;       /* EOL type of input */
@@ -109,7 +109,7 @@ typedef struct CopyStateData
    bool        header_line;    /* CSV header line? */
    char       *null_print;     /* NULL marker string (server encoding!) */
    int         null_print_len; /* length of same */
-   char       *null_print_client; /* same converted to client encoding */
+   char       *null_print_client;      /* same converted to client encoding */
    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) */
@@ -125,8 +125,8 @@ typedef struct CopyStateData
    /*
     * Working state for COPY TO
     */
-   FmgrInfo   *out_functions;      /* lookup info for output functions */
-   MemoryContext rowcontext;       /* per-row evaluation context */
+   FmgrInfo   *out_functions;  /* lookup info for output functions */
+   MemoryContext rowcontext;   /* per-row evaluation context */
 
    /*
     * These variables are used to reduce overhead in textual COPY FROM.
@@ -177,7 +177,7 @@ typedef struct
  * function call overhead in tight COPY loops.
  *
  * We must use "if (1)" because "do {} while(0)" overrides the continue/break
- * processing.  See http://www.cit.gu.edu.au/~anthony/info/C/C.macros.
+ * processing. See http://www.cit.gu.edu.au/~anthony/info/C/C.macros.
  */
 
 /*
@@ -243,7 +243,7 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";
 static void DoCopyTo(CopyState cstate);
 static void CopyTo(CopyState cstate);
 static void CopyOneRowTo(CopyState cstate, Oid tupleOid,
-                        Datum *values, bool *nulls);
+            Datum *values, bool *nulls);
 static void CopyFrom(CopyState cstate);
 static bool CopyReadLine(CopyState cstate);
 static bool CopyReadLineText(CopyState cstate);
@@ -259,7 +259,7 @@ static void CopyAttributeOutText(CopyState cstate, char *string);
 static void CopyAttributeOutCSV(CopyState cstate, char *string,
                    bool use_quote, bool single_attr);
 static List *CopyGetAttnums(TupleDesc tupDesc, Relation rel,
-                           List *attnamelist);
+              List *attnamelist);
 static char *limit_printout_length(const char *str);
 
 /* Low-level communications functions */
@@ -863,10 +863,10 @@ DoCopy(const CopyStmt *stmt)
 
    /* Disallow end-of-line characters */
    if (strchr(cstate->delim, '\r') != NULL ||
-       strchr(cstate->delim, '\n') != NULL)
+       strchr(cstate->delim, '\n') != NULL)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                errmsg("COPY delimiter cannot be newline or carriage return")));
+            errmsg("COPY delimiter cannot be newline or carriage return")));
 
    if (strchr(cstate->null_print, '\r') != NULL ||
        strchr(cstate->null_print, '\n') != NULL)
@@ -956,7 +956,7 @@ DoCopy(const CopyStmt *stmt)
 
        /* Open and lock the relation, using the appropriate lock type. */
        cstate->rel = heap_openrv(stmt->relation,
-                                 (is_from ? RowExclusiveLock : AccessShareLock));
+                            (is_from ? RowExclusiveLock : AccessShareLock));
 
        /* Check relation permissions. */
        aclresult = pg_class_aclcheck(RelationGetRelid(cstate->rel),
@@ -1009,7 +1009,7 @@ DoCopy(const CopyStmt *stmt)
         * rewriting or planning.  Do that now.
         *
         * Because the planner is not cool about not scribbling on its input,
-        * we make a preliminary copy of the source querytree.  This prevents
+        * we make a preliminary copy of the source querytree.  This prevents
         * problems in the case that the COPY is in a portal or plpgsql
         * function and is executed repeatedly.  (See also the same hack in
         * EXPLAIN, DECLARE CURSOR and PREPARE.)  XXX the planner really
@@ -1124,8 +1124,8 @@ DoCopy(const CopyStmt *stmt)
 
    /*
     * Set up encoding conversion info.  Even if the client and server
-    * encodings are the same, we must apply pg_client_to_server() to
-    * validate data in multibyte encodings.
+    * encodings are the same, we must apply pg_client_to_server() to validate
+    * data in multibyte encodings.
     */
    cstate->client_encoding = pg_get_client_encoding();
    cstate->need_transcoding =
@@ -1139,7 +1139,8 @@ DoCopy(const CopyStmt *stmt)
 
    if (is_from)                /* copy from file to database */
        CopyFrom(cstate);
-   else                        /* copy from database to file */
+   else
+       /* copy from database to file */
        DoCopyTo(cstate);
 
    /*
@@ -1210,12 +1211,12 @@ DoCopyTo(CopyState cstate)
    }
    else
    {
-       mode_t      oumask; /* Pre-existing umask value */
+       mode_t      oumask;     /* Pre-existing umask value */
        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(cstate->filename))
            ereport(ERROR,
@@ -1351,7 +1352,7 @@ CopyTo(CopyState cstate)
         */
        if (cstate->need_transcoding)
            cstate->null_print_client = pg_server_to_client(cstate->null_print,
-                                                   cstate->null_print_len);
+                                                    cstate->null_print_len);
 
        /* if a header has been requested send the line */
        if (cstate->header_line)
@@ -1508,7 +1509,7 @@ CopyOneRowTo(CopyState cstate, Oid tupleOid, Datum *values, bool *nulls)
    CopySendEndOfRow(cstate);
 
    MemoryContextSwitchTo(oldcontext);
-       
+
    cstate->processed++;
 }
 
@@ -2237,6 +2238,7 @@ CopyReadLineText(CopyState cstate)
    bool        hit_eof = false;
    bool        result = false;
    char        mblen_str[2];
+
    /* CSV variables */
    bool        first_char_in_line = true;
    bool        in_quote = false,
@@ -2268,10 +2270,10 @@ CopyReadLineText(CopyState cstate)
     * assumed the same in frontend and backend encodings.
     *
     * For speed, we try to move data from raw_buf to line_buf in chunks
-     * rather than one character at a time.  raw_buf_ptr points to the next
+    * 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.
+    * 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.
@@ -2286,14 +2288,14 @@ CopyReadLineText(CopyState cstate)
        char        c;
 
        /*
-        *  Load more data if needed.  Ideally we would just force four bytes
-        *  of read-ahead and avoid the many calls to
-        *  IF_NEED_REFILL_AND_NOT_EOF_CONTINUE(), but the COPY_OLD_FE
-        *  protocol does not allow us to read too far ahead or we might
-        *  read into the next data, so we read-ahead only as far we know
-        *  we can.  One optimization would be to read-ahead four byte here
-        *  if cstate->copy_dest != COPY_OLD_FE, but it hardly seems worth it,
-        *  considering the size of the buffer.
+        * Load more data if needed.  Ideally we would just force four bytes
+        * of read-ahead and avoid the many calls to
+        * IF_NEED_REFILL_AND_NOT_EOF_CONTINUE(), but the COPY_OLD_FE protocol
+        * does not allow us to read too far ahead or we might read into the
+        * next data, so we read-ahead only as far we know we can.  One
+        * optimization would be to read-ahead four byte here if
+        * cstate->copy_dest != COPY_OLD_FE, but it hardly seems worth it,
+        * considering the size of the buffer.
         */
        if (raw_buf_ptr >= copy_buf_len || need_data)
        {
@@ -2328,12 +2330,12 @@ CopyReadLineText(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')
            {
@@ -2341,12 +2343,12 @@ CopyReadLineText(CopyState cstate)
            }
 
            /*
-            * 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;
@@ -2357,9 +2359,9 @@ CopyReadLineText(CopyState cstate)
 
            /*
             * 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?)
+            * 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++;
@@ -2394,12 +2396,13 @@ CopyReadLineText(CopyState cstate)
                    if (cstate->eol_type == EOL_CRNL)
                        ereport(ERROR,
                                (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
-                            errmsg(!cstate->csv_mode ?
+                                errmsg(!cstate->csv_mode ?
                                    "literal carriage return found in data" :
-                                   "unquoted carriage return found in data"),
+                                  "unquoted carriage return found in data"),
                                 errhint(!cstate->csv_mode ?
-                                       "Use \"\\r\" to represent carriage return." :
-                                       "Use quoted CSV field to represent carriage return.")));
+                               "Use \"\\r\" to represent carriage return." :
+                                        "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
@@ -2410,12 +2413,12 @@ CopyReadLineText(CopyState cstate)
            else if (cstate->eol_type == EOL_NL)
                ereport(ERROR,
                        (errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
-                    errmsg(!cstate->csv_mode ?
+                        errmsg(!cstate->csv_mode ?
                                "literal carriage return found in data" :
                                "unquoted carriage return found in data"),
                         errhint(!cstate->csv_mode ?
-                               "Use \"\\r\" to represent carriage return." :
-                               "Use quoted CSV field to represent carriage return.")));
+                                "Use \"\\r\" to represent carriage return." :
+                    "Use quoted CSV field to represent carriage return.")));
            /* If reach here, we have found the line terminator */
            break;
        }
@@ -2431,15 +2434,15 @@ CopyReadLineText(CopyState cstate)
                                "unquoted newline found in data"),
                         errhint(!cstate->csv_mode ?
                                 "Use \"\\n\" to represent newline." :
-                                "Use quoted CSV field to represent newline.")));
+                            "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;
        }
 
        /*
-        *  In CSV mode, we only recognize \. alone on a line.  This is
-        *  because \. is a valid CSV data value.
+        * In CSV mode, we only recognize \. alone on a line.  This is because
+        * \. is a valid CSV data value.
         */
        if (c == '\\' && (!cstate->csv_mode || first_char_in_line))
        {
@@ -2529,23 +2532,24 @@ CopyReadLineText(CopyState cstate)
                break;
            }
            else if (!cstate->csv_mode)
+
                /*
-                *  If we are here, it means we found a backslash followed by
-                *  something other than a period.  In non-CSV mode, anything
-                *  after a backslash is special, so we skip over that second
-                *  character too.  If we didn't do that \\. would be
-                *  considered an eof-of copy, while in non-CVS mode it is a
-                *  literal backslash followed by a period.  In CSV mode,
-                *  backslashes are not special, so we want to process the
-                *  character after the backslash just like a normal character,
-                *  so we don't increment in those cases.
+                * If we are here, it means we found a backslash followed by
+                * something other than a period.  In non-CSV mode, anything
+                * after a backslash is special, so we skip over that second
+                * character too.  If we didn't do that \\. would be
+                * considered an eof-of copy, while in non-CVS mode it is a
+                * literal backslash followed by a period.  In CSV mode,
+                * backslashes are not special, so we want to process the
+                * character after the backslash just like a normal character,
+                * so we don't increment in those cases.
                 */
                raw_buf_ptr++;
        }
 
        /*
-        * This label is for CSV cases where \. appears at the start of a line,
-        * but there is more text after it, meaning it was a data value.
+        * This label is for CSV cases where \. appears at the start of a
+        * line, but there is more text after it, meaning it was a data value.
         * We are more strict for \. in CSV mode because \. could be a data
         * value, while in non-CSV mode, \. cannot be a data value.
         */
@@ -2554,9 +2558,9 @@ not_end_of_copy:
        /*
         * Process all bytes of a multi-byte character as a group.
         *
-        * We only support multi-byte sequences where the first byte
-        * has the high-bit set, so as an optimization we can avoid
-        * this block entirely if it is not set.
+        * We only support multi-byte sequences where the first byte has the
+        * high-bit set, so as an optimization we can avoid this block
+        * entirely if it is not set.
         */
        if (cstate->encoding_embeds_ascii && IS_HIGHBIT_SET(c))
        {
@@ -3040,10 +3044,10 @@ CopyAttributeOutText(CopyState cstate, char *string)
    /*
     * We have to grovel through the string searching for control characters
     * and instances of the delimiter character.  In most cases, though, these
-    * are infrequent.  To avoid overhead from calling CopySendData once per
-    * character, we dump out all characters between replaceable characters
-    * in a single call.  The loop invariant is that the data from "start"
-    * to "ptr" can be sent literally, but hasn't yet been.
+    * are infrequent.  To avoid overhead from calling CopySendData once per
+    * character, we dump out all characters between replaceable characters in
+    * a single call.  The loop invariant is that the data from "start" to
+    * "ptr" can be sent literally, but hasn't yet been.
     */
    start = ptr;
    while ((c = *ptr) != '\0')
@@ -3090,7 +3094,7 @@ CopyAttributeOutText(CopyState cstate, char *string)
                {
                    DUMPSOFAR();
                    CopySendChar(cstate, '\\');
-                   start = ptr; /* we include char in next run */
+                   start = ptr;    /* we include char in next run */
                }
 
                /*
@@ -3139,14 +3143,13 @@ CopyAttributeOutCSV(CopyState cstate, char *string,
    if (!use_quote)
    {
        /*
-        *  Because '\.' can be a data value, quote it if it appears
-        *  alone on a line so it is not interpreted as the end-of-data
-        *  marker.
+        * Because '\.' can be a data value, quote it if it appears alone on a
+        * line so it is not interpreted as the end-of-data marker.
         */
        if (single_attr && strcmp(ptr, "\\.") == 0)
-           use_quote = true;
-       else
-       {
+           use_quote = true;
+       else
+       {
            char       *tptr = ptr;
 
            while ((c = *tptr) != '\0')
@@ -3251,14 +3254,14 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
            {
                if (rel != NULL)
                    ereport(ERROR,
-                       (errcode(ERRCODE_UNDEFINED_COLUMN),
-                        errmsg("column \"%s\" of relation \"%s\" does not exist",
-                               name, RelationGetRelationName(rel))));
+                           (errcode(ERRCODE_UNDEFINED_COLUMN),
+                   errmsg("column \"%s\" of relation \"%s\" does not exist",
+                          name, RelationGetRelationName(rel))));
                else
                    ereport(ERROR,
-                       (errcode(ERRCODE_UNDEFINED_COLUMN),
-                        errmsg("column \"%s\" does not exist",
-                               name)));
+                           (errcode(ERRCODE_UNDEFINED_COLUMN),
+                            errmsg("column \"%s\" does not exist",
+                                   name)));
            }
            /* Check for duplicates */
            if (list_member_int(attnums, attnum))
@@ -3289,7 +3292,7 @@ copy_dest_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
 static void
 copy_dest_receive(TupleTableSlot *slot, DestReceiver *self)
 {
-   DR_copy    *myState = (DR_copy *) self;
+   DR_copy    *myState = (DR_copy *) self;
    CopyState   cstate = myState->cstate;
 
    /* Make sure the tuple is fully deconstructed */
@@ -3323,7 +3326,7 @@ copy_dest_destroy(DestReceiver *self)
 DestReceiver *
 CreateCopyDestReceiver(void)
 {
-   DR_copy *self = (DR_copy *) palloc(sizeof(DR_copy));
+   DR_copy    *self = (DR_copy *) palloc(sizeof(DR_copy));
 
    self->pub.receiveSlot = copy_dest_receive;
    self->pub.rStartup = copy_dest_startup;
index 853c7e66268e3926ac04b71710b01602f313f22e..d7d4cdbfbc42554f895e829d35c31b6962b1552b 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.184 2006/07/14 14:52:18 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.185 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -326,9 +326,9 @@ createdb(const CreatedbStmt *stmt)
    }
 
    /*
-    * Check for db name conflict.  This is just to give a more friendly
-    * error message than "unique index violation".  There's a race condition
-    * but we're willing to accept the less friendly message in that case.
+    * Check for db name conflict.  This is just to give a more friendly error
+    * message than "unique index violation".  There's a race condition but
+    * we're willing to accept the less friendly message in that case.
     */
    if (OidIsValid(get_database_oid(dbname)))
        ereport(ERROR,
@@ -336,10 +336,10 @@ createdb(const CreatedbStmt *stmt)
                 errmsg("database \"%s\" already exists", dbname)));
 
    /*
-    * Insert a new tuple into pg_database.  This establishes our ownership
-    * of the new database name (anyone else trying to insert the same name
-    * will block on the unique index, and fail after we commit).  It also
-    * assigns the OID that the new database will have.
+    * Insert a new tuple into pg_database.  This establishes our ownership of
+    * the new database name (anyone else trying to insert the same name will
+    * block on the unique index, and fail after we commit).  It also assigns
+    * the OID that the new database will have.
     */
    pg_database_rel = heap_open(DatabaseRelationId, RowExclusiveLock);
 
@@ -361,9 +361,9 @@ createdb(const CreatedbStmt *stmt)
 
    /*
     * We deliberately set datconfig and datacl to defaults (NULL), rather
-    * than copying them from the template database.  Copying datacl would
-    * be a bad idea when the owner is not the same as the template's
-    * owner. It's more debatable whether datconfig should be copied.
+    * than copying them from the template database.  Copying datacl would be
+    * a bad idea when the owner is not the same as the template's owner. It's
+    * more debatable whether datconfig should be copied.
     */
    new_record_nulls[Anum_pg_database_datconfig - 1] = 'n';
    new_record_nulls[Anum_pg_database_datacl - 1] = 'n';
@@ -497,8 +497,8 @@ createdb(const CreatedbStmt *stmt)
        RequestCheckpoint(true, false);
 
        /*
-        * Close pg_database, but keep lock till commit (this is important
-        * to prevent any risk of deadlock failure while updating flat file)
+        * Close pg_database, but keep lock till commit (this is important to
+        * prevent any risk of deadlock failure while updating flat file)
         */
        heap_close(pg_database_rel, NoLock);
 
@@ -543,8 +543,8 @@ dropdb(const char *dbname, bool missing_ok)
                 errmsg("cannot drop the currently open database")));
 
    /*
-    * Look up the target database's OID, and get exclusive lock on it.
-    * We need this to ensure that no new backend starts up in the target
+    * Look up the target database's OID, and get exclusive lock on it. We
+    * need this to ensure that no new backend starts up in the target
     * database while we are deleting it (see postinit.c), and that no one is
     * using it as a CREATE DATABASE template or trying to delete it for
     * themselves.
@@ -589,8 +589,8 @@ dropdb(const char *dbname, bool missing_ok)
                 errmsg("cannot drop a template database")));
 
    /*
-    * Check for active backends in the target database.  (Because we hold
-    * the database lock, no new ones can start after this.)
+    * Check for active backends in the target database.  (Because we hold the
+    * database lock, no new ones can start after this.)
     */
    if (DatabaseHasActiveBackends(db_id, false))
        ereport(ERROR,
@@ -647,8 +647,8 @@ dropdb(const char *dbname, bool missing_ok)
    remove_dbtablespaces(db_id);
 
    /*
-    * Close pg_database, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_database, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(pgdbrel, NoLock);
 
@@ -670,8 +670,8 @@ RenameDatabase(const char *oldname, const char *newname)
    Relation    rel;
 
    /*
-    * Look up the target database's OID, and get exclusive lock on it.
-    * We need this for the same reasons as DROP DATABASE.
+    * Look up the target database's OID, and get exclusive lock on it. We
+    * need this for the same reasons as DROP DATABASE.
     */
    rel = heap_open(DatabaseRelationId, RowExclusiveLock);
 
@@ -693,8 +693,8 @@ RenameDatabase(const char *oldname, const char *newname)
                 errmsg("current database may not be renamed")));
 
    /*
-    * Make sure the database does not have active sessions.  This is the
-    * same concern as above, but applied to other sessions.
+    * Make sure the database does not have active sessions.  This is the same
+    * concern as above, but applied to other sessions.
     */
    if (DatabaseHasActiveBackends(db_id, false))
        ereport(ERROR,
@@ -730,8 +730,8 @@ RenameDatabase(const char *oldname, const char *newname)
    CatalogUpdateIndexes(rel, newtup);
 
    /*
-    * Close pg_database, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_database, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(rel, NoLock);
 
@@ -1067,9 +1067,9 @@ get_db_info(const char *name, LOCKMODE lockmode,
    relation = heap_open(DatabaseRelationId, AccessShareLock);
 
    /*
-    * Loop covers the rare case where the database is renamed before we
-    * can lock it.  We try again just in case we can find a new one of
-    * the same name.
+    * Loop covers the rare case where the database is renamed before we can
+    * lock it.  We try again just in case we can find a new one of the same
+    * name.
     */
    for (;;)
    {
@@ -1079,8 +1079,8 @@ get_db_info(const char *name, LOCKMODE lockmode,
        Oid         dbOid;
 
        /*
-        * there's no syscache for database-indexed-by-name,
-        * so must do it the hard way
+        * there's no syscache for database-indexed-by-name, so must do it the
+        * hard way
         */
        ScanKeyInit(&scanKey,
                    Anum_pg_database_datname,
@@ -1110,9 +1110,9 @@ get_db_info(const char *name, LOCKMODE lockmode,
            LockSharedObject(DatabaseRelationId, dbOid, 0, lockmode);
 
        /*
-        * And now, re-fetch the tuple by OID.  If it's still there and
-        * still the same name, we win; else, drop the lock and loop
-        * back to try again.
+        * And now, re-fetch the tuple by OID.  If it's still there and still
+        * the same name, we win; else, drop the lock and loop back to try
+        * again.
         */
        tuple = SearchSysCache(DATABASEOID,
                               ObjectIdGetDatum(dbOid),
@@ -1267,8 +1267,8 @@ get_database_oid(const char *dbname)
    Oid         oid;
 
    /*
-    * There's no syscache for pg_database indexed by name,
-    * so we must look the hard way.
+    * There's no syscache for pg_database indexed by name, so we must look
+    * the hard way.
     */
    pg_database = heap_open(DatabaseRelationId, AccessShareLock);
    ScanKeyInit(&entry[0],
@@ -1399,15 +1399,15 @@ dbase_desc(StringInfo buf, uint8 xl_info, char *rec)
        xl_dbase_create_rec *xlrec = (xl_dbase_create_rec *) rec;
 
        appendStringInfo(buf, "create db: copy dir %u/%u to %u/%u",
-               xlrec->src_db_id, xlrec->src_tablespace_id,
-               xlrec->db_id, xlrec->tablespace_id);
+                        xlrec->src_db_id, xlrec->src_tablespace_id,
+                        xlrec->db_id, xlrec->tablespace_id);
    }
    else if (info == XLOG_DBASE_DROP)
    {
        xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
 
        appendStringInfo(buf, "drop db: dir %u/%u",
-               xlrec->db_id, xlrec->tablespace_id);
+                        xlrec->db_id, xlrec->tablespace_id);
    }
    else
        appendStringInfo(buf, "UNKNOWN");
index 149e1b6dae0de20ffaa676922950d9c2e3a373c1..697678c4aa8cca8ca38a7fef3c741aab1dbdef63 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.97 2006/07/03 22:45:38 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.98 2006/10/04 00:29:51 momjian Exp $
  *
  * DESCRIPTION
  *   The "DefineFoo" routines take the parse tree and pick out the
@@ -131,6 +131,7 @@ defGetBoolean(DefElem *def)
     */
    if (def->arg == NULL)
        return true;
+
    /*
     * Allow 0, 1, "true", "false"
     */
@@ -150,7 +151,7 @@ defGetBoolean(DefElem *def)
            break;
        default:
            {
-               char   *sval = defGetString(def);
+               char       *sval = defGetString(def);
 
                if (pg_strcasecmp(sval, "true") == 0)
                    return true;
@@ -310,9 +311,9 @@ defGetTypeLength(DefElem *def)
 DefElem *
 defWithOids(bool value)
 {
-   DefElem *f = makeNode(DefElem);
+   DefElem    *f = makeNode(DefElem);
 
    f->defname = "oids";
-   f->arg = (Node *)makeInteger(value);
+   f->arg = (Node *) makeInteger(value);
    return f;
 }
index 48db000ea9b2d832360b64b8ebb80e85ed1f318b..00ada3fc7224f33da8e5c7e892ed841d13298e3e 100644 (file)
@@ -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.151 2006/09/06 20:40:47 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.152 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -41,7 +41,7 @@ typedef struct ExplainState
 } ExplainState;
 
 static void ExplainOneQuery(Query *query, ExplainStmt *stmt,
-                           ParamListInfo params, TupOutputState *tstate);
+               ParamListInfo params, TupOutputState *tstate);
 static double elapsed_time(instr_time *starttime);
 static void explain_outNode(StringInfo str,
                Plan *plan, PlanState *planstate,
@@ -760,7 +760,7 @@ explain_outNode(StringInfo str,
                 * The tidquals list has OR semantics, so be sure to show it
                 * as an OR condition.
                 */
-               List *tidquals = ((TidScan *) plan)->tidquals;
+               List       *tidquals = ((TidScan *) plan)->tidquals;
 
                if (list_length(tidquals) > 1)
                    tidquals = list_make1(make_orclause(tidquals));
@@ -928,8 +928,8 @@ explain_outNode(StringInfo str,
            /*
             * Ordinarily we don't pass down our own outer_plan value to our
             * child nodes, but in an Append we must, since we might be
-            * looking at an appendrel indexscan with outer references
-            * from the member scans.
+            * looking at an appendrel indexscan with outer references from
+            * the member scans.
             */
            explain_outNode(str, subnode,
                            appendstate->appendplans[j],
index 615d4c93b292679cfb25c92f58dd1e261c8d9960..29954a27a826aa1d781db56a48d4d547183c77e3 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.78 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.79 2006/10/04 00:29:51 momjian Exp $
  *
  * DESCRIPTION
  *   These routines take the parse tree and pick out the
@@ -686,7 +686,7 @@ RemoveFunction(RemoveFuncStmt *stmt)
     * Find the function, do permissions and validity checks
     */
    funcOid = LookupFuncNameTypeNames(functionName, argTypes, stmt->missing_ok);
-   if (!OidIsValid(funcOid)) 
+   if (!OidIsValid(funcOid))
    {
        /* can only get here if stmt->missing_ok */
        ereport(NOTICE,
@@ -1394,7 +1394,7 @@ DropCast(DropCastStmt *stmt)
                           0, 0);
    if (!HeapTupleIsValid(tuple))
    {
-       if (! stmt->missing_ok)
+       if (!stmt->missing_ok)
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
                     errmsg("cast from type %s to type %s does not exist",
@@ -1402,7 +1402,7 @@ DropCast(DropCastStmt *stmt)
                            TypeNameToString(stmt->targettype))));
        else
            ereport(NOTICE,
-                    (errmsg("cast from type %s to type %s does not exist ... skipping",
+                   (errmsg("cast from type %s to type %s does not exist ... skipping",
                            TypeNameToString(stmt->sourcetype),
                            TypeNameToString(stmt->targettype))));
 
index 81246768bc9f72a420bff364ac77b31f131dfee5..5f54f66f59148f31d82df519870b76419dc78d62 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.148 2006/08/27 19:14:34 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.149 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,8 +125,8 @@ DefineIndex(RangeVar *heapRelation,
    LockRelId   heaprelid;
    LOCKTAG     heaplocktag;
    Snapshot    snapshot;
-   Relation pg_index;
-   HeapTuple indexTuple;
+   Relation    pg_index;
+   HeapTuple   indexTuple;
    Form_pg_index indexForm;
 
    /*
@@ -450,18 +450,18 @@ DefineIndex(RangeVar *heapRelation,
     * for an overview of how this works)
     *
     * We must commit our current transaction so that the index becomes
-    * visible; then start another.  Note that all the data structures
-    * we just built are lost in the commit.  The only data we keep past
-    * here are the relation IDs.
+    * visible; then start another.  Note that all the data structures we just
+    * built are lost in the commit.  The only data we keep past here are the
+    * relation IDs.
     *
     * Before committing, get a session-level lock on the table, to ensure
-    * that neither it nor the index can be dropped before we finish.
-    * This cannot block, even if someone else is waiting for access, because
-    * we already have the same lock within our transaction.
+    * that neither it nor the index can be dropped before we finish. This
+    * cannot block, even if someone else is waiting for access, because we
+    * already have the same lock within our transaction.
     *
     * Note: we don't currently bother with a session lock on the index,
-    * because there are no operations that could change its state while
-    * we hold lock on the parent table.  This might need to change later.
+    * because there are no operations that could change its state while we
+    * hold lock on the parent table.  This might need to change later.
     */
    heaprelid = rel->rd_lockInfo.lockRelId;
    LockRelationIdForSession(&heaprelid, ShareUpdateExclusiveLock);
@@ -471,15 +471,15 @@ DefineIndex(RangeVar *heapRelation,
 
    /*
     * Now we must wait until no running transaction could have the table open
-    * with the old list of indexes.  To do this, inquire which xacts currently
-    * would conflict with ShareLock on the table -- ie, which ones have
-    * a lock that permits writing the table.  Then wait for each of these
-    * xacts to commit or abort.  Note we do not need to worry about xacts
-    * that open the table for writing after this point; they will see the
-    * new index when they open it.
+    * with the old list of indexes.  To do this, inquire which xacts
+    * currently would conflict with ShareLock on the table -- ie, which ones
+    * have a lock that permits writing the table.  Then wait for each of
+    * these xacts to commit or abort.  Note we do not need to worry about
+    * xacts that open the table for writing after this point; they will see
+    * the new index when they open it.
     *
-    * Note: GetLockConflicts() never reports our own xid,
-    * hence we need not check for that.
+    * Note: GetLockConflicts() never reports our own xid, hence we need not
+    * check for that.
     */
    SET_LOCKTAG_RELATION(heaplocktag, heaprelid.dbId, heaprelid.relId);
    old_xact_list = GetLockConflicts(&heaplocktag, ShareLock);
@@ -493,12 +493,12 @@ DefineIndex(RangeVar *heapRelation,
 
    /*
     * Now take the "reference snapshot" that will be used by validate_index()
-    * to filter candidate tuples.  All other transactions running at this
+    * to filter candidate tuples.  All other transactions running at this
     * time will have to be out-waited before we can commit, because we can't
     * guarantee that tuples deleted just before this will be in the index.
     *
-    * We also set ActiveSnapshot to this snap, since functions in indexes
-    * may need a snapshot.
+    * We also set ActiveSnapshot to this snap, since functions in indexes may
+    * need a snapshot.
     */
    snapshot = CopySnapshot(GetTransactionSnapshot());
    ActiveSnapshot = snapshot;
@@ -510,13 +510,13 @@ DefineIndex(RangeVar *heapRelation,
 
    /*
     * The index is now valid in the sense that it contains all currently
-    * interesting tuples.  But since it might not contain tuples deleted
-    * just before the reference snap was taken, we have to wait out any
-    * transactions older than the reference snap.  We can do this by
-    * waiting for each xact explicitly listed in the snap.
+    * interesting tuples.  But since it might not contain tuples deleted just
+    * before the reference snap was taken, we have to wait out any
+    * transactions older than the reference snap.  We can do this by waiting
+    * for each xact explicitly listed in the snap.
     *
-    * Note: GetSnapshotData() never stores our own xid into a snap,
-    * hence we need not check for that.
+    * Note: GetSnapshotData() never stores our own xid into a snap, hence we
+    * need not check for that.
     */
    for (ixcnt = 0; ixcnt < snapshot->xcnt; ixcnt++)
        XactLockTableWait(snapshot->xip[ixcnt]);
index 5d77e056e13d406702dac336d7c80d1d887aeec9..4407e2785c0de74b6ab05c0e1874b47b4e3f1c7e 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.48 2006/07/18 17:42:00 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.49 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -128,7 +128,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
     * A minimum expectation therefore is that the caller have execute
     * privilege with grant option.  Since we don't have a way to make the
     * opclass go away if the grant option is revoked, we choose instead to
-    * require ownership of the functions.  It's also not entirely clear what
+    * require ownership of the functions.  It's also not entirely clear what
     * permissions should be required on the datatype, but ownership seems
     * like a safe choice.
     *
@@ -699,7 +699,7 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
        opcID = OpclassnameGetOpcid(amID, opcname);
        if (!OidIsValid(opcID))
        {
-           if (! stmt -> missing_ok )
+           if (!stmt->missing_ok)
                ereport(ERROR,
                        (errcode(ERRCODE_UNDEFINED_OBJECT),
                         errmsg("operator class \"%s\" does not exist for access method \"%s\"",
@@ -708,10 +708,10 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
                ereport(NOTICE,
                        (errmsg("operator class \"%s\" does not exist for access method \"%s\"",
                                opcname, stmt->amname)));
-           
+
            return;
        }
+
        tuple = SearchSysCache(CLAOID,
                               ObjectIdGetDatum(opcID),
                               0, 0, 0);
@@ -719,19 +719,19 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
 
    if (!HeapTupleIsValid(tuple))
    {
-  
-       if (! stmt->missing_ok )
+
+       if (!stmt->missing_ok)
            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)));
        else
            ereport(NOTICE,
                    (errmsg("operator class \"%s\" does not exist for access method \"%s\"",
-                           NameListToString(stmt->opclassname), stmt->amname)));
+                       NameListToString(stmt->opclassname), stmt->amname)));
        return;
    }
-   
+
    opcID = HeapTupleGetOid(tuple);
 
    /* Permission check: must own opclass or its namespace */
index 2aed55ed453f9bd6bdd511eccc6e4ff0c5c76512..76884e8cd82ce1e40fd27265c6202f7c9bb5154e 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.32 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.33 2006/10/04 00:29:51 momjian Exp $
  *
  * DESCRIPTION
  *   The "DefineFoo" routines take the parse tree and pick out the
@@ -214,14 +214,14 @@ RemoveOperator(RemoveFuncStmt *stmt)
    operOid = LookupOperNameTypeNames(NULL, operatorName,
                                      typeName1, typeName2,
                                      stmt->missing_ok, -1);
-   if (stmt->missing_ok &&!OidIsValid(operOid) )
-   {
-       ereport(NOTICE,
-               (errmsg("operator %s does not exist, skipping",
-                       NameListToString(operatorName))));
-       return;
-   }
+
+   if (stmt->missing_ok && !OidIsValid(operOid))
+   {
+       ereport(NOTICE,
+               (errmsg("operator %s does not exist, skipping",
+                       NameListToString(operatorName))));
+       return;
+   }
 
    tup = SearchSysCache(OPEROID,
                         ObjectIdGetDatum(operOid),
index 48833e7dc0472c69d6df70cff7cd37a5bc1f1af0..8907aac8a95bb50d4fc3f258d88e8de483b6c6a5 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.55 2006/09/07 22:52:00 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.56 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -108,8 +108,8 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params)
    plan = copyObject(plan);
 
    /*
-    * XXX: debug_query_string is wrong here: the user might have
-    * submitted multiple semicolon delimited queries.
+    * XXX: debug_query_string is wrong here: the user might have submitted
+    * multiple semicolon delimited queries.
     */
    PortalDefineQuery(portal,
                      NULL,
index 46824a48e5dc8bf8849774a3d4541c09dbbf2f22..6b7c11a189460e83828ac007dbf0be38bc4ebad8 100644 (file)
@@ -10,7 +10,7 @@
  * Copyright (c) 2002-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.65 2006/09/27 18:40:09 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.66 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -162,7 +162,7 @@ ExecuteQuery(ExecuteStmt *stmt, ParamListInfo params,
    portal = CreateNewPortal();
    /* Don't display the portal in pg_cursors, it is for internal use only */
    portal->visible = false;
-   
+
    /*
     * 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).
@@ -251,7 +251,7 @@ EvaluateParams(EState *estate, List *params, List *argtypes)
 
    /* sizeof(ParamListInfoData) includes the first array element */
    paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
-                                    (nargs - 1) * sizeof(ParamExternData));
+                                    (nargs - 1) *sizeof(ParamExternData));
    paramLI->numParams = nargs;
 
    forboth(le, exprstates, la, argtypes)
@@ -674,22 +674,21 @@ ExplainExecuteQuery(ExplainStmt *stmt, ParamListInfo params,
 Datum
 pg_prepared_statement(PG_FUNCTION_ARGS)
 {
-   FuncCallContext    *funcctx;
-   HASH_SEQ_STATUS    *hash_seq;
-   PreparedStatement  *prep_stmt;
+   FuncCallContext *funcctx;
+   HASH_SEQ_STATUS *hash_seq;
+   PreparedStatement *prep_stmt;
 
    /* stuff done only on the first call of the function */
    if (SRF_IS_FIRSTCALL())
    {
-       TupleDesc       tupdesc;
-       MemoryContext   oldcontext;
+       TupleDesc   tupdesc;
+       MemoryContext oldcontext;
 
        /* create a function context for cross-call persistence */
        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);
 
@@ -704,9 +703,8 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
            funcctx->user_fctx = NULL;
 
        /*
-        * build tupdesc for result tuples. This must match the
-        * definition of the pg_prepared_statements view in
-        * system_views.sql
+        * build tupdesc for result tuples. This must match the definition of
+        * the pg_prepared_statements view in system_views.sql
         */
        tupdesc = CreateTemplateTupleDesc(5, false);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
@@ -735,21 +733,21 @@ pg_prepared_statement(PG_FUNCTION_ARGS)
    prep_stmt = hash_seq_search(hash_seq);
    if (prep_stmt)
    {
-       Datum           result;
-       HeapTuple       tuple;
-       Datum           values[5];
-       bool            nulls[5];
+       Datum       result;
+       HeapTuple   tuple;
+       Datum       values[5];
+       bool        nulls[5];
 
        MemSet(nulls, 0, sizeof(nulls));
 
        values[0] = DirectFunctionCall1(textin,
-                                       CStringGetDatum(prep_stmt->stmt_name));
+                                     CStringGetDatum(prep_stmt->stmt_name));
 
        if (prep_stmt->query_string == NULL)
            nulls[1] = true;
        else
            values[1] = DirectFunctionCall1(textin,
-                                   CStringGetDatum(prep_stmt->query_string));
+                                  CStringGetDatum(prep_stmt->query_string));
 
        values[2] = TimestampTzGetDatum(prep_stmt->prepare_time);
        values[3] = build_regtype_array(prep_stmt->argtype_list);
@@ -783,8 +781,8 @@ build_regtype_array(List *oid_list)
    i = 0;
    foreach(lc, oid_list)
    {
-       Oid     oid;
-       Datum   oid_str;
+       Oid         oid;
+       Datum       oid_str;
 
        oid = lfirst_oid(lc);
        oid_str = DirectFunctionCall1(oidout, ObjectIdGetDatum(oid));
index f91242470a1fca7fd40112bda5cd96e0511dbc0a..7906f587b78b1f3f337066dc8e3c92c85461958f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.68 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.69 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -395,15 +395,15 @@ DropProceduralLanguage(DropPLangStmt *stmt)
                             0, 0, 0);
    if (!HeapTupleIsValid(langTup))
    {
-       if (! stmt->missing_ok)
+       if (!stmt->missing_ok)
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
                     errmsg("language \"%s\" does not exist", languageName)));
-       else 
+       else
            ereport(NOTICE,
-                   (errmsg("language \"%s\" does not exist, skipping", 
+                   (errmsg("language \"%s\" does not exist, skipping",
                            languageName)));
+
        return;
    }
 
index 865c2f60fe5527e008fd14c74163e20eb5091d53..9d769cb052c0f57786d692fcde3591bda22f5886 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.139 2006/08/21 00:57:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.140 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -85,7 +85,7 @@ static Relation open_share_lock(SeqTable seq);
 static void init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel);
 static Form_pg_sequence read_info(SeqTable elm, Relation rel, Buffer *buf);
 static void init_params(List *options, bool isInit,
-                       Form_pg_sequence new, List **owned_by);
+           Form_pg_sequence new, List **owned_by);
 static void do_setval(Oid relid, int64 next, bool iscalled);
 static void process_owned_by(Relation seqrel, List *owned_by);
 
@@ -862,7 +862,7 @@ open_share_lock(SeqTable seq)
 static void
 init_sequence(Oid relid, SeqTable *p_elm, Relation *p_rel)
 {
-   SeqTable elm;
+   SeqTable    elm;
    Relation    seqrel;
 
    /* Look to see if we already have a seqtable entry for relation */
@@ -1180,7 +1180,7 @@ process_owned_by(Relation seqrel, List *owned_by)
            ereport(ERROR,
                    (errcode(ERRCODE_SYNTAX_ERROR),
                     errmsg("invalid OWNED BY option"),
-                    errhint("Specify OWNED BY table.column or OWNED BY NONE.")));
+               errhint("Specify OWNED BY table.column or OWNED BY NONE.")));
        tablerel = NULL;
        attnum = 0;
    }
@@ -1209,7 +1209,7 @@ process_owned_by(Relation seqrel, List *owned_by)
        if (seqrel->rd_rel->relowner != tablerel->rd_rel->relowner)
            ereport(ERROR,
                    (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-                    errmsg("sequence must have same owner as table it is owned by")));
+           errmsg("sequence must have same owner as table it is owned by")));
        if (RelationGetNamespace(seqrel) != RelationGetNamespace(tablerel))
            ereport(ERROR,
                    (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
@@ -1225,8 +1225,8 @@ process_owned_by(Relation seqrel, List *owned_by)
    }
 
    /*
-    * OK, we are ready to update pg_depend.  First remove any existing
-    * AUTO dependencies for the sequence, then optionally add a new one.
+    * OK, we are ready to update pg_depend.  First remove any existing AUTO
+    * dependencies for the sequence, then optionally add a new one.
     */
    markSequenceUnowned(RelationGetRelid(seqrel));
 
@@ -1304,5 +1304,5 @@ seq_desc(StringInfo buf, uint8 xl_info, char *rec)
    }
 
    appendStringInfo(buf, "rel %u/%u/%u",
-           xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode);
+              xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode);
 }
index 45167b816af42e259cf48cc595fa7bad29d614e5..04c2a03aa8a18c4763adfa189e1b691939ae1dd1 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.202 2006/09/04 21:15:55 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.203 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -166,7 +166,7 @@ static void MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
 static bool change_varattnos_walker(Node *node, const AttrNumber *newattno);
 static void StoreCatalogInheritance(Oid relationId, List *supers);
 static void StoreCatalogInheritance1(Oid relationId, Oid parentOid,
-                   int16 seqNumber, Relation catalogRelation);
+                        int16 seqNumber, Relation catalogRelation);
 static int findAttrByName(const char *attributeName, List *schema);
 static void setRelhassubclassInRelation(Oid relationId, bool relhassubclass);
 static void AlterIndexNamespaces(Relation classRel, Relation rel,
@@ -566,18 +566,18 @@ ExecuteTruncate(TruncateStmt *stmt)
    }
 
    /*
-    * In CASCADE mode, suck in all referencing relations as well.  This
-    * requires multiple iterations to find indirectly-dependent relations.
-    * At each phase, we need to exclusive-lock new rels before looking
-    * for their dependencies, else we might miss something.  Also, we
-    * check each rel as soon as we open it, to avoid a faux pas such as
-    * holding lock for a long time on a rel we have no permissions for.
+    * In CASCADE mode, suck in all referencing relations as well.  This
+    * requires multiple iterations to find indirectly-dependent relations. At
+    * each phase, we need to exclusive-lock new rels before looking for their
+    * dependencies, else we might miss something.  Also, we check each rel as
+    * soon as we open it, to avoid a faux pas such as holding lock for a long
+    * time on a rel we have no permissions for.
     */
    if (stmt->behavior == DROP_CASCADE)
    {
        for (;;)
        {
-           List   *newrelids;
+           List       *newrelids;
 
            newrelids = heap_truncate_find_FKs(relids);
            if (newrelids == NIL)
@@ -585,7 +585,7 @@ ExecuteTruncate(TruncateStmt *stmt)
 
            foreach(cell, newrelids)
            {
-               Oid     relid = lfirst_oid(cell);
+               Oid         relid = lfirst_oid(cell);
                Relation    rel;
 
                rel = heap_open(relid, AccessExclusiveLock);
@@ -601,8 +601,8 @@ ExecuteTruncate(TruncateStmt *stmt)
 
    /*
     * Check foreign key references.  In CASCADE mode, this should be
-    * unnecessary since we just pulled in all the references; but as
-    * cross-check, do it anyway if in an Assert-enabled build.
+    * unnecessary since we just pulled in all the references; but as a
+    * cross-check, do it anyway if in an Assert-enabled build.
     */
 #ifdef USE_ASSERT_CHECKING
    heap_truncate_check_FKs(rels, false);
@@ -612,9 +612,9 @@ ExecuteTruncate(TruncateStmt *stmt)
 #endif
 
    /*
-    * Also check for pending AFTER trigger events on the target relations.
-    * We can't just leave those be, since they will try to fetch tuples
-    * that the TRUNCATE removes.
+    * Also check for pending AFTER trigger events on the target relations. We
+    * can't just leave those be, since they will try to fetch tuples that the
+    * TRUNCATE removes.
     */
    AfterTriggerCheckTruncate(relids);
 
@@ -657,7 +657,7 @@ ExecuteTruncate(TruncateStmt *stmt)
 }
 
 /*
- * Check that a given rel is safe to truncate.  Subroutine for ExecuteTruncate
+ * Check that a given rel is safe to truncate. Subroutine for ExecuteTruncate
  */
 static void
 truncate_check_rel(Relation rel)
@@ -681,9 +681,8 @@ truncate_check_rel(Relation rel)
                        RelationGetRelationName(rel))));
 
    /*
-    * We can never allow truncation of shared or nailed-in-cache
-    * relations, because we can't support changing their relfilenode
-    * values.
+    * We can never allow truncation of shared or nailed-in-cache relations,
+    * because we can't support changing their relfilenode values.
     */
    if (rel->rd_rel->relisshared || rel->rd_isnailed)
        ereport(ERROR,
@@ -692,13 +691,13 @@ truncate_check_rel(Relation rel)
                        RelationGetRelationName(rel))));
 
    /*
-    * Don't allow truncate on temp tables of other backends ... their
-    * local buffer manager is not going to cope.
+    * Don't allow truncate on 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 truncate temporary tables of other sessions")));
+             errmsg("cannot truncate temporary tables of other sessions")));
 }
 
 /*----------
@@ -1141,16 +1140,20 @@ change_varattnos_of_a_node(Node *node, const AttrNumber *newattno)
 AttrNumber *
 varattnos_map(TupleDesc old, TupleDesc new)
 {
-   int i,j;
-   AttrNumber *attmap = palloc0(sizeof(AttrNumber)*old->natts);
-   for (i=1; i <= old->natts; i++) {
-       if (old->attrs[i-1]->attisdropped) {
-           attmap[i-1] = 0;
+   int         i,
+               j;
+   AttrNumber *attmap = palloc0(sizeof(AttrNumber) * old->natts);
+
+   for (i = 1; i <= old->natts; i++)
+   {
+       if (old->attrs[i - 1]->attisdropped)
+       {
+           attmap[i - 1] = 0;
            continue;
        }
-       for (j=1; j<= new->natts; j++)
-           if (!strcmp(NameStr(old->attrs[i-1]->attname), NameStr(new->attrs[j-1]->attname)))
-               attmap[i-1] = j;
+       for (j = 1; j <= new->natts; j++)
+           if (!strcmp(NameStr(old->attrs[i - 1]->attname), NameStr(new->attrs[j - 1]->attname)))
+               attmap[i - 1] = j;
    }
    return attmap;
 }
@@ -1160,16 +1163,19 @@ varattnos_map(TupleDesc old, TupleDesc new)
  * ColumnDefs
  */
 AttrNumber *
-varattnos_map_schema(TupleDesc old, List *schema) 
+varattnos_map_schema(TupleDesc old, List *schema)
 {
-   int i;
-   AttrNumber *attmap = palloc0(sizeof(AttrNumber)*old->natts);
-   for (i=1; i <= old->natts; i++) {
-       if (old->attrs[i-1]->attisdropped) {
-           attmap[i-1] = 0;
+   int         i;
+   AttrNumber *attmap = palloc0(sizeof(AttrNumber) * old->natts);
+
+   for (i = 1; i <= old->natts; i++)
+   {
+       if (old->attrs[i - 1]->attisdropped)
+       {
+           attmap[i - 1] = 0;
            continue;
        }
-       attmap[i-1] = findAttrByName(NameStr(old->attrs[i-1]->attname), schema);
+       attmap[i - 1] = findAttrByName(NameStr(old->attrs[i - 1]->attname), schema);
    }
    return attmap;
 }
@@ -1244,14 +1250,14 @@ StoreCatalogInheritance(Oid relationId, List *supers)
 
 static void
 StoreCatalogInheritance1(Oid relationId, Oid parentOid,
-                        int16 seqNumber, Relation relation) 
+                        int16 seqNumber, Relation relation)
 {
-   Datum           datum[Natts_pg_inherits];
-   char            nullarr[Natts_pg_inherits];
-   ObjectAddress   childobject,
-                   parentobject;
-   HeapTuple       tuple;
-   TupleDesc       desc = RelationGetDescr(relation);
+   Datum       datum[Natts_pg_inherits];
+   char        nullarr[Natts_pg_inherits];
+   ObjectAddress childobject,
+               parentobject;
+   HeapTuple   tuple;
+   TupleDesc   desc = RelationGetDescr(relation);
 
    datum[0] = ObjectIdGetDatum(relationId);    /* inhrel */
    datum[1] = ObjectIdGetDatum(parentOid);     /* inhparent */
@@ -2100,8 +2106,8 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
            ATPrepSetTableSpace(tab, rel, cmd->name);
            pass = AT_PASS_MISC;    /* doesn't actually matter */
            break;
-       case AT_SetRelOptions:      /* SET (...) */
-       case AT_ResetRelOptions:    /* RESET (...) */
+       case AT_SetRelOptions:  /* SET (...) */
+       case AT_ResetRelOptions:        /* RESET (...) */
            ATSimplePermissionsRelationOrIndex(rel);
            /* This command never recurses */
            /* No command-specific prep needed */
@@ -2274,10 +2280,10 @@ ATExecCmd(AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd)
             * Nothing to do here; Phase 3 does the work
             */
            break;
-       case AT_SetRelOptions:      /* SET (...) */
+       case AT_SetRelOptions:  /* SET (...) */
            ATExecSetRelOptions(rel, (List *) cmd->def, false);
            break;
-       case AT_ResetRelOptions:    /* RESET (...) */
+       case AT_ResetRelOptions:        /* RESET (...) */
            ATExecSetRelOptions(rel, (List *) cmd->def, true);
            break;
        case AT_EnableTrig:     /* ENABLE TRIGGER name */
@@ -2564,8 +2570,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
        /*
         * If we are rebuilding the tuples OR if we added any new NOT NULL
         * constraints, check all not-null constraints.  This is a bit of
-        * overkill but it minimizes risk of bugs, and heap_attisnull is
-        * pretty cheap test anyway.
+        * overkill but it minimizes risk of bugs, and heap_attisnull is a
+        * pretty cheap test anyway.
         */
        for (i = 0; i < newTupDesc->natts; i++)
        {
@@ -2679,13 +2685,13 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
 
            foreach(l, notnull_attrs)
            {
-               int     attn = lfirst_int(l);
+               int         attn = lfirst_int(l);
 
-               if (heap_attisnull(tuple, attn+1))
+               if (heap_attisnull(tuple, attn + 1))
                    ereport(ERROR,
                            (errcode(ERRCODE_NOT_NULL_VIOLATION),
                             errmsg("column \"%s\" contains null values",
-                                   NameStr(newTupDesc->attrs[attn]->attname))));
+                               NameStr(newTupDesc->attrs[attn]->attname))));
            }
 
            foreach(l, tab->constraints)
@@ -5105,7 +5111,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
                if (!list_member_oid(tab->changedConstraintOids,
                                     foundObject.objectId))
                {
-                   char *defstring = pg_get_constraintdef_string(foundObject.objectId);
+                   char       *defstring = pg_get_constraintdef_string(foundObject.objectId);
 
                    /*
                     * Put NORMAL dependencies at the front of the list and
@@ -5302,10 +5308,10 @@ ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab)
    /*
     * Now we can drop the existing constraints and indexes --- constraints
     * first, since some of them might depend on the indexes.  In fact, we
-    * have to delete FOREIGN KEY constraints before UNIQUE constraints,
-    * but we already ordered the constraint list to ensure that would happen.
-    * It should be okay to use DROP_RESTRICT here, since nothing else should
-    * be depending on these objects.
+    * have to delete FOREIGN KEY constraints before UNIQUE constraints, but
+    * we already ordered the constraint list to ensure that would happen. It
+    * should be okay to use DROP_RESTRICT here, since nothing else should be
+    * depending on these objects.
     */
    foreach(l, tab->changedConstraintOids)
    {
@@ -5482,17 +5488,17 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing)
                tuple_class->relowner != newOwnerId)
            {
                /* if it's an owned sequence, disallow changing it by itself */
-               Oid     tableId;
-               int32   colId;
+               Oid         tableId;
+               int32       colId;
 
                if (sequenceIsOwned(relationOid, &tableId, &colId))
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                             errmsg("cannot change owner of sequence \"%s\"",
                                    NameStr(tuple_class->relname)),
-                            errdetail("Sequence \"%s\" is linked to table \"%s\".",
-                                      NameStr(tuple_class->relname),
-                                      get_rel_name(tableId))));
+                     errdetail("Sequence \"%s\" is linked to table \"%s\".",
+                               NameStr(tuple_class->relname),
+                               get_rel_name(tableId))));
            }
            break;
        case RELKIND_TOASTVALUE:
@@ -6051,12 +6057,12 @@ ATExecEnableDisableTrigger(Relation rel, char *trigname,
 }
 
 static char *
-decompile_conbin(HeapTuple contup, TupleDesc tupdesc) 
+decompile_conbin(HeapTuple contup, TupleDesc tupdesc)
 {
-   Form_pg_constraint  con;
-   bool                isnull;
-   Datum               attr;
-   Datum               expr;
+   Form_pg_constraint con;
+   bool        isnull;
+   Datum       attr;
+   Datum       expr;
 
    con = (Form_pg_constraint) GETSTRUCT(contup);
    attr = heap_getattr(contup, Anum_pg_constraint_conbin, tupdesc, &isnull);
@@ -6107,7 +6113,7 @@ ATExecAddInherits(Relation child_rel, RangeVar *parent)
        ereport(ERROR,
                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                 errmsg("table \"%s\" without OIDs cannot inherit from table \"%s\" with OIDs",
-                       RelationGetRelationName(child_rel), parent->relname)));
+                     RelationGetRelationName(child_rel), parent->relname)));
 
    /*
     * Don't allow any duplicates in the list of parents. We scan through the
@@ -6140,8 +6146,8 @@ ATExecAddInherits(Relation child_rel, RangeVar *parent)
    heap_close(catalogRelation, RowExclusiveLock);
 
    /*
-    * If the new parent is found in our list of inheritors, we have a circular
-    * structure
+    * If the new parent is found in our list of inheritors, we have a
+    * circular structure
     */
    children = find_all_inheritors(RelationGetRelid(child_rel));
 
@@ -6183,12 +6189,12 @@ ATExecAddInherits(Relation child_rel, RangeVar *parent)
 static void
 MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
 {
-   Relation     attrdesc;
-   AttrNumber   parent_attno;
-   int          parent_natts;
-   TupleDesc    tupleDesc;
+   Relation    attrdesc;
+   AttrNumber  parent_attno;
+   int         parent_natts;
+   TupleDesc   tupleDesc;
    TupleConstr *constr;
-   HeapTuple    tuple;
+   HeapTuple   tuple;
 
    tupleDesc = RelationGetDescr(parent_rel);
    parent_natts = tupleDesc->natts;
@@ -6221,13 +6227,13 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
                ereport(ERROR,
                        (errcode(ERRCODE_DATATYPE_MISMATCH),
                         errmsg("child table \"%s\" has different type for column \"%s\"",
-               RelationGetRelationName(child_rel), NameStr(attribute->attname))));
+                               RelationGetRelationName(child_rel), NameStr(attribute->attname))));
 
            if (attribute->attnotnull && !childatt->attnotnull)
                ereport(ERROR,
                        (errcode(ERRCODE_DATATYPE_MISMATCH),
-                        errmsg("column \"%s\" in child table must be NOT NULL",
-                               NameStr(attribute->attname))));
+                     errmsg("column \"%s\" in child table must be NOT NULL",
+                            NameStr(attribute->attname))));
 
            childatt->attinhcount++;
            simple_heap_update(attrdesc, &tuple->t_self, tuple);
@@ -6555,13 +6561,13 @@ AlterTableNamespace(RangeVar *relation, const char *newschema)
    /* if it's an owned sequence, disallow moving it by itself */
    if (rel->rd_rel->relkind == RELKIND_SEQUENCE)
    {
-       Oid     tableId;
-       int32   colId;
+       Oid         tableId;
+       int32       colId;
 
        if (sequenceIsOwned(relid, &tableId, &colId))
            ereport(ERROR,
                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                    errmsg("cannot move an owned sequence into another schema"),
+                errmsg("cannot move an owned sequence into another schema"),
                     errdetail("Sequence \"%s\" is linked to table \"%s\".",
                               RelationGetRelationName(rel),
                               get_rel_name(tableId))));
index e53ae3b61bdb30b6779dbfff7bc2a302df130bbf..50d5e7d84e83fadbf1d0075e52a368a95c25b10e 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.38 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.39 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -402,7 +402,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
 
    if (!HeapTupleIsValid(tuple))
    {
-       if ( ! stmt->missing_ok )
+       if (!stmt->missing_ok)
        {
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -481,8 +481,8 @@ DropTableSpace(DropTableSpaceStmt *stmt)
    }
 
    /*
-    * Note: because we checked that the tablespace was empty, there should
-    * be no need to worry about flushing shared buffers or free space map
+    * Note: because we checked that the tablespace was empty, there should be
+    * no need to worry about flushing shared buffers or free space map
     * entries for relations in the tablespace.
     */
 
@@ -1069,7 +1069,7 @@ tblspc_desc(StringInfo buf, uint8 xl_info, char *rec)
        xl_tblspc_create_rec *xlrec = (xl_tblspc_create_rec *) rec;
 
        appendStringInfo(buf, "create ts: %u \"%s\"",
-               xlrec->ts_id, xlrec->ts_path);
+                        xlrec->ts_id, xlrec->ts_path);
    }
    else if (info == XLOG_TBLSPC_DROP)
    {
index 6d63356e1007f23eaf43e3dd36958f6c2e46e7ae..1ed15614ce41215366c3449795ba59c0b6babb14 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.208 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.209 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -480,7 +480,7 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior,
 
    if (!HeapTupleIsValid(tup))
    {
-       if (! missing_ok)
+       if (!missing_ok)
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
                     errmsg("trigger \"%s\" for table \"%s\" does not exist",
@@ -856,8 +856,8 @@ RelationBuildTriggers(Relation relation)
    /*
     * Note: since we scan the triggers using TriggerRelidNameIndexId, we will
     * be reading the triggers in name order, except possibly during
-    * emergency-recovery operations (ie, IgnoreSystemIndexes). This in
-    * turn ensures that triggers will be fired in name order.
+    * emergency-recovery operations (ie, IgnoreSystemIndexes). This in turn
+    * ensures that triggers will be fired in name order.
     */
    ScanKeyInit(&skey,
                Anum_pg_trigger_tgrelid,
@@ -2940,26 +2940,30 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                             errmsg("cross-database references are not implemented: \"%s.%s.%s\"",
-                                   constraint->catalogname, constraint->schemaname,
+                            constraint->catalogname, constraint->schemaname,
                                    constraint->relname)));
            }
 
-           /* 
+           /*
             * If we're given the schema name with the constraint, look only
-            * in that schema.  If given a bare constraint name, use the
+            * in that schema.  If given a bare constraint name, use the
             * search path to find the first matching constraint.
             */
-           if (constraint->schemaname) {
-               Oid namespaceId = LookupExplicitNamespace(constraint->schemaname);
+           if (constraint->schemaname)
+           {
+               Oid         namespaceId = LookupExplicitNamespace(constraint->schemaname);
+
                namespaceSearchList = list_make1_oid(namespaceId);
-           } else {
+           }
+           else
+           {
                namespaceSearchList = fetch_search_path(true);
            }
 
            found = false;
            foreach(namespaceSearchCell, namespaceSearchList)
            {
-               Oid searchNamespaceId = lfirst_oid(namespaceSearchCell);
+               Oid         searchNamespaceId = lfirst_oid(namespaceSearchCell);
 
                /*
                 * Setup to scan pg_trigger by tgconstrname ...
@@ -2978,18 +2982,18 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
                while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
                {
                    Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
-                   Oid constraintNamespaceId;
+                   Oid         constraintNamespaceId;
 
                    /*
                     * Foreign key constraints have triggers on both the
-                    * parent and child tables.  Since these tables may be
-                    * in different schemas we must pick the child table
-                    * because that table "owns" the constraint.
+                    * parent and child tables.  Since these tables may be in
+                    * different schemas we must pick the child table because
+                    * that table "owns" the constraint.
                     *
                     * Referential triggers on the parent table other than
-                    * NOACTION_DEL and NOACTION_UPD are ignored below, so
-                    * it is possible to not check them here, but it seems
-                    * safer to always check.
+                    * NOACTION_DEL and NOACTION_UPD are ignored below, so it
+                    * is possible to not check them here, but it seems safer
+                    * to always check.
                     */
                    if (pg_trigger->tgfoid == F_RI_FKEY_NOACTION_DEL ||
                        pg_trigger->tgfoid == F_RI_FKEY_NOACTION_UPD ||
@@ -3006,16 +3010,16 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
                        constraintNamespaceId = get_rel_namespace(pg_trigger->tgrelid);
 
                    /*
-                    * If this constraint is not in the schema we're
-                    * currently searching for, keep looking.
+                    * If this constraint is not in the schema we're currently
+                    * searching for, keep looking.
                     */
                    if (constraintNamespaceId != searchNamespaceId)
                        continue;
 
                    /*
-                    * 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 &&
@@ -3029,8 +3033,8 @@ AfterTriggerSetState(ConstraintsSetStmt *stmt)
                        if (stmt->deferred && !pg_trigger->tgdeferrable)
                            ereport(ERROR,
                                    (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                    errmsg("constraint \"%s\" is not deferrable",
-                                           constraint->relname)));
+                               errmsg("constraint \"%s\" is not deferrable",
+                                      constraint->relname)));
                        oidlist = lappend_oid(oidlist, HeapTupleGetOid(htup));
                    }
                    found = true;
@@ -3147,9 +3151,9 @@ AfterTriggerCheckTruncate(List *relids)
         event = event->ate_next)
    {
        /*
-        * We can ignore completed events.  (Even if a DONE flag is rolled
-        * back by subxact abort, it's OK because the effects of the
-        * TRUNCATE must get rolled back too.)
+        * We can ignore completed events.  (Even if a DONE flag is rolled
+        * back by subxact abort, it's OK because the effects of the TRUNCATE
+        * must get rolled back too.)
         */
        if (event->ate_event & AFTER_TRIGGER_DONE)
            continue;
@@ -3162,10 +3166,9 @@ AfterTriggerCheckTruncate(List *relids)
    }
 
    /*
-    * Also scan events queued by incomplete queries.  This could only
-    * matter if a TRUNCATE is executed by a function or trigger within
-    * an updating query on the same relation, which is pretty perverse,
-    * but let's check.
+    * Also scan events queued by incomplete queries.  This could only matter
+    * if a TRUNCATE is executed by a function or trigger within an updating
+    * query on the same relation, which is pretty perverse, but let's check.
     */
    for (depth = 0; depth <= afterTriggers->query_depth; depth++)
    {
index 6dfa6296d5abe66f7bc79d080cf4cf7eeb0b30b4..53cca73a9dd6a87ea350de3854a539094565b01c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.96 2006/07/31 20:09:00 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.97 2006/10/04 00:29:51 momjian Exp $
  *
  * DESCRIPTION
  *   The "DefineFoo" routines take the parse tree and pick out the
@@ -343,12 +343,12 @@ DefineType(List *names, List *parameters)
        analyzeOid = findTypeAnalyzeFunction(analyzeName, typoid);
 
    /*
-    * Check permissions on functions.  We choose to require the creator/owner
-    * of a type to also own the underlying functions.  Since creating a type
+    * Check permissions on functions.  We choose to require the creator/owner
+    * of a type to also own the underlying functions.  Since creating a type
     * is tantamount to granting public execute access on the functions, the
-    * minimum sane check would be for execute-with-grant-option.  But we don't
-    * have a way to make the type go away if the grant option is revoked, so
-    * ownership seems better.
+    * minimum sane check would be for execute-with-grant-option.  But we
+    * don't have a way to make the type go away if the grant option is
+    * revoked, so ownership seems better.
     */
    if (inputOid && !pg_proc_ownercheck(inputOid, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
@@ -587,8 +587,8 @@ DefineDomain(CreateDomainStmt *stmt)
 
    /*
     * Base type must be a plain base type or another domain.  Domains over
-    * pseudotypes would create a security hole.  Domains over composite
-    * types might be made to work in the future, but not today.
+    * pseudotypes would create a security hole.  Domains over composite types
+    * might be made to work in the future, but not today.
     */
    typtype = baseType->typtype;
    if (typtype != 'b' && typtype != 'd')
@@ -1840,7 +1840,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
    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")));
 
    /*
     * Convert to string form for storage.
index 589111713b1226a54fc453cdfb10465385929f97..2e9b27a5988ba24ebc72738c6c0e85d846e082c9 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.173 2006/07/13 16:49:14 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.174 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -377,8 +377,8 @@ CreateRole(CreateRoleStmt *stmt)
                GetUserId(), false);
 
    /*
-    * Close pg_authid, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_authid, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(pg_authid_rel, NoLock);
 
@@ -696,8 +696,8 @@ AlterRole(AlterRoleStmt *stmt)
                    false);
 
    /*
-    * Close pg_authid, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_authid, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(pg_authid_rel, NoLock);
 
@@ -845,7 +845,7 @@ DropRole(DropRoleStmt *stmt)
            else
            {
                ereport(NOTICE,
-                       (errmsg("role \"%s\" does not exist, skipping", 
+                       (errmsg("role \"%s\" does not exist, skipping",
                                role)));
            }
 
@@ -1075,8 +1075,8 @@ RenameRole(const char *oldname, const char *newname)
    ReleaseSysCache(oldtuple);
 
    /*
-    * Close pg_authid, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_authid, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(rel, NoLock);
 
@@ -1132,8 +1132,8 @@ GrantRole(GrantRoleStmt *stmt)
    }
 
    /*
-    * Close pg_authid, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_authid, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(pg_authid_rel, NoLock);
 
@@ -1149,7 +1149,7 @@ GrantRole(GrantRoleStmt *stmt)
  * Drop the objects owned by a given list of roles.
  */
 void
-DropOwnedObjects(DropOwnedStmt * stmt)
+DropOwnedObjects(DropOwnedStmt *stmt)
 {
    List       *role_ids = roleNamesToIds(stmt->roles);
    ListCell   *cell;
@@ -1175,7 +1175,7 @@ DropOwnedObjects(DropOwnedStmt * stmt)
  * Give the objects owned by a given list of roles away to another user.
  */
 void
-ReassignOwnedObjects(ReassignOwnedStmt * stmt)
+ReassignOwnedObjects(ReassignOwnedStmt *stmt)
 {
    List       *role_ids = roleNamesToIds(stmt->roles);
    ListCell   *cell;
@@ -1360,8 +1360,8 @@ AddRoleMems(const char *rolename, Oid roleid,
    }
 
    /*
-    * Close pg_authmem, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_authmem, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(pg_authmem_rel, NoLock);
 }
@@ -1473,8 +1473,8 @@ DelRoleMems(const char *rolename, Oid roleid,
    }
 
    /*
-    * Close pg_authmem, but keep lock till commit (this is important
-    * to prevent any risk of deadlock failure while updating flat file)
+    * Close pg_authmem, but keep lock till commit (this is important to
+    * prevent any risk of deadlock failure while updating flat file)
     */
    heap_close(pg_authmem_rel, NoLock);
 }
index 5a6d5a04b029a64106e429230b3c7d0e39e9930c..e9f0bf363ea9109ae9fb2db3d8b5b4a3c708fe0d 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.340 2006/09/21 20:31:22 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.341 2006/10/04 00:29:51 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,7 +125,7 @@ typedef struct VRelStats
    Size        min_tlen;
    Size        max_tlen;
    bool        hasindex;
-   TransactionId minxid;   /* Minimum Xid present anywhere on table */
+   TransactionId minxid;       /* Minimum Xid present anywhere on table */
    /* vtlinks array for tuple chain following - sorted by new_tid */
    int         num_vtlinks;
    VTupleLink  vtlinks;
@@ -238,7 +238,7 @@ static int  vac_cmp_blk(const void *left, const void *right);
 static int vac_cmp_offno(const void *left, const void *right);
 static int vac_cmp_vtlinks(const void *left, const void *right);
 static bool enough_space(VacPage vacpage, Size len);
-static Size    PageGetFreeSpaceWithFillFactor(Relation relation, Page page);
+static Size PageGetFreeSpaceWithFillFactor(Relation relation, Page page);
 
 
 /****************************************************************************
@@ -320,8 +320,8 @@ vacuum(VacuumStmt *vacstmt, List *relids)
                 errhint("Use VACUUM FULL, then VACUUM FREEZE.")));
 
    /*
-    * Send info about dead objects to the statistics collector, unless
-    * we are in autovacuum --- autovacuum.c does this for itself.
+    * Send info about dead objects to the statistics collector, unless we are
+    * in autovacuum --- autovacuum.c does this for itself.
     */
    if (vacstmt->vacuum && !IsAutoVacuumProcess())
        pgstat_vacuum_tabstat();
@@ -481,20 +481,21 @@ vacuum(VacuumStmt *vacstmt, List *relids)
         * PostgresMain().
         */
        StartTransactionCommand();
+
        /*
-        * Re-establish the transaction snapshot.  This is wasted effort
-        * when we are called as a normal utility command, because the
-        * new transaction will be dropped immediately by PostgresMain();
-        * but it's necessary if we are called from autovacuum because
-        * autovacuum might continue on to do an ANALYZE-only call.
+        * Re-establish the transaction snapshot.  This is wasted effort when
+        * we are called as a normal utility command, because the new
+        * transaction will be dropped immediately by PostgresMain(); but it's
+        * necessary if we are called from autovacuum because autovacuum might
+        * continue on to do an ANALYZE-only call.
         */
        ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
    }
 
    if (vacstmt->vacuum)
    {
-       TransactionId   minxid,
-                       vacuumxid;
+       TransactionId minxid,
+                   vacuumxid;
 
        /*
         * If it was a database-wide VACUUM, print FSM usage statistics (we
@@ -593,9 +594,9 @@ vacuum_set_xid_limits(VacuumStmt *vacstmt, bool sharedRel,
    TransactionId limit;
 
    /*
-    * We can always ignore processes running lazy vacuum.  This is because we
+    * We can always ignore processes running lazy vacuum.  This is because we
     * use these values only for deciding which tuples we must keep in the
-    * tables.  Since lazy vacuum doesn't write its xid to the table, it's
+    * tables.  Since lazy vacuum doesn't write its xid to the table, it's
     * safe to ignore it.  In theory it could be problematic to ignore lazy
     * vacuums on a full vacuum, but keep in mind that only one vacuum process
     * can be working on a particular table at any time, and that each vacuum
@@ -704,6 +705,7 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
        pgcform->relhasindex = hasindex;
        dirty = true;
    }
+
    /*
     * If we have discovered that there are no indexes, then there's no
     * primary key either.  This could be done more thoroughly...
@@ -740,11 +742,11 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
 /*
  * vac_update_dbminxid() -- update the minimum Xid present in one database
  *
- *         Update pg_database's datminxid and datvacuumxid, and the flat-file copy
- *         of it.  datminxid is updated to the minimum of all relminxid found in
- *         pg_class.  datvacuumxid is updated to the minimum of all relvacuumxid
- *         found in pg_class.  The values are also returned in minxid and
- *         vacuumxid, respectively.
+ *     Update pg_database's datminxid and datvacuumxid, and the flat-file copy
+ *     of it.  datminxid is updated to the minimum of all relminxid found in
+ *     pg_class.  datvacuumxid is updated to the minimum of all relvacuumxid
+ *     found in pg_class.  The values are also returned in minxid and
+ *     vacuumxid, respectively.
  *
  *     We violate transaction semantics here by overwriting the database's
  *     existing pg_database tuple with the new values.  This is reasonably
@@ -760,15 +762,15 @@ vac_update_dbminxid(Oid dbid, TransactionId *minxid, TransactionId *vacuumxid)
    HeapTuple   tuple;
    Form_pg_database dbform;
    Relation    relation;
-   SysScanDesc scan;
+   SysScanDesc scan;
    HeapTuple   classTup;
-   TransactionId   newMinXid = InvalidTransactionId;
-   TransactionId   newVacXid = InvalidTransactionId;
+   TransactionId newMinXid = InvalidTransactionId;
+   TransactionId newVacXid = InvalidTransactionId;
    bool        dirty = false;
 
-   /* 
-    * We must seqscan pg_class to find the minimum Xid, because there
-    * is no index that can help us here.
+   /*
+    * We must seqscan pg_class to find the minimum Xid, because there is no
+    * index that can help us here.
     */
    relation = heap_open(RelationRelationId, AccessShareLock);
 
@@ -845,7 +847,7 @@ vac_update_dbminxid(Oid dbid, TransactionId *minxid, TransactionId *vacuumxid)
    *vacuumxid = newVacXid;
 
    /* Mark the flat-file copy of pg_database for update at commit */
-       database_file_update_needed();
+   database_file_update_needed();
 }
 
 
@@ -970,14 +972,14 @@ vac_truncate_clog(TransactionId myminxid, TransactionId myvacxid)
     * XXX -- the test we use here is fairly arbitrary.  Note that in the
     * autovacuum database-wide code, a template database is always processed
     * with VACUUM FREEZE, so we can be sure that it will be truly frozen so
-    * it won't be need to be processed here again soon.  
+    * it won't be need to be processed here again soon.
     *
     * FIXME -- here we could get into a kind of loop if the database being
     * chosen is not actually a template database, because we'll not freeze
     * it, so its age may not really decrease if there are any live
     * non-freezable tuples.  Consider forcing a vacuum freeze if autovacuum
-    * is invoked by a backend.  On the other hand, forcing a vacuum freeze
-    * on a user database may not a be a very polite thing to do.
+    * is invoked by a backend.  On the other hand, forcing a vacuum freeze on
+    * a user database may not a be a very polite thing to do.
     */
    if (!AutoVacuumingActive() && age > (int32) ((MaxTransactionId >> 3) * 3))
        SendPostmasterSignal(PMSIGNAL_START_AUTOVAC);
@@ -1022,18 +1024,18 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
    else
    {
        /*
-        * During a lazy VACUUM we do not run any user-supplied functions,
-        * and so it should be safe to not create a transaction snapshot.
+        * During a lazy VACUUM we do not run any user-supplied functions, and
+        * so it should be safe to not create a transaction snapshot.
         *
         * We can furthermore set the inVacuum flag, which lets other
         * concurrent VACUUMs know that they can ignore this one while
         * determining their OldestXmin.  (The reason we don't set inVacuum
         * during a full VACUUM is exactly that we may have to run user-
-        * defined functions for functional indexes, and we want to make
-        * sure that if they use the snapshot set above, any tuples it
-        * requires can't get removed from other tables.  An index function
-        * that depends on the contents of other tables is arguably broken,
-        * but we won't break it here by violating transaction semantics.)
+        * defined functions for functional indexes, and we want to make sure
+        * that if they use the snapshot set above, any tuples it requires
+        * can't get removed from other tables.  An index function that
+        * depends on the contents of other tables is arguably broken, but we
+        * won't break it here by violating transaction semantics.)
         *
         * Note: the inVacuum flag remains set until CommitTransaction or
         * AbortTransaction.  We don't want to clear it until we reset
@@ -1059,8 +1061,8 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
    /*
     * Open the relation and get the appropriate lock on it.
     *
-    * There's a race condition here: the rel may have gone away since
-    * the last time we saw it.  If so, we don't need to vacuum it.
+    * There's a race condition here: the rel may have gone away since the
+    * last time we saw it.  If so, we don't need to vacuum it.
     */
    onerel = try_relation_open(relid, lmode);
 
@@ -1116,7 +1118,7 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind)
    {
        relation_close(onerel, lmode);
        CommitTransactionCommand();
-       return;         /* assume no long-lived data in temp tables */
+       return;                 /* assume no long-lived data in temp tables */
    }
 
    /*
@@ -1207,7 +1209,7 @@ full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
                i;
    VRelStats  *vacrelstats;
    TransactionId FreezeLimit,
-                 OldestXmin;
+               OldestXmin;
 
    vacuum_set_xid_limits(vacstmt, onerel->rd_rel->relisshared,
                          &OldestXmin, &FreezeLimit);
@@ -1221,13 +1223,13 @@ full_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
    vacrelstats->hasindex = false;
 
    /*
-    * Set initial minimum Xid, which will be updated if a smaller Xid is found
-    * in the relation by scan_heap.
+    * Set initial minimum Xid, which will be updated if a smaller Xid is
+    * found in the relation by scan_heap.
     *
     * We use RecentXmin here (the minimum Xid that belongs to a transaction
     * that is still open according to our snapshot), because it is the
-    * earliest transaction that could insert new tuples in the table after our
-    * VACUUM is done.
+    * earliest transaction that could insert new tuples in the table after
+    * our VACUUM is done.
     */
    vacrelstats->minxid = RecentXmin;
 
@@ -1557,7 +1559,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
            }
            else
            {
-               TransactionId   min;
+               TransactionId min;
 
                num_tuples += 1;
                notup = false;
@@ -1566,7 +1568,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
                if (tuple.t_len > max_tlen)
                    max_tlen = tuple.t_len;
 
-               /* 
+               /*
                 * If the tuple is alive, we consider it for the "minxid"
                 * calculations.
                 */
@@ -1710,23 +1712,23 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
 TransactionId
 vactuple_get_minxid(HeapTuple tuple)
 {
-   TransactionId   min = InvalidTransactionId;
+   TransactionId min = InvalidTransactionId;
 
-   /* 
-    * Initialize calculations with Xmin.  NB -- may be FrozenXid and
-    * we don't want that one.
+   /*
+    * Initialize calculations with Xmin.  NB -- may be FrozenXid and we don't
+    * want that one.
     */
    if (TransactionIdIsNormal(HeapTupleHeaderGetXmin(tuple->t_data)))
        min = HeapTupleHeaderGetXmin(tuple->t_data);
 
    /*
     * If Xmax is not marked INVALID, we assume it's valid without making
-    * further checks on it --- it must be recently obsoleted or still running,
-    * else HeapTupleSatisfiesVacuum would have deemed it removable.
+    * further checks on it --- it must be recently obsoleted or still
+    * running, else HeapTupleSatisfiesVacuum would have deemed it removable.
     */
    if (!(tuple->t_data->t_infomask | HEAP_XMAX_INVALID))
    {
-       TransactionId    xmax = HeapTupleHeaderGetXmax(tuple->t_data);
+       TransactionId xmax = HeapTupleHeaderGetXmax(tuple->t_data);
 
        /* If xmax is a plain Xid, consider it by itself */
        if (!(tuple->t_data->t_infomask | HEAP_XMAX_IS_MULTI))
index c839b951d9839473776edc0455d232ca29a3878f..c89dc20404c97b2675743367c1c0c28a1862fe05 100644 (file)
@@ -36,7 +36,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.79 2006/09/21 20:31:22 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.80 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -90,7 +90,7 @@ typedef struct LVRelStats
    int         num_free_pages; /* current # of entries */
    int         max_free_pages; /* # slots allocated in array */
    PageFreeSpaceInfo *free_pages;      /* array or heap of blkno/avail */
-   BlockNumber tot_free_pages; /* total pages with >= threshold space */
+   BlockNumber tot_free_pages; /* total pages with >= threshold space */
 } LVRelStats;
 
 
@@ -103,15 +103,15 @@ static void lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
               TransactionId OldestXmin);
 static void lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats);
 static void lazy_vacuum_index(Relation indrel,
-                             IndexBulkDeleteResult **stats,
-                             LVRelStats *vacrelstats);
+                 IndexBulkDeleteResult **stats,
+                 LVRelStats *vacrelstats);
 static void lazy_cleanup_index(Relation indrel,
-                              IndexBulkDeleteResult *stats,
-                              LVRelStats *vacrelstats);
+                  IndexBulkDeleteResult *stats,
+                  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,
-                              TransactionId OldestXmin);
+                  TransactionId OldestXmin);
 static BlockNumber count_nondeletable_pages(Relation onerel,
                         LVRelStats *vacrelstats, TransactionId OldestXmin);
 static void lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks);
@@ -143,7 +143,7 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
    int         nindexes;
    BlockNumber possibly_freeable;
    TransactionId OldestXmin,
-                 FreezeLimit;
+               FreezeLimit;
 
    if (vacstmt->verbose)
        elevel = INFO;
@@ -160,8 +160,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
    vacrelstats->threshold = GetAvgFSMRequestSize(&onerel->rd_node);
 
    /*
-    * Set initial minimum Xid, which will be updated if a smaller Xid is found
-    * in the relation by lazy_scan_heap.
+    * Set initial minimum Xid, which will be updated if a smaller Xid is
+    * found in the relation by lazy_scan_heap.
     *
     * We use RecentXmin here (the minimum Xid that belongs to a transaction
     * that is still open according to our snapshot), because it is the
@@ -440,7 +440,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
                num_tuples += 1;
                hastup = true;
 
-               /* 
+               /*
                 * If the tuple is alive, we consider it for the "minxid"
                 * calculations.
                 */
@@ -472,8 +472,8 @@ 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.  (This path will always
-        * be taken if there are no indexes.)
+        * page, so remember its free space as-is.  (This path will always be
+        * taken if there are no indexes.)
         */
        if (vacrelstats->num_dead_tuples == prev_dead_count)
        {
@@ -803,11 +803,12 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats,
        }
    }
    vacrelstats->num_free_pages = j;
+
    /*
     * If tot_free_pages was more than num_free_pages, we can't tell for sure
     * what its correct value is now, because we don't know which of the
-    * forgotten pages are getting truncated.  Conservatively set it equal
-    * to num_free_pages.
+    * forgotten pages are getting truncated.  Conservatively set it equal to
+    * num_free_pages.
     */
    vacrelstats->tot_free_pages = j;
 
index 2e270cde56f07a3191a66d1a642c80947d213943..c910f6376fde2557c1eaadda9a76fc3f624389a2 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.118 2006/07/14 14:52:18 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.119 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -585,7 +585,7 @@ assign_client_encoding(const char *value, bool doit, GucSource source)
  * limit on names, so we can tell whether we're being passed an initial
  * role name or a saved/restored value.  (NOTE: we rely on guc.c to have
  * properly truncated any incoming value, but not to truncate already-stored
- * values.  See GUC_IS_NAME processing.)
+ * values. See GUC_IS_NAME processing.)
  */
 extern char *session_authorization_string;     /* in guc.c */
 
index df7f479f3162643775705443a83cfdfaa003e22c..a79bd3cd4f2311e841b5c7459c78bc24f0094310 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.97 2006/08/21 00:57:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.98 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -119,7 +119,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
 
            def->colname = pstrdup(tle->resname);
            def->typename = makeTypeNameFromOid(exprType((Node *) tle->expr),
-                                           exprTypmod((Node *) tle->expr));
+                                            exprTypmod((Node *) tle->expr));
            def->inhcount = 0;
            def->is_local = true;
            def->is_not_null = false;
index 4b8a166ffae2b328373523f51702324114f5bad0..5e5ca085ba4a47270ef49903ed531423f452737f 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.279 2006/08/12 20:05:55 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.280 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,17 +76,17 @@ static TupleTableSlot *ExecutePlan(EState *estate, PlanState *planstate,
            ScanDirection direction,
            DestReceiver *dest);
 static void ExecSelect(TupleTableSlot *slot,
-                      DestReceiver *dest, EState *estate);
+          DestReceiver *dest, EState *estate);
 static void ExecInsert(TupleTableSlot *slot, ItemPointer tupleid,
-                      TupleTableSlot *planSlot,
-                      DestReceiver *dest, EState *estate);
+          TupleTableSlot *planSlot,
+          DestReceiver *dest, EState *estate);
 static void ExecDelete(ItemPointer tupleid,
-                      TupleTableSlot *planSlot,
-                      DestReceiver *dest, EState *estate);
+          TupleTableSlot *planSlot,
+          DestReceiver *dest, EState *estate);
 static void ExecUpdate(TupleTableSlot *slot, ItemPointer tupleid,
-                      TupleTableSlot *planSlot,
-                      DestReceiver *dest, EState *estate);
-static void ExecProcessReturning(ProjectionInfo    *projectReturning,
+          TupleTableSlot *planSlot,
+          DestReceiver *dest, EState *estate);
+static void ExecProcessReturning(ProjectionInfo *projectReturning,
                     TupleTableSlot *tupleSlot,
                     TupleTableSlot *planSlot,
                     DestReceiver *dest);
@@ -758,32 +758,33 @@ InitPlan(QueryDesc *queryDesc, int eflags)
        econtext = CreateExprContext(estate);
 
        /*
-        * Build a projection for each result rel.  Note that any SubPlans
-        * in the RETURNING lists get attached to the topmost plan node.
+        * Build a projection for each result rel.  Note that any SubPlans in
+        * the RETURNING lists get attached to the topmost plan node.
         */
        Assert(list_length(parseTree->returningLists) == estate->es_num_result_relations);
        resultRelInfo = estate->es_result_relations;
        foreach(l, parseTree->returningLists)
        {
-           List   *rlist = (List *) lfirst(l);
-           List   *rliststate;
+           List       *rlist = (List *) lfirst(l);
+           List       *rliststate;
 
            rliststate = (List *) ExecInitExpr((Expr *) rlist, planstate);
            resultRelInfo->ri_projectReturning =
                ExecBuildProjectionInfo(rliststate, econtext, slot);
            resultRelInfo++;
        }
+
        /*
-        * Because we already ran ExecInitNode() for the top plan node,
-        * any subplans we just attached to it won't have been initialized;
-        * so we have to do it here.  (Ugly, but the alternatives seem worse.)
+        * Because we already ran ExecInitNode() for the top plan node, any
+        * subplans we just attached to it won't have been initialized; so we
+        * have to do it here.  (Ugly, but the alternatives seem worse.)
         */
        foreach(l, planstate->subPlan)
        {
            SubPlanState *sstate = (SubPlanState *) lfirst(l);
 
            Assert(IsA(sstate, SubPlanState));
-           if (sstate->planstate == NULL)          /* already inited? */
+           if (sstate->planstate == NULL)      /* already inited? */
                ExecInitSubPlan(sstate, estate, eflags);
        }
    }
@@ -1191,7 +1192,7 @@ lnext:    ;
                                                       erm->rti,
                                                       &update_ctid,
                                                       update_xmax,
-                                                      estate->es_snapshot->curcid);
+                                               estate->es_snapshot->curcid);
                                if (!TupIsNull(newSlot))
                                {
                                    slot = planSlot = newSlot;
@@ -1215,9 +1216,9 @@ lnext:    ;
            }
 
            /*
-            * Create a new "clean" tuple with all junk attributes removed.
-            * We don't need to do this for DELETE, however (there will
-            * in fact be no non-junk attributes in a DELETE!)
+            * Create a new "clean" tuple with all junk attributes removed. We
+            * don't need to do this for DELETE, however (there will in fact
+            * be no non-junk attributes in a DELETE!)
             */
            if (operation != CMD_DELETE)
                slot = ExecFilterJunk(junkfilter, slot);
@@ -1515,8 +1516,8 @@ ldelete:;
    if (resultRelInfo->ri_projectReturning)
    {
        /*
-        * We have to put the target tuple into a slot, which means
-        * first we gotta fetch it.  We can use the trigger tuple slot.
+        * We have to put the target tuple into a slot, which means first we
+        * gotta fetch it.  We can use the trigger tuple slot.
         */
        TupleTableSlot *slot = estate->es_trig_tuple_slot;
        HeapTupleData deltuple;
@@ -1815,13 +1816,13 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
  * dest: where to send the output
  */
 static void
-ExecProcessReturning(ProjectionInfo    *projectReturning,
+ExecProcessReturning(ProjectionInfo *projectReturning,
                     TupleTableSlot *tupleSlot,
                     TupleTableSlot *planSlot,
                     DestReceiver *dest)
 {
-   ExprContext     *econtext = projectReturning->pi_exprContext;
-   TupleTableSlot  *retSlot;
+   ExprContext *econtext = projectReturning->pi_exprContext;
+   TupleTableSlot *retSlot;
 
    /*
     * Reset per-tuple memory context to free any expression evaluation
@@ -1942,12 +1943,12 @@ EvalPlanQual(EState *estate, Index rti,
             * If tuple was inserted by our own transaction, we have to check
             * cmin against curCid: cmin >= curCid means our command cannot
             * see the tuple, so we should ignore it.  Without this we are
-            * open to the "Halloween problem" of indefinitely re-updating
-            * the same tuple.  (We need not check cmax because
-            * HeapTupleSatisfiesDirty will consider a tuple deleted by
-            * our transaction dead, regardless of cmax.)  We just checked
-            * that priorXmax == xmin, so we can test that variable instead
-            * of doing HeapTupleHeaderGetXmin again.
+            * open to the "Halloween problem" of indefinitely re-updating the
+            * same tuple.  (We need not check cmax because
+            * HeapTupleSatisfiesDirty will consider a tuple deleted by our
+            * transaction dead, regardless of cmax.)  We just checked that
+            * priorXmax == xmin, so we can test that variable instead of
+            * doing HeapTupleHeaderGetXmin again.
             */
            if (TransactionIdIsCurrentTransactionId(priorXmax) &&
                HeapTupleHeaderGetCmin(tuple.t_data) >= curCid)
@@ -2379,7 +2380,8 @@ OpenIntoRel(QueryDesc *queryDesc)
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
                     errmsg("tablespace \"%s\" does not exist",
                            parseTree->intoTableSpaceName)));
-   } else
+   }
+   else
    {
        tablespaceId = GetDefaultTablespace();
        /* note InvalidOid is OK in this case */
@@ -2426,15 +2428,15 @@ OpenIntoRel(QueryDesc *queryDesc)
    FreeTupleDesc(tupdesc);
 
    /*
-    * 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 INTO 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(intoRelationId);
 
@@ -2449,11 +2451,11 @@ OpenIntoRel(QueryDesc *queryDesc)
    /*
     * 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();
    estate->es_into_relation_descriptor = intoRelationDesc;
index 9f1fd54a8e542d0a993cf8b49852cbf282d9600f..cd13bc659727751fafc3ad6f3c3e187aa3ccc372 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.58 2006/08/02 01:59:45 joe Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/execProcnode.c,v 1.59 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -197,7 +197,7 @@ ExecInitNode(Plan *node, EState *estate, int eflags)
 
        case T_ValuesScan:
            result = (PlanState *) ExecInitValuesScan((ValuesScan *) node,
-                                                       estate, eflags);
+                                                     estate, eflags);
            break;
 
            /*
index 7e9e51f13911635d1d4a7c208e040438b3643e86..3f9c0907257bd1a5543df3b2254343f778f77b0d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.194 2006/09/28 20:51:41 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.195 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -108,8 +108,8 @@ static Datum ExecEvalRow(RowExprState *rstate,
            ExprContext *econtext,
            bool *isNull, ExprDoneCond *isDone);
 static Datum ExecEvalRowCompare(RowCompareExprState *rstate,
-           ExprContext *econtext,
-           bool *isNull, ExprDoneCond *isDone);
+                  ExprContext *econtext,
+                  bool *isNull, ExprDoneCond *isDone);
 static Datum ExecEvalCoalesce(CoalesceExprState *coalesceExpr,
                 ExprContext *econtext,
                 bool *isNull, ExprDoneCond *isDone);
@@ -882,7 +882,7 @@ get_cached_rowtype(Oid type_id, int32 typmod,
 static void
 ShutdownTupleDescRef(Datum arg)
 {
-   TupleDesc *cache_field = (TupleDesc *) DatumGetPointer(arg);
+   TupleDesc  *cache_field = (TupleDesc *) DatumGetPointer(arg);
 
    if (*cache_field)
        ReleaseTupleDesc(*cache_field);
@@ -2015,8 +2015,8 @@ ExecEvalConvertRowtype(ConvertRowtypeExprState *cstate,
    /* if first time through, initialize */
    if (cstate->attrMap == NULL)
    {
-       MemoryContext   old_cxt;
-       int     n;
+       MemoryContext old_cxt;
+       int         n;
 
        /* allocate state in long-lived memory context */
        old_cxt = MemoryContextSwitchTo(econtext->ecxt_per_query_memory);
@@ -2502,7 +2502,7 @@ ExecEvalRowCompare(RowCompareExprState *rstate,
 
    switch (rctype)
    {
-       /* EQ and NE cases aren't allowed here */
+           /* EQ and NE cases aren't allowed here */
        case ROWCOMPARE_LT:
            result = (cmpresult < 0);
            break;
@@ -2722,7 +2722,7 @@ ExecEvalNullTest(NullTestState *nstate,
        for (att = 1; att <= tupDesc->natts; att++)
        {
            /* ignore dropped columns */
-           if (tupDesc->attrs[att-1]->attisdropped)
+           if (tupDesc->attrs[att - 1]->attisdropped)
                continue;
            if (heap_attisnull(&tmptup, att))
            {
@@ -2764,7 +2764,7 @@ ExecEvalNullTest(NullTestState *nstate,
            default:
                elog(ERROR, "unrecognized nulltesttype: %d",
                     (int) ntest->nulltesttype);
-               return (Datum) 0;   /* keep compiler quiet */
+               return (Datum) 0;       /* keep compiler quiet */
        }
    }
 }
@@ -3564,16 +3564,17 @@ ExecInitExpr(Expr *node, PlanState *parent)
                i = 0;
                forboth(l, rcexpr->opnos, l2, rcexpr->opclasses)
                {
-                   Oid     opno = lfirst_oid(l);
-                   Oid     opclass = lfirst_oid(l2);
-                   int     strategy;
-                   Oid     subtype;
-                   bool    recheck;
-                   Oid     proc;
+                   Oid         opno = lfirst_oid(l);
+                   Oid         opclass = lfirst_oid(l2);
+                   int         strategy;
+                   Oid         subtype;
+                   bool        recheck;
+                   Oid         proc;
 
                    get_op_opclass_properties(opno, opclass,
                                              &strategy, &subtype, &recheck);
                    proc = get_opclass_proc(opclass, subtype, BTORDER_PROC);
+
                    /*
                     * If we enforced permissions checks on index support
                     * functions, we'd need to make a check here.  But the
@@ -3632,11 +3633,12 @@ ExecInitExpr(Expr *node, PlanState *parent)
                            (errcode(ERRCODE_UNDEFINED_FUNCTION),
                             errmsg("could not identify a comparison function for type %s",
                                    format_type_be(minmaxexpr->minmaxtype))));
+
                /*
                 * If we enforced permissions checks on index support
-                * functions, we'd need to make a check here.  But the
-                * index support machinery doesn't do that, and neither
-                * does this code.
+                * functions, we'd need to make a check here.  But the index
+                * support machinery doesn't do that, and neither does this
+                * code.
                 */
                fmgr_info(typentry->cmp_proc, &(mstate->cfunc));
                state = (ExprState *) mstate;
index 6e5f30bde4aa8f1adb20c06ede276798eff264d7..fb1fdf9e7233e297620e97ed5b9e229ef60ba6eb 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.97 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.98 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -722,7 +722,7 @@ ExecFetchSlotTuple(TupleTableSlot *slot)
  *         Fetch the slot's minimal physical tuple.
  *
  *     If the slot contains a virtual tuple, we convert it to minimal
- *     physical form.  The slot retains ownership of the physical tuple.
+ *     physical form.  The slot retains ownership of the physical tuple.
  *     Likewise, if it contains a regular tuple we convert to minimal form.
  *
  * As above, the result must be treated as read-only.
@@ -792,8 +792,8 @@ ExecMaterializeSlot(TupleTableSlot *slot)
    Assert(!slot->tts_isempty);
 
    /*
-    * If we have a regular physical tuple, and it's locally palloc'd,
-    * we have nothing to do.
+    * If we have a regular physical tuple, and it's locally palloc'd, we have
+    * nothing to do.
     */
    if (slot->tts_tuple && slot->tts_shouldFree && slot->tts_mintuple == NULL)
        return slot->tts_tuple;
index aa5aeb57f3644c1a4f508baa5da0b65bd13c5dc4..d8290b3b5be7aebe27fbb6384f3ae897c54b898f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.139 2006/08/04 21:33:36 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/execUtils.c,v 1.140 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -898,8 +898,8 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo)
    resultRelInfo->ri_IndexRelationInfo = indexInfoArray;
 
    /*
-    * For each index, open the index relation and save pg_index info.
-    * We acquire RowExclusiveLock, signifying we will update the index.
+    * For each index, open the index relation and save pg_index info. We
+    * acquire RowExclusiveLock, signifying we will update the index.
     */
    i = 0;
    foreach(l, indexoidlist)
index e2e56543839c40a3e1622c153c4905805d5cbb5f..f9b8067109bb75f5688cc002a15477a93fc34c49 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.106 2006/09/06 20:40:47 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.107 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -433,7 +433,7 @@ postquel_sub_params(SQLFunctionCachePtr fcache,
 
        /* sizeof(ParamListInfoData) includes the first array element */
        paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
-                                    (nargs - 1) * sizeof(ParamExternData));
+                                      (nargs - 1) *sizeof(ParamExternData));
        paramLI->numParams = nargs;
 
        for (i = 0; i < nargs; i++)
@@ -897,8 +897,8 @@ check_sql_fn_retval(Oid func_id, Oid rettype, List *queryTreeList,
    parse = (Query *) lfirst(list_tail(queryTreeList));
 
    /*
-    * Note: eventually replace this with QueryReturnsTuples?  We'd need
-    * more general method of determining the output type, though.
+    * Note: eventually replace this with QueryReturnsTuples?  We'd need a
+    * more general method of determining the output type, though.
     */
    isSelect = (parse->commandType == CMD_SELECT && parse->into == NULL);
 
index 19410997b2cee9b06212cf79848a6d3ba2f1bb6e..44609bb40b7b8b04606239a523ecaef3346b15f0 100644 (file)
@@ -61,7 +61,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.145 2006/07/27 19:52:05 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.146 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -331,16 +331,16 @@ advance_transition_function(AggState *aggstate,
                            AggStatePerGroup pergroupstate,
                            FunctionCallInfoData *fcinfo)
 {
-   int     numArguments = peraggstate->numArguments;
+   int         numArguments = peraggstate->numArguments;
    MemoryContext oldContext;
-   Datum newVal;
-   int i;
+   Datum       newVal;
+   int         i;
 
    if (peraggstate->transfn.fn_strict)
    {
        /*
-        * For a strict transfn, nothing happens when there's a NULL input;
-        * we just keep the prior transValue.
+        * For a strict transfn, nothing happens when there's a NULL input; we
+        * just keep the prior transValue.
         */
        for (i = 1; i <= numArguments; i++)
        {
@@ -434,14 +434,14 @@ advance_aggregates(AggState *aggstate, AggStatePerGroup pergroup)
 
    for (aggno = 0; aggno < aggstate->numaggs; aggno++)
    {
-       AggStatePerAgg      peraggstate = &aggstate->peragg[aggno];
-       AggStatePerGroup    pergroupstate = &pergroup[aggno];
-       AggrefExprState     *aggrefstate = peraggstate->aggrefstate;
-       Aggref              *aggref = peraggstate->aggref;
+       AggStatePerAgg peraggstate = &aggstate->peragg[aggno];
+       AggStatePerGroup pergroupstate = &pergroup[aggno];
+       AggrefExprState *aggrefstate = peraggstate->aggrefstate;
+       Aggref     *aggref = peraggstate->aggref;
        FunctionCallInfoData fcinfo;
-       int                 i;
-       ListCell            *arg;
-       MemoryContext       oldContext;
+       int         i;
+       ListCell   *arg;
+       MemoryContext oldContext;
 
        /* Switch memory context just once for all args */
        oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
@@ -495,8 +495,8 @@ process_sorted_aggregate(AggState *aggstate,
    bool        haveOldVal = false;
    MemoryContext workcontext = aggstate->tmpcontext->ecxt_per_tuple_memory;
    MemoryContext oldContext;
-   Datum       *newVal;
-   bool        *isNull;
+   Datum      *newVal;
+   bool       *isNull;
    FunctionCallInfoData fcinfo;
 
    tuplesort_performsort(peraggstate->sortstate);
@@ -624,7 +624,7 @@ static Bitmapset *
 find_unaggregated_cols(AggState *aggstate)
 {
    Agg        *node = (Agg *) aggstate->ss.ps.plan;
-   Bitmapset *colnos;
+   Bitmapset  *colnos;
 
    colnos = NULL;
    (void) find_unaggregated_cols_walker((Node *) node->plan.targetlist,
@@ -686,20 +686,20 @@ build_hash_table(AggState *aggstate)
                                              tmpmem);
 
    /*
-    * Create a list of the tuple columns that actually need to be stored
-    * in hashtable entries.  The incoming tuples from the child plan node
-    * will contain grouping columns, other columns referenced in our
-    * targetlist and qual, columns used to compute the aggregate functions,
-    * and perhaps just junk columns we don't use at all.  Only columns of the
-    * first two types need to be stored in the hashtable, and getting rid of
-    * the others can make the table entries significantly smaller.  To avoid
-    * messing up Var numbering, we keep the same tuple descriptor for
-    * hashtable entries as the incoming tuples have, but set unwanted columns
-    * to NULL in the tuples that go into the table.
+    * Create a list of the tuple columns that actually need to be stored in
+    * hashtable entries.  The incoming tuples from the child plan node will
+    * contain grouping columns, other columns referenced in our targetlist
+    * and qual, columns used to compute the aggregate functions, and perhaps
+    * just junk columns we don't use at all.  Only columns of the first two
+    * types need to be stored in the hashtable, and getting rid of the others
+    * can make the table entries significantly smaller.  To avoid messing up
+    * Var numbering, we keep the same tuple descriptor for hashtable entries
+    * as the incoming tuples have, but set unwanted columns to NULL in the
+    * tuples that go into the table.
     *
     * To eliminate duplicates, we build a bitmapset of the needed columns,
-    * then convert it to an integer list (cheaper to scan at runtime).
-    * The list is in decreasing order so that the first entry is the largest;
+    * then convert it to an integer list (cheaper to scan at runtime). The
+    * list is in decreasing order so that the first entry is the largest;
     * lookup_hash_entry depends on this to use slot_getsomeattrs correctly.
     *
     * Note: at present, searching the tlist/qual is not really necessary
@@ -767,7 +767,7 @@ lookup_hash_entry(AggState *aggstate, TupleTableSlot *inputslot)
    slot_getsomeattrs(inputslot, linitial_int(aggstate->hash_needed));
    foreach(l, aggstate->hash_needed)
    {
-       int     varNumber = lfirst_int(l) - 1;
+       int         varNumber = lfirst_int(l) - 1;
 
        hashslot->tts_values[varNumber] = inputslot->tts_values[varNumber];
        hashslot->tts_isnull[varNumber] = inputslot->tts_isnull[varNumber];
@@ -968,10 +968,10 @@ agg_retrieve_direct(AggState *aggstate)
 
        /*
         * Use the representative input tuple for any references to
-        * non-aggregated input columns in the qual and tlist.  (If we are
-        * not grouping, and there are no input rows at all, we will come
-        * here with an empty firstSlot ... but if not grouping, there can't
-        * be any references to non-aggregated input columns, so no problem.)
+        * non-aggregated input columns in the qual and tlist.  (If we are not
+        * grouping, and there are no input rows at all, we will come here
+        * with an empty firstSlot ... but if not grouping, there can't be any
+        * references to non-aggregated input columns, so no problem.)
         */
        econtext->ecxt_scantuple = firstSlot;
 
@@ -1226,8 +1226,8 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
    /*
     * initialize child nodes
     *
-    * If we are doing a hashed aggregation then the child plan does not
-    * need to handle REWIND efficiently; see ExecReScanAgg.
+    * If we are doing a hashed aggregation then the child plan does not need
+    * to handle REWIND efficiently; see ExecReScanAgg.
     */
    if (node->aggstrategy == AGG_HASHED)
        eflags &= ~EXEC_FLAG_REWIND;
@@ -1321,7 +1321,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
        Aggref     *aggref = (Aggref *) aggrefstate->xprstate.expr;
        AggStatePerAgg peraggstate;
        Oid         inputTypes[FUNC_MAX_ARGS];
-       int         numArguments;
+       int         numArguments;
        HeapTuple   aggTuple;
        Form_pg_aggregate aggform;
        Oid         aggtranstype;
@@ -1332,7 +1332,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
                   *finalfnexpr;
        Datum       textInitVal;
        int         i;
-       ListCell    *lc;
+       ListCell   *lc;
 
        /* Planner should have assigned aggregate to correct level */
        Assert(aggref->agglevelsup == 0);
@@ -1364,9 +1364,9 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
        peraggstate->numArguments = numArguments;
 
        /*
-        * Get actual datatypes of the inputs.  These could be different
-        * from the agg's declared input types, when the agg accepts ANY,
-        * ANYARRAY or ANYELEMENT.
+        * Get actual datatypes of the inputs.  These could be different from
+        * the agg's declared input types, when the agg accepts ANY, ANYARRAY
+        * or ANYELEMENT.
         */
        i = 0;
        foreach(lc, aggref->args)
@@ -1481,8 +1481,8 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
 
        /*
         * 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
+        * 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...
         */
@@ -1504,9 +1504,9 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
            Assert(node->aggstrategy != AGG_HASHED);
 
            /*
-            * We don't currently implement DISTINCT aggs for aggs having
-            * more than one argument.  This isn't required for anything
-            * in the SQL spec, but really it ought to be implemented for
+            * We don't currently implement DISTINCT aggs for aggs having more
+            * than one argument.  This isn't required for anything in the SQL
+            * spec, but really it ought to be implemented for
             * feature-completeness.  FIXME someday.
             */
            if (numArguments != 1)
index 719381f10b04ca0b0058ec2e4f4bcc37c00f3bc1..1034f96b6eff94e5e83b9057f5a0fefdb8f4b980 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.70 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeAppend.c,v 1.71 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -345,9 +345,9 @@ ExecReScanAppend(AppendState *node, ExprContext *exprCtxt)
 
        /*
         * If chgParam of subnode is not null then plan will be re-scanned by
-        * first ExecProcNode.  However, if caller is passing us an exprCtxt
-        * then forcibly rescan all the subnodes now, so that we can pass
-        * the exprCtxt down to the subnodes (needed for appendrel indexscan).
+        * first ExecProcNode.  However, if caller is passing us an exprCtxt
+        * then forcibly rescan all the subnodes now, so that we can pass the
+        * exprCtxt down to the subnodes (needed for appendrel indexscan).
         */
        if (subnode->chgParam == NULL || exprCtxt != NULL)
        {
index 62f166cdebe440a940189e70bf1207e0259e9c69..e1e006226908d7025115419fad3c94bd2e707017 100644 (file)
@@ -21,7 +21,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.13 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.14 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -192,8 +192,8 @@ BitmapHeapNext(BitmapHeapScanState *node)
        pgstat_count_heap_fetch(&scan->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(&scan->rs_ctup,
                       slot,
@@ -201,8 +201,8 @@ BitmapHeapNext(BitmapHeapScanState *node)
                       false);
 
        /*
-        * If we are using lossy info, we have to recheck the qual
-        * conditions at every tuple.
+        * If we are using lossy info, we have to recheck the qual conditions
+        * at every tuple.
         */
        if (tbmres->ntuples < 0)
        {
@@ -237,7 +237,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static void
 bitgetpage(HeapScanDesc scan, TBMIterateResult *tbmres)
 {
-   BlockNumber page = tbmres->blockno;
+   BlockNumber page = tbmres->blockno;
    Buffer      buffer;
    Snapshot    snapshot;
    Page        dp;
@@ -259,9 +259,9 @@ bitgetpage(HeapScanDesc scan, TBMIterateResult *tbmres)
    snapshot = scan->rs_snapshot;
 
    /*
-    * We must hold share lock on the buffer content while examining
-    * tuple visibility.  Afterwards, however, the tuples we have found
-    * to be visible are guaranteed good as long as we hold the buffer pin.
+    * We must hold share lock on the buffer content while examining tuple
+    * visibility.  Afterwards, however, the tuples we have found to be
+    * visible are guaranteed good as long as we hold the buffer pin.
     */
    LockBuffer(buffer, BUFFER_LOCK_SHARE);
 
@@ -269,10 +269,9 @@ bitgetpage(HeapScanDesc scan, TBMIterateResult *tbmres)
    maxoff = PageGetMaxOffsetNumber(dp);
 
    /*
-    * 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)
    {
@@ -467,8 +466,8 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
    Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
 
    /*
-    * Assert caller didn't ask for an unsafe snapshot --- see comments
-    * at head of file.
+    * Assert caller didn't ask for an unsafe snapshot --- see comments at
+    * head of file.
     */
    Assert(IsMVCCSnapshot(estate->es_snapshot));
 
@@ -549,8 +548,8 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
     * initialize child nodes
     *
     * We do this last because the child nodes will open indexscans on our
-    * relation's indexes, and we want to be sure we have acquired a lock
-    * on the relation first.
+    * relation's indexes, and we want to be sure we have acquired a lock on
+    * the relation first.
     */
    outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, eflags);
 
index 6a0303cddd12b7539466945a5c8c53d510622e4c..1b2e5a7652d8cf71a04c9673a3ebae615186bc8f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.20 2006/07/31 20:09:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.21 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -57,8 +57,8 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node)
    /*
     * If we have runtime keys and they've not already been set up, do it now.
     * Array keys are also treated as runtime keys; note that if ExecReScan
-    * returns with biss_RuntimeKeysReady still false, then there is an
-    * empty array key so we should do nothing.
+    * returns with biss_RuntimeKeysReady still false, then there is an empty
+    * array key so we should do nothing.
     */
    if (!node->biss_RuntimeKeysReady &&
        (node->biss_NumRuntimeKeys != 0 || node->biss_NumArrayKeys != 0))
@@ -152,9 +152,9 @@ ExecBitmapIndexReScan(BitmapIndexScanState *node, ExprContext *exprCtxt)
     * If we are doing runtime key calculations (ie, the index keys depend on
     * data from an outer scan), compute the new key values.
     *
-    * Array keys are also treated as runtime keys; note that if we
-    * return with biss_RuntimeKeysReady still false, then there is an
-    * empty array key so no index scan is needed.
+    * Array keys are also treated as runtime keys; note that if we return
+    * with biss_RuntimeKeysReady still false, then there is an empty array
+    * key so no index scan is needed.
     */
    if (node->biss_NumRuntimeKeys != 0)
        ExecIndexEvalRuntimeKeys(econtext,
@@ -249,8 +249,8 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
 
    /*
     * We do not open or lock the base relation here.  We assume that an
-    * ancestor BitmapHeapScan node is holding AccessShareLock (or better)
-    * on the heap relation throughout the execution of the plan tree.
+    * ancestor BitmapHeapScan node is holding AccessShareLock (or better) on
+    * the heap relation throughout the execution of the plan tree.
     */
 
    indexstate->ss.ss_currentRelation = NULL;
@@ -265,7 +265,7 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags)
     */
    relistarget = ExecRelationIsTargetRelation(estate, node->scan.scanrelid);
    indexstate->biss_RelationDesc = index_open(node->indexid,
-                                   relistarget ? NoLock : AccessShareLock);
+                                    relistarget ? NoLock : AccessShareLock);
 
    /*
     * Initialize index-specific scan state
index 43084ed05bb8ce19e915fed2bbb58df8f7f73b50..14fd016e5a5a442a19c87b6fc86799888861f932 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.84 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.85 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -119,11 +119,11 @@ ExecHashJoin(HashJoinState *node)
         * since we aren't going to be able to skip the join on the strength
         * of an empty inner relation anyway.)
         *
-        * If we are rescanning the join, we make use of information gained
-        * on the previous scan: don't bother to try the prefetch if the
-        * previous scan found the outer relation nonempty.  This is not
-        * 100% reliable since with new parameters the outer relation might
-        * yield different results, but it's a good heuristic.
+        * If we are rescanning the join, we make use of information gained on
+        * the previous scan: don't bother to try the prefetch if the previous
+        * scan found the outer relation nonempty.  This is not 100% reliable
+        * since with new parameters the outer relation might yield different
+        * results, but it's a good heuristic.
         *
         * 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
@@ -173,8 +173,8 @@ ExecHashJoin(HashJoinState *node)
 
        /*
         * Reset OuterNotEmpty for scan.  (It's OK if we fetched a tuple
-        * above, because ExecHashJoinOuterGetTuple will immediately
-        * set it again.)
+        * above, because ExecHashJoinOuterGetTuple will immediately set it
+        * again.)
         */
        node->hj_OuterNotEmpty = false;
    }
@@ -788,12 +788,12 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
    MinimalTuple tuple;
 
    /*
-    * Since both the hash value and the MinimalTuple length word are
-    * uint32, we can read them both in one BufFileRead() call without
-    * any type cheating.
+    * Since both the hash value and the MinimalTuple length word are uint32,
+    * we can read them both in one BufFileRead() call without any type
+    * cheating.
     */
    nread = BufFileRead(file, (void *) header, sizeof(header));
-   if (nread == 0)         /* end of file */
+   if (nread == 0)             /* end of file */
    {
        ExecClearTuple(tupleSlot);
        return NULL;
@@ -834,8 +834,8 @@ ExecReScanHashJoin(HashJoinState *node, ExprContext *exprCtxt)
            /*
             * okay to reuse the hash table; needn't rescan inner, either.
             *
-            * What we do need to do is reset our state about the emptiness
-            * of the outer relation, so that the new scan of the outer will
+            * What we do need to do is reset our state about the emptiness of
+            * the outer relation, so that the new scan of the outer will
             * update it correctly if it turns out to be empty this time.
             * (There's no harm in clearing it now because ExecHashJoin won't
             * need the info.  In the other cases, where the hash table
index 84ee56beb0ff6a22b1bcf9d7152b64bc41e1f98e..9773f2341ec78eda88b6fceb7a09c0ea1fe6fbe0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.116 2006/07/31 20:09:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.117 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -233,9 +233,9 @@ ExecIndexEvalRuntimeKeys(ExprContext *econtext,
        bool        isNull;
 
        /*
-        * For each run-time key, extract the run-time expression and
-        * evaluate it with respect to the current outer tuple.  We then stick
-        * the result into the proper scan key.
+        * For each run-time key, extract the run-time expression and evaluate
+        * it with respect to the current outer tuple.  We then stick the
+        * result into the proper 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
@@ -290,8 +290,8 @@ ExecIndexEvalArrayKeys(ExprContext *econtext,
        bool       *elem_nulls;
 
        /*
-        * Compute and deconstruct the array expression.
-        * (Notes in ExecIndexEvalRuntimeKeys() apply here too.)
+        * Compute and deconstruct the array expression. (Notes in
+        * ExecIndexEvalRuntimeKeys() apply here too.)
         */
        arraydatum = ExecEvalExpr(array_expr,
                                  econtext,
@@ -317,8 +317,9 @@ ExecIndexEvalArrayKeys(ExprContext *econtext,
        }
 
        /*
-        * Note: we expect the previous array data, if any, to be automatically
-        * freed by resetting the per-tuple context; hence no pfree's here.
+        * Note: we expect the previous array data, if any, to be
+        * automatically freed by resetting the per-tuple context; hence no
+        * pfree's here.
         */
        arrayKeys[j].elem_values = elem_values;
        arrayKeys[j].elem_nulls = elem_nulls;
@@ -524,7 +525,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
     */
    relistarget = ExecRelationIsTargetRelation(estate, node->scan.scanrelid);
    indexstate->iss_RelationDesc = index_open(node->indexid,
-                                   relistarget ? NoLock : AccessShareLock);
+                                    relistarget ? NoLock : AccessShareLock);
 
    /*
     * Initialize index-specific scan state
@@ -543,7 +544,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, int eflags)
                           &indexstate->iss_NumScanKeys,
                           &indexstate->iss_RuntimeKeys,
                           &indexstate->iss_NumRuntimeKeys,
-                          NULL,                /* no ArrayKeys */
+                          NULL,    /* no ArrayKeys */
                           NULL);
 
    /*
@@ -661,7 +662,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
    /*
     * If there are any RowCompareExpr quals, we need extra ScanKey entries
     * for them, and possibly extra runtime-key entries.  Count up what's
-    * needed.  (The subsidiary ScanKey arrays for the RowCompareExprs could
+    * needed.  (The subsidiary ScanKey arrays for the RowCompareExprs could
     * be allocated as separate chunks, but we have to count anyway to make
     * runtime_keys large enough, so might as well just do one palloc.)
     */
@@ -784,9 +785,9 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
        {
            /* (indexkey, indexkey, ...) op (expression, expression, ...) */
            RowCompareExpr *rc = (RowCompareExpr *) clause;
-           ListCell *largs_cell = list_head(rc->largs);
-           ListCell *rargs_cell = list_head(rc->rargs);
-           ListCell *opnos_cell = list_head(rc->opnos);
+           ListCell   *largs_cell = list_head(rc->largs);
+           ListCell   *rargs_cell = list_head(rc->rargs);
+           ListCell   *opnos_cell = list_head(rc->opnos);
            ScanKey     first_sub_key = &scan_keys[extra_scan_keys];
 
            /* Scan RowCompare columns and generate subsidiary ScanKey items */
@@ -859,7 +860,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                opclass = index->rd_indclass->values[varattno - 1];
 
                get_op_opclass_properties(opno, opclass,
-                                   &op_strategy, &op_subtype, &op_recheck);
+                                    &op_strategy, &op_subtype, &op_recheck);
 
                if (op_strategy != rc->rctype)
                    elog(ERROR, "RowCompare index qualification contains wrong operator");
@@ -871,11 +872,11 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                 */
                ScanKeyEntryInitialize(this_sub_key,
                                       flags,
-                                      varattno,    /* attribute number */
-                                      op_strategy, /* op's strategy */
-                                      op_subtype,  /* strategy subtype */
-                                      opfuncid,    /* reg proc to use */
-                                      scanvalue);  /* constant */
+                                      varattno,        /* attribute number */
+                                      op_strategy,     /* op's strategy */
+                                      op_subtype,      /* strategy subtype */
+                                      opfuncid,        /* reg proc to use */
+                                      scanvalue);      /* constant */
                extra_scan_keys++;
            }
 
@@ -883,8 +884,8 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
            scan_keys[extra_scan_keys - 1].sk_flags |= SK_ROW_END;
 
            /*
-            * We don't use ScanKeyEntryInitialize for the header because
-            * it isn't going to contain a valid sk_func pointer.
+            * We don't use ScanKeyEntryInitialize for the header because it
+            * isn't going to contain a valid sk_func pointer.
             */
            MemSet(this_scan_key, 0, sizeof(ScanKeyData));
            this_scan_key->sk_flags = SK_ROW_HEADER;
@@ -937,7 +938,7 @@ ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
             * initialize the scan key's fields appropriately
             */
            ScanKeyEntryInitialize(this_scan_key,
-                                  0,           /* flags */
+                                  0,   /* flags */
                                   varattno,    /* attribute number to scan */
                                   strategy,    /* op's strategy */
                                   subtype,     /* strategy subtype */
index 84a494cf0da2f61b6d81710d2f3d77451e5945a6..3774edc612070ea25c7d5726b824121790748505 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeMaterial.c,v 1.56 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeMaterial.c,v 1.57 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -124,16 +124,16 @@ ExecMaterial(MaterialState *node)
        }
 
        /*
-        * Append returned tuple to tuplestore.  NOTE: because the
-        * tuplestore is certainly in EOF state, its read position will move
-        * forward over the added tuple.  This is what we want.
+        * Append returned tuple to tuplestore.  NOTE: because the tuplestore
+        * is certainly in EOF state, its read position will move forward over
+        * the added tuple.  This is what we want.
         */
        if (tuplestorestate)
            tuplestore_puttupleslot(tuplestorestate, outerslot);
 
        /*
-        * And return a copy of the tuple.  (XXX couldn't we just return
-        * the outerslot?)
+        * And return a copy of the tuple.  (XXX couldn't we just return the
+        * outerslot?)
         */
        return ExecCopySlot(slot, outerslot);
    }
@@ -162,10 +162,10 @@ ExecInitMaterial(Material *node, EState *estate, int eflags)
    matstate->ss.ps.state = estate;
 
    /*
-    * We must have random access to the subplan output to do backward scan
-    * or mark/restore.  We also prefer to materialize the subplan output
-    * if we might be called on to rewind and replay it many times.
-    * However, if none of these cases apply, we can skip storing the data.
+    * We must have random access to the subplan output to do backward scan or
+    * mark/restore.  We also prefer to materialize the subplan output if we
+    * might be called on to rewind and replay it many times. However, if none
+    * of these cases apply, we can skip storing the data.
     */
    matstate->randomAccess = (eflags & (EXEC_FLAG_REWIND |
                                        EXEC_FLAG_BACKWARD |
@@ -194,8 +194,8 @@ ExecInitMaterial(Material *node, EState *estate, int eflags)
    /*
     * initialize child nodes
     *
-    * We shield the child node from the need to support REWIND, BACKWARD,
-    * or MARK/RESTORE.
+    * We shield the child node from the need to support REWIND, BACKWARD, or
+    * MARK/RESTORE.
     */
    eflags &= ~(EXEC_FLAG_REWIND | EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK);
 
index 75403dfa7174c0b987c6b40ffaf01b7971896b96..8a9f6fe230061804f970c1a57b89dff391f4e557 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.81 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeMergejoin.c,v 1.82 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -957,10 +957,10 @@ ExecMergeJoin(MergeJoinState *node)
                }
 
                /*
-                * Load up the new inner tuple's comparison values.  If we
-                * see that it contains a NULL and hence can't match any
-                * outer tuple, we can skip the comparison and assume the
-                * new tuple is greater than current outer.
+                * Load up the new inner tuple's comparison values.  If we see
+                * that it contains a NULL and hence can't match any outer
+                * tuple, we can skip the comparison and assume the new tuple
+                * is greater than current outer.
                 */
                if (!MJEvalInnerValues(node, innerTupleSlot))
                {
@@ -1377,8 +1377,8 @@ ExecMergeJoin(MergeJoinState *node)
                else
                {
                    /*
-                    * current inner can't possibly match any outer;
-                    * better to advance the inner scan than the outer.
+                    * current inner can't possibly match any outer; better to
+                    * advance the inner scan than the outer.
                     */
                    node->mj_JoinState = EXEC_MJ_SKIPINNER_ADVANCE;
                }
index f12f2f624f621d5dd599ec74d20161dca8cfd576..1c0a696f53340196819af2ccdeb8e621bc90ee96 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeNestloop.c,v 1.42 2006/03/05 15:58:26 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeNestloop.c,v 1.43 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -314,10 +314,10 @@ ExecInitNestLoop(NestLoop *node, EState *estate, int eflags)
     * initialize child nodes
     *
     * Tell the inner child that cheap rescans would be good.  (This is
-    * unnecessary if we are doing nestloop with inner indexscan, because
-    * the rescan will always be with a fresh parameter --- but since
-    * nodeIndexscan doesn't actually care about REWIND, there's no point
-    * in dealing with that refinement.)
+    * unnecessary if we are doing nestloop with inner indexscan, because the
+    * rescan will always be with a fresh parameter --- but since
+    * nodeIndexscan doesn't actually care about REWIND, there's no point in
+    * dealing with that refinement.)
     */
    outerPlanState(nlstate) = ExecInitNode(outerPlan(node), estate, eflags);
    innerPlanState(nlstate) = ExecInitNode(innerPlan(node), estate,
index c2ed276e56e881ba9c3995d968abe16394050cb3..a6287793d44b8d8f4ab644fdc8e2a5038c8be3b6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.60 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeSeqscan.c,v 1.61 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -148,7 +148,7 @@ InitScanRelation(SeqScanState *node, EState *estate)
     * open that relation and acquire appropriate lock on it.
     */
    currentRelation = ExecOpenScanRelation(estate,
-                                          ((SeqScan *) node->ps.plan)->scanrelid);
+                                    ((SeqScan *) node->ps.plan)->scanrelid);
 
    currentScanDesc = heap_beginscan(currentRelation,
                                     estate->es_snapshot,
index b586a37a642ef68d34fc3fbd03f981daf76e0c6b..dd473489974fd33b4054704de6297c72b85996cb 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeSort.c,v 1.57 2006/06/27 16:53:02 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeSort.c,v 1.58 2006/10/04 00:29:52 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -158,9 +158,9 @@ ExecInitSort(Sort *node, EState *estate, int eflags)
    sortstate->ss.ps.state = estate;
 
    /*
-    * We must have random access to the sort output to do backward scan
-    * or mark/restore.  We also prefer to materialize the sort output
-    * if we might be called on to rewind and replay it many times.
+    * We must have random access to the sort output to do backward scan or
+    * mark/restore.  We also prefer to materialize the sort output if we
+    * might be called on to rewind and replay it many times.
     */
    sortstate->randomAccess = (eflags & (EXEC_FLAG_REWIND |
                                         EXEC_FLAG_BACKWARD |
@@ -189,8 +189,8 @@ ExecInitSort(Sort *node, EState *estate, int eflags)
    /*
     * initialize child nodes
     *
-    * We shield the child node from the need to support REWIND, BACKWARD,
-    * or MARK/RESTORE.
+    * We shield the child node from the need to support REWIND, BACKWARD, or
+    * MARK/RESTORE.
     */
    eflags &= ~(EXEC_FLAG_REWIND | EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK);
 
@@ -316,6 +316,7 @@ ExecReScanSort(SortState *node, ExprContext *exprCtxt)
        node->sort_Done = false;
        tuplesort_end((Tuplesortstate *) node->tuplesortstate);
        node->tuplesortstate = NULL;
+
        /*
         * if chgParam of subnode is not null then plan will be re-scanned by
         * first ExecProcNode.
index 600a39d4ee8a261567a865ae888d9af5780f544e..2a5fd6d955da4eb18c37f5095272122e6817caff 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.79 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.80 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -332,8 +332,8 @@ ExecScanSubPlan(SubPlanState *node,
 
        /*
         * For ALL, ANY, and ROWCOMPARE sublinks, load up the Params
-        * representing the columns of the sub-select, and then evaluate
-        * the combining expression.
+        * representing the columns of the sub-select, and then evaluate the
+        * combining expression.
         */
        col = 1;
        foreach(plst, subplan->paramIds)
@@ -434,8 +434,8 @@ buildSubPlanHash(SubPlanState *node)
     * 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
+    * 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
@@ -682,9 +682,9 @@ ExecInitSubPlan(SubPlanState *node, EState *estate, int eflags)
    /*
     * Start up the subplan (this is a very cut-down form of InitPlan())
     *
-    * The subplan will never need to do BACKWARD scan or MARK/RESTORE.
-    * If it is a parameterless subplan (not initplan), we suggest that it
-    * be prepared to handle REWIND efficiently; otherwise there is no need.
+    * The subplan will never need to do BACKWARD scan or MARK/RESTORE. If it
+    * is a parameterless subplan (not initplan), we suggest that it be
+    * prepared to handle REWIND efficiently; otherwise there is no need.
     */
    eflags &= EXEC_FLAG_EXPLAIN_ONLY;
    if (subplan->parParam == NIL && subplan->setParam == NIL)
index 0436ea82be226916015b2682b7be6b162e13f1ac..22e148ec6c9a2b32a3130532a14ab9eb5df2bf69 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.31 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.32 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -204,7 +204,7 @@ ExecInitSubqueryScan(SubqueryScan *node, EState *estate, int eflags)
     * too soon during shutdown.
     */
    ExecAssignScanType(&subquerystate->ss,
-           CreateTupleDescCopy(ExecGetResultType(subquerystate->subplan)));
+            CreateTupleDescCopy(ExecGetResultType(subquerystate->subplan)));
 
    /*
     * Initialize result tuple type and projection info.
index b59ff9ca8ec32d2f6938174cb31c15913b5c371f..52d92904577397b49e5c5383328f41234baaf49f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.50 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.51 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -60,9 +60,9 @@ TidListCreate(TidScanState *tidstate)
    ListCell   *l;
 
    /*
-    * We initialize the array with enough slots for the case that all
-    * quals are simple OpExprs.  If there's any ScalarArrayOpExprs,
-    * we may have to enlarge the array.
+    * We initialize the array with enough slots for the case that all quals
+    * are simple OpExprs.  If there's any ScalarArrayOpExprs, we may have to
+    * enlarge the array.
     */
    numAllocTids = list_length(evalList);
    tidList = (ItemPointerData *)
@@ -78,9 +78,9 @@ TidListCreate(TidScanState *tidstate)
 
        if (is_opclause(expr))
        {
-           FuncExprState  *fexstate = (FuncExprState *) exstate;
-           Node *arg1;
-           Node *arg2;
+           FuncExprState *fexstate = (FuncExprState *) exstate;
+           Node       *arg1;
+           Node       *arg2;
 
            arg1 = get_leftop(expr);
            arg2 = get_rightop(expr);
@@ -154,15 +154,14 @@ TidListCreate(TidScanState *tidstate)
 
    /*
     * Sort the array of TIDs into order, and eliminate duplicates.
-    * Eliminating duplicates is necessary since we want OR semantics
-    * across the list.  Sorting makes it easier to detect duplicates,
-    * and as a bonus ensures that we will visit the heap in the most
-    * efficient way.
+    * Eliminating duplicates is necessary since we want OR semantics across
+    * the list.  Sorting makes it easier to detect duplicates, and as a bonus
+    * ensures that we will visit the heap in the most efficient way.
     */
    if (numTids > 1)
    {
-       int     lastTid;
-       int     i;
+       int         lastTid;
+       int         i;
 
        qsort((void *) tidList, numTids, sizeof(ItemPointerData),
              itemptr_comparator);
@@ -188,8 +187,8 @@ itemptr_comparator(const void *a, const void *b)
 {
    const ItemPointerData *ipa = (const ItemPointerData *) a;
    const ItemPointerData *ipb = (const ItemPointerData *) b;
-   BlockNumber ba = ItemPointerGetBlockNumber(ipa);
-   BlockNumber bb = ItemPointerGetBlockNumber(ipb);
+   BlockNumber ba = ItemPointerGetBlockNumber(ipa);
+   BlockNumber bb = ItemPointerGetBlockNumber(ipb);
    OffsetNumber oa = ItemPointerGetOffsetNumber(ipa);
    OffsetNumber ob = ItemPointerGetOffsetNumber(ipb);
 
index 1d4bb08d4dded3fe28119d37d722c7914323c045..c6a1a940389ce562ea5219bae43bf4be5fcb624b 100644 (file)
@@ -2,14 +2,14 @@
  *
  * nodeValuesscan.c
  *   Support routines for scanning Values lists
- *    ("VALUES (...), (...), ..." in rangetable).
+ *   ("VALUES (...), (...), ..." in rangetable).
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/nodeValuesscan.c,v 1.2 2006/08/02 18:58:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/nodeValuesscan.c,v 1.3 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,10 +47,10 @@ static TupleTableSlot *
 ValuesNext(ValuesScanState *node)
 {
    TupleTableSlot *slot;
-   EState         *estate;
-   ExprContext    *econtext;
-   ScanDirection   direction;
-   List           *exprlist;
+   EState     *estate;
+   ExprContext *econtext;
+   ScanDirection direction;
+   List       *exprlist;
 
    /*
     * get information from the estate and scan state
@@ -83,9 +83,9 @@ ValuesNext(ValuesScanState *node)
    }
 
    /*
-    * Always clear the result slot; this is appropriate if we are at the
-    * end of the data, and if we're not, we still need it as the first step
-    * of the store-virtual-tuple protocol.  It seems wise to clear the slot
+    * Always clear the result slot; this is appropriate if we are at the end
+    * of the data, and if we're not, we still need it as the first step of
+    * the store-virtual-tuple protocol.  It seems wise to clear the slot
     * before we reset the context it might have pointers into.
     */
    ExecClearTuple(slot);
@@ -107,18 +107,18 @@ ValuesNext(ValuesScanState *node)
        ReScanExprContext(econtext);
 
        /*
-        * Build the expression eval state in the econtext's per-tuple
-        * memory.  This is a tad unusual, but we want to delete the eval
-        * state again when we move to the next row, to avoid growth of
-        * memory requirements over a long values list.
+        * Build the expression eval state in the econtext's per-tuple memory.
+        * This is a tad unusual, but we want to delete the eval state again
+        * when we move to the next row, to avoid growth of memory
+        * requirements over a long values list.
         */
        oldContext = MemoryContextSwitchTo(econtext->ecxt_per_tuple_memory);
 
        /*
-        * Pass NULL, not my plan node, because we don't want anything
-        * in this transient state linking into permanent state.  The
-        * only possibility is a SubPlan, and there shouldn't be any
-        * (any subselects in the VALUES list should be InitPlans).
+        * Pass NULL, not my plan node, because we don't want anything in this
+        * transient state linking into permanent state.  The only possibility
+        * is a SubPlan, and there shouldn't be any (any subselects in the
+        * VALUES list should be InitPlans).
         */
        exprstatelist = (List *) ExecInitExpr((Expr *) exprlist, NULL);
 
@@ -126,8 +126,8 @@ ValuesNext(ValuesScanState *node)
        Assert(list_length(exprstatelist) == slot->tts_tupleDescriptor->natts);
 
        /*
-        * Compute the expressions and build a virtual result tuple.
-        * We already did ExecClearTuple(slot).
+        * Compute the expressions and build a virtual result tuple. We
+        * already did ExecClearTuple(slot).
         */
        values = slot->tts_values;
        isnull = slot->tts_isnull;
@@ -135,7 +135,7 @@ ValuesNext(ValuesScanState *node)
        resind = 0;
        foreach(lc, exprstatelist)
        {
-           ExprState *estate = (ExprState *) lfirst(lc);
+           ExprState  *estate = (ExprState *) lfirst(lc);
 
            values[resind] = ExecEvalExpr(estate,
                                          econtext,
@@ -181,12 +181,12 @@ ExecValuesScan(ValuesScanState *node)
 ValuesScanState *
 ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags)
 {
-   ValuesScanState    *scanstate;
-   RangeTblEntry      *rte;
-   TupleDesc           tupdesc;
-   ListCell           *vtl;
-   int                 i;
-   PlanState          *planstate;
+   ValuesScanState *scanstate;
+   RangeTblEntry *rte;
+   TupleDesc   tupdesc;
+   ListCell   *vtl;
+   int         i;
+   PlanState  *planstate;
 
    /*
     * ValuesScan should not have any children.
@@ -208,8 +208,8 @@ ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags)
 
    /*
     * Create expression contexts.  We need two, one for per-sublist
-    * processing and one for execScan.c to use for quals and projections.
-    * We cheat a little by using ExecAssignExprContext() to build both.
+    * processing and one for execScan.c to use for quals and projections. We
+    * cheat a little by using ExecAssignExprContext() to build both.
     */
    ExecAssignExprContext(estate, planstate);
    scanstate->rowcontext = planstate->ps_ExprContext;
index eb8d11fed9fbe12d7463adeaa0032dd3b46e35ed..5410c364e0af5e26129b4c47f71100f17148110e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.163 2006/09/07 22:52:00 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.164 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -827,8 +827,8 @@ SPI_cursor_open(const char *name, void *plan,
    int         k;
 
    /*
-    * Check that the plan is something the Portal code will special-case
-    * as returning one tupleset.
+    * Check that the plan is something the Portal code will special-case as
+    * returning one tupleset.
     */
    if (!SPI_is_cursor_plan(spiplan))
    {
@@ -846,7 +846,7 @@ SPI_cursor_open(const char *name, void *plan,
                     errmsg("cannot open empty query as cursor")));
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_CURSOR_DEFINITION),
-                /* translator: %s is name of a SQL command, eg INSERT */
+       /* translator: %s is name of a SQL command, eg INSERT */
                 errmsg("cannot open %s query as cursor",
                        CreateQueryTag(queryTree))));
    }
@@ -885,7 +885,7 @@ SPI_cursor_open(const char *name, void *plan,
    {
        /* sizeof(ParamListInfoData) includes the first array element */
        paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
-                           (spiplan->nargs - 1) * sizeof(ParamExternData));
+                             (spiplan->nargs - 1) *sizeof(ParamExternData));
        paramLI->numParams = spiplan->nargs;
 
        for (k = 0; k < spiplan->nargs; k++)
@@ -1348,7 +1348,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
 
            /* sizeof(ParamListInfoData) includes the first array element */
            paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
-                                    (nargs - 1) * sizeof(ParamExternData));
+                                      (nargs - 1) *sizeof(ParamExternData));
            paramLI->numParams = nargs;
 
            for (k = 0; k < nargs; k++)
@@ -1482,9 +1482,9 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, const char *Nulls,
                ActiveSnapshot = NULL;
 
                /*
-                * The last canSetTag query sets the status values returned
-                * to the caller.  Be careful to free any tuptables not
-                * returned, to avoid intratransaction memory leak.
+                * The last canSetTag query sets the status values returned to
+                * the caller.  Be careful to free any tuptables not returned,
+                * to avoid intratransaction memory leak.
                 */
                if (queryTree->canSetTag)
                {
index defe45334c7d90b4a89c7b0c2fb3b50bc368abf0..6e3ef149f3a70bf3b06fe7a23c3948337a26aeee 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.143 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.144 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -75,16 +75,17 @@ static Port *pam_port_cludge;   /* Workaround for passing "Port *port" into
 #include 
 
 /* Correct header from the Platform SDK */
-typedef ULONG (*__ldap_start_tls_sA)(
-    IN   PLDAP          ExternalHandle,
-    OUT  PULONG         ServerReturnValue,
-    OUT  LDAPMessage    **result,
-    IN   PLDAPControlA  *ServerControls,
-    IN   PLDAPControlA  *ClientControls
+typedef
+ULONG(*__ldap_start_tls_sA) (
+                            IN PLDAP ExternalHandle,
+                            OUT PULONG ServerReturnValue,
+                            OUT LDAPMessage ** result,
+                            IN PLDAPControlA * ServerControls,
+                            IN PLDAPControlA * ClientControls
 );
 #endif
 
-static int CheckLDAPAuth(Port *port);
+static int CheckLDAPAuth(Port *port);
 #endif
 
 
@@ -347,9 +348,9 @@ auth_failed(Port *port, int status)
            break;
 #endif   /* USE_PAM */
 #ifdef USE_LDAP
-        case uaLDAP:
-            errstr = gettext_noop("LDAP authentication failed for user \"%s\"");
-            break;
+       case uaLDAP:
+           errstr = gettext_noop("LDAP authentication failed for user \"%s\"");
+           break;
 #endif   /* USE_LDAP */
        default:
            errstr = gettext_noop("authentication failed for user \"%s\": invalid authentication method");
@@ -480,9 +481,9 @@ ClientAuthentication(Port *port)
 #endif   /* USE_PAM */
 
 #ifdef USE_LDAP
-        case uaLDAP:
-            status = CheckLDAPAuth(port);
-            break;
+       case uaLDAP:
+           status = CheckLDAPAuth(port);
+           break;
 #endif
 
        case uaTrust:
@@ -709,100 +710,102 @@ CheckPAMAuth(Port *port, char *user, char *password)
 static int
 CheckLDAPAuth(Port *port)
 {
-    char *passwd;
-    char server[128];
-    char basedn[128];
-    char prefix[128];
-    char suffix[128];
-    LDAP *ldap;
-    int  ssl = 0;
-    int  r;
-    int  ldapversion = LDAP_VERSION3;
-    int  ldapport = LDAP_PORT;
-    char fulluser[128];
-
-    if (!port->auth_arg || port->auth_arg[0] == '\0')
-    {
-        ereport(LOG,
-                (errmsg("LDAP configuration URL not specified")));
-        return STATUS_ERROR;
-    }
-
-    /* 
-     * Crack the LDAP url. We do a very trivial parse..
-     * ldap[s]://[:]/[;prefix[;suffix]]
-     */
-
-    server[0] = '\0';
-    basedn[0] = '\0';
-    prefix[0] = '\0';
-    suffix[0] = '\0';
-
-    /* ldap, including port number */
-    r = sscanf(port->auth_arg, 
-            "ldap://%127[^:]:%i/%127[^;];%127[^;];%127s",
-            server, &ldapport, basedn, prefix, suffix);
-    if (r < 3)
-    {
-        /* ldaps, including port number */
-        r = sscanf(port->auth_arg,
-                "ldaps://%127[^:]:%i/%127[^;];%127[^;];%127s",
-                server, &ldapport, basedn, prefix, suffix);
-        if (r >=3) ssl = 1;
-    }
-    if (r < 3)
-    {
-        /* ldap, no port number */
-        r = sscanf(port->auth_arg,
-                "ldap://%127[^/]/%127[^;];%127[^;];%127s",
-                server, basedn, prefix, suffix);
-    }
-    if (r < 2)
-    {
-        /* ldaps, no port number */
-        r = sscanf(port->auth_arg,
-                "ldaps://%127[^/]/%127[^;];%127[^;];%127s",
-                server, basedn, prefix, suffix);
-        if (r >= 2) ssl = 1;
-    }
-    if (r < 2)
-    {
-        ereport(LOG,
-                (errmsg("invalid LDAP URL: \"%s\"",
+   char       *passwd;
+   char        server[128];
+   char        basedn[128];
+   char        prefix[128];
+   char        suffix[128];
+   LDAP       *ldap;
+   int         ssl = 0;
+   int         r;
+   int         ldapversion = LDAP_VERSION3;
+   int         ldapport = LDAP_PORT;
+   char        fulluser[128];
+
+   if (!port->auth_arg || port->auth_arg[0] == '\0')
+   {
+       ereport(LOG,
+               (errmsg("LDAP configuration URL not specified")));
+       return STATUS_ERROR;
+   }
+
+   /*
+    * Crack the LDAP url. We do a very trivial parse..
+    * ldap[s]://[:]/[;prefix[;suffix]]
+    */
+
+   server[0] = '\0';
+   basedn[0] = '\0';
+   prefix[0] = '\0';
+   suffix[0] = '\0';
+
+   /* ldap, including port number */
+   r = sscanf(port->auth_arg,
+              "ldap://%127[^:]:%i/%127[^;];%127[^;];%127s",
+              server, &ldapport, basedn, prefix, suffix);
+   if (r < 3)
+   {
+       /* ldaps, including port number */
+       r = sscanf(port->auth_arg,
+                  "ldaps://%127[^:]:%i/%127[^;];%127[^;];%127s",
+                  server, &ldapport, basedn, prefix, suffix);
+       if (r >= 3)
+           ssl = 1;
+   }
+   if (r < 3)
+   {
+       /* ldap, no port number */
+       r = sscanf(port->auth_arg,
+                  "ldap://%127[^/]/%127[^;];%127[^;];%127s",
+                  server, basedn, prefix, suffix);
+   }
+   if (r < 2)
+   {
+       /* ldaps, no port number */
+       r = sscanf(port->auth_arg,
+                  "ldaps://%127[^/]/%127[^;];%127[^;];%127s",
+                  server, basedn, prefix, suffix);
+       if (r >= 2)
+           ssl = 1;
+   }
+   if (r < 2)
+   {
+       ereport(LOG,
+               (errmsg("invalid LDAP URL: \"%s\"",
                        port->auth_arg)));
-        return STATUS_ERROR;
-    }
-
-    sendAuthRequest(port, AUTH_REQ_PASSWORD);
-    
-    passwd = recv_password_packet(port);
-    if (passwd == NULL)
-        return STATUS_EOF; /* client wouldn't send password */
-   
-    ldap = ldap_init(server, ldapport);
-    if (!ldap)
-    {
+       return STATUS_ERROR;
+   }
+
+   sendAuthRequest(port, AUTH_REQ_PASSWORD);
+
+   passwd = recv_password_packet(port);
+   if (passwd == NULL)
+       return STATUS_EOF;      /* client wouldn't send password */
+
+   ldap = ldap_init(server, ldapport);
+   if (!ldap)
+   {
 #ifndef WIN32
-        ereport(LOG,
-                (errmsg("could not initialize LDAP: error code %d", 
-                        errno)));
+       ereport(LOG,
+               (errmsg("could not initialize LDAP: error code %d",
+                       errno)));
 #else
-        ereport(LOG,
-                (errmsg("could not initialize LDAP: error code %d", 
-                        (int) LdapGetLastError())));
+       ereport(LOG,
+               (errmsg("could not initialize LDAP: error code %d",
+                       (int) LdapGetLastError())));
 #endif
-        return STATUS_ERROR;
-    }
-
-    if ((r = ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, &ldapversion)) != LDAP_SUCCESS)
-    {
-        ereport(LOG,
-                (errmsg("could not set LDAP protocol version: error code %d", r)));
-        return STATUS_ERROR;
-    }
-    
-    if (ssl)
-    {
+       return STATUS_ERROR;
+   }
+
+   if ((r = ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, &ldapversion)) != LDAP_SUCCESS)
+   {
+       ereport(LOG,
+         (errmsg("could not set LDAP protocol version: error code %d", r)));
+       return STATUS_ERROR;
+   }
+
+   if (ssl)
+   {
 #ifndef WIN32
        if ((r = ldap_start_tls_s(ldap, NULL, NULL)) != LDAP_SUCCESS)
 #else
@@ -815,17 +818,20 @@ CheckLDAPAuth(Port *port)
             * exist on Windows 2000, and causes a load error for the whole
             * exe if referenced.
             */
-           HANDLE ldaphandle;
-           
+           HANDLE      ldaphandle;
+
            ldaphandle = LoadLibrary("WLDAP32.DLL");
            if (ldaphandle == NULL)
            {
-               /* should never happen since we import other files from wldap32, but check anyway */
+               /*
+                * should never happen since we import other files from
+                * wldap32, but check anyway
+                */
                ereport(LOG,
                        (errmsg("could not load wldap32.dll")));
                return STATUS_ERROR;
            }
-           _ldap_start_tls_sA = (__ldap_start_tls_sA)GetProcAddress(ldaphandle, "ldap_start_tls_sA");
+           _ldap_start_tls_sA = (__ldap_start_tls_sA) GetProcAddress(ldaphandle, "ldap_start_tls_sA");
            if (_ldap_start_tls_sA == NULL)
            {
                ereport(LOG,
@@ -839,33 +845,32 @@ CheckLDAPAuth(Port *port)
             * process and is automatically cleaned up on process exit.
             */
        }
-        if ((r = _ldap_start_tls_sA(ldap, NULL, NULL, NULL, NULL)) != LDAP_SUCCESS) 
+       if ((r = _ldap_start_tls_sA(ldap, NULL, NULL, NULL, NULL)) != LDAP_SUCCESS)
 #endif
-        {
-            ereport(LOG,
-                    (errmsg("could not start LDAP TLS session: error code %d", r)));
-            return STATUS_ERROR;
-        }
-    }
-
-    snprintf(fulluser, sizeof(fulluser)-1, "%s%s%s",
+       {
+           ereport(LOG,
+            (errmsg("could not start LDAP TLS session: error code %d", r)));
+           return STATUS_ERROR;
+       }
+   }
+
+   snprintf(fulluser, sizeof(fulluser) - 1, "%s%s%s",
             prefix, port->user_name, suffix);
-    fulluser[sizeof(fulluser)-1] = '\0';
+   fulluser[sizeof(fulluser) - 1] = '\0';
 
-    r = ldap_simple_bind_s(ldap, fulluser, passwd);
-    ldap_unbind(ldap);
+   r = ldap_simple_bind_s(ldap, fulluser, passwd);
+   ldap_unbind(ldap);
 
-    if (r != LDAP_SUCCESS)
-    {
-        ereport(LOG,
-                (errmsg("LDAP login failed for user \"%s\" on server \"%s\": error code %d",
+   if (r != LDAP_SUCCESS)
+   {
+       ereport(LOG,
+               (errmsg("LDAP login failed for user \"%s\" on server \"%s\": error code %d",
                        fulluser, server, r)));
-        return STATUS_ERROR;
-    }
-    
-    return STATUS_OK;
-}
+       return STATUS_ERROR;
+   }
 
+   return STATUS_OK;
+}
 #endif   /* USE_LDAP */
 
 /*
index 20c2cc7a3b56315887bc1f7959c48d31d8f60fe5..06a5b9a6c05fd45d07c245c163c850f12dd9ad4a 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.72 2006/09/04 14:57:27 petere Exp $
+ *   $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.73 2006/10/04 00:29:53 momjian Exp $
  *
  *   Since the server static private key ($DataDir/server.key)
  *   will normally be stored unencrypted so that the database
@@ -110,7 +110,7 @@ static DH  *load_dh_buffer(const char *, size_t);
 static DH  *tmp_dh_cb(SSL *s, int is_export, int keylength);
 static int verify_cb(int, X509_STORE_CTX *);
 static void info_cb(const SSL *ssl, int type, int args);
-static void    initialize_SSL(void);
+static void initialize_SSL(void);
 static void destroy_SSL(void);
 static int open_server_SSL(Port *);
 static void close_SSL(Port *);
@@ -795,8 +795,9 @@ initialize_SSL(void)
    else
    {
        /*
-        *  Check the Certificate Revocation List (CRL) if file exists.
-        *  http://searchsecurity.techtarget.com/sDefinition/0,,sid14_gci803160,00.html
+        * Check the Certificate Revocation List (CRL) if file exists.
+        * http://searchsecurity.techtarget.com/sDefinition/0,,sid14_gci803160,
+        * 00.html
         */
        X509_STORE *cvstore = SSL_CTX_get_cert_store(SSL_context);
 
@@ -807,19 +808,19 @@ initialize_SSL(void)
 /* OpenSSL 0.96 does not support X509_V_FLAG_CRL_CHECK */
 #ifdef X509_V_FLAG_CRL_CHECK
                X509_STORE_set_flags(cvstore,
-                           X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL);
+                         X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
 #else
                ereport(LOG,
-                   (errmsg("SSL Certificate Revocation List (CRL) file \"%s\" ignored",
-                           ROOT_CRL_FILE),
-                    errdetail("Installed SSL library does not support CRL.")));
+                       (errmsg("SSL Certificate Revocation List (CRL) file \"%s\" ignored",
+                               ROOT_CRL_FILE),
+                 errdetail("Installed SSL library does not support CRL.")));
 #endif
            else
            {
                /* Not fatal - we do not require CRL */
                ereport(LOG,
-                   (errmsg("SSL Certificate Revocation List (CRL) file \"%s\" not found, skipping: %s",
-                           ROOT_CRL_FILE, SSLerrmessage()),
+                       (errmsg("SSL Certificate Revocation List (CRL) file \"%s\" not found, skipping: %s",
+                               ROOT_CRL_FILE, SSLerrmessage()),
                     errdetail("Will not check certificates against CRL.")));
            }
        }
index e2f1f6c869e1e01965e7feb4799668e1b2b1765f..776d167ff2e66d789aaadab789ca501f37f44ab1 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.155 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.156 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -613,8 +613,8 @@ parse_hba_auth(ListCell **line_item, UserAuth *userauth_p,
        *userauth_p = uaPAM;
 #endif
 #ifdef USE_LDAP
-    else if (strcmp(token,"ldap") == 0)
-        *userauth_p = uaLDAP;
+   else if (strcmp(token, "ldap") == 0)
+       *userauth_p = uaLDAP;
 #endif
    else
    {
index 3a4c74b0a84efdcbadaff6fa1ad0ad38d4d56e56..9bf244410e079f9f945d5d5c1d10c96ea9b62ec3 100644 (file)
@@ -30,7 +30,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.187 2006/08/11 20:44:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.188 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -594,13 +594,14 @@ StreamConnection(int server_fd, Port *port)
        }
 
 #ifdef WIN32
+
        /*
-        *  This is a Win32 socket optimization.  The ideal size is 32k.
-        *  http://support.microsoft.com/kb/823764/EN-US/
+        * This is a Win32 socket optimization.  The ideal size is 32k.
+        * http://support.microsoft.com/kb/823764/EN-US/
         */
        on = PQ_BUFFER_SIZE * 4;
        if (setsockopt(port->sock, SOL_SOCKET, SO_SNDBUF, (char *) &on,
-           sizeof(on)) < 0)
+                      sizeof(on)) < 0)
        {
            elog(LOG, "setsockopt(SO_SNDBUF) failed: %m");
            return STATUS_ERROR;
index 150d28b44fd2a553becc53cce051c3014798f426..a750cfe9fd98929417698d331fe26bce73a26555 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/main/main.c,v 1.104 2006/07/14 14:52:19 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/main/main.c,v 1.105 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -90,6 +90,7 @@ main(int argc, char *argv[])
    set_pglocale_pgservice(argv[0], "postgres");
 
 #ifdef WIN32
+
    /*
     * Windows uses codepages rather than the environment, so we work around
     * that by querying the environment explicitly first for LC_COLLATE and
@@ -156,8 +157,7 @@ main(int argc, char *argv[])
    check_root(progname);
 
    /*
-    * Dispatch to one of various subprograms depending on first
-    * argument.
+    * Dispatch to one of various subprograms depending on first argument.
     */
 
 #ifdef EXEC_BACKEND
@@ -166,6 +166,7 @@ main(int argc, char *argv[])
 #endif
 
 #ifdef WIN32
+
    /*
     * Start our win32 signal implementation
     *
@@ -190,7 +191,7 @@ main(int argc, char *argv[])
 
 
 /*
- * Place platform-specific startup hacks here.  This is the right
+ * 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
@@ -211,12 +212,11 @@ startup_hacks(const char *progname)
 
 
    /*
-    * 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
 
@@ -230,8 +230,7 @@ startup_hacks(const char *progname)
        write_stderr("%s: setsysinfo failed: %s\n",
                     progname, strerror(errno));
 #endif
-
-#endif /* NOFIXADE */
+#endif   /* NOFIXADE */
 
 
 #ifdef WIN32
@@ -253,9 +252,9 @@ startup_hacks(const char *progname)
        }
 
        /* In case of general protection fault, don't show GUI popup box */
-        SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
+       SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
    }
-#endif /* WIN32 */
+#endif   /* WIN32 */
 }
 
 
@@ -315,7 +314,7 @@ help(const char *progname)
    printf(_("  -x NUM          internal use\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"
+    "configuration settings and how to set them on the command line or in\n"
             "the configuration file.\n\n"
             "Report bugs to .\n"));
 }
@@ -330,19 +329,18 @@ check_root(const char *progname)
    {
        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");
+         "possible system security compromise.  See the documentation for\n"
+                 "more information on how to properly start the server.\n");
        exit(1);
    }
 
    /*
-    * Also make sure that real and effective uids are the same.
-    * Executing 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 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())
    {
@@ -350,17 +348,17 @@ check_root(const char *progname)
                     progname);
        exit(1);
    }
-#else /* WIN32 */
+#else                          /* WIN32 */
    if (pgwin32_is_admin())
    {
        write_stderr("Execution of PostgreSQL by a user with administrative permissions is not\n"
                     "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");
+        "possible system security compromises.  See the documentation for\n"
+                 "more information on how to properly start the server.\n");
        exit(1);
    }
-#endif /* WIN32 */
+#endif   /* WIN32 */
 }
 
 
index fb1037f170488e5a12632c35992b826e379eec3e..f58a2ad3ec46de4de1e51d59bc8d72f294f412f0 100644 (file)
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.350 2006/08/30 23:34:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.351 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1050,7 +1050,7 @@ _copyRowExpr(RowExpr *from)
 static RowCompareExpr *
 _copyRowCompareExpr(RowCompareExpr *from)
 {
-   RowCompareExpr    *newnode = makeNode(RowCompareExpr);
+   RowCompareExpr *newnode = makeNode(RowCompareExpr);
 
    COPY_SCALAR_FIELD(rctype);
    COPY_NODE_FIELD(opnos);
@@ -2682,7 +2682,7 @@ _copyDeallocateStmt(DeallocateStmt *from)
 }
 
 static DropOwnedStmt *
-_copyDropOwnedStmt(DropOwnedStmt * from)
+_copyDropOwnedStmt(DropOwnedStmt *from)
 {
    DropOwnedStmt *newnode = makeNode(DropOwnedStmt);
 
@@ -2693,7 +2693,7 @@ _copyDropOwnedStmt(DropOwnedStmt * from)
 }
 
 static ReassignOwnedStmt *
-_copyReassignOwnedStmt(ReassignOwnedStmt * from)
+_copyReassignOwnedStmt(ReassignOwnedStmt *from)
 {
    ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
 
index 1912cdd319aa3aa1ddbbfdee636d7d2565f24a62..45dc76af9b66f1a421fa7ad56704213fa694bd88 100644 (file)
@@ -18,7 +18,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.284 2006/08/30 23:34:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.285 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1496,7 +1496,7 @@ _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
 }
 
 static bool
-_equalDropOwnedStmt(DropOwnedStmt * a, DropOwnedStmt * b)
+_equalDropOwnedStmt(DropOwnedStmt *a, DropOwnedStmt *b)
 {
    COMPARE_NODE_FIELD(roles);
    COMPARE_SCALAR_FIELD(behavior);
@@ -1505,7 +1505,7 @@ _equalDropOwnedStmt(DropOwnedStmt * a, DropOwnedStmt * b)
 }
 
 static bool
-_equalReassignOwnedStmt(ReassignOwnedStmt * a, ReassignOwnedStmt * b)
+_equalReassignOwnedStmt(ReassignOwnedStmt *a, ReassignOwnedStmt *b)
 {
    COMPARE_NODE_FIELD(roles);
    COMPARE_NODE_FIELD(newrole);
index 7555cbd0dd032cc8d2d1074d4bcbe88929ddcde5..9f6aa22707b500ddd7d250c17b8822c3bf5c2067 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.51 2006/08/21 00:57:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.52 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -330,7 +330,7 @@ makeFuncExpr(Oid funcid, Oid rettype, List *args, CoercionForm fformat)
 DefElem *
 makeDefElem(char *name, Node *arg)
 {
-   DefElem *res = makeNode(DefElem);
+   DefElem    *res = makeNode(DefElem);
 
    res->defname = name;
    res->arg = arg;
index 1d4e1d48e8b45a6dd38afb51567cca748b6da97e..7274f59788e85ded7a78371776143a74102a2478 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/nodes/params.c,v 1.6 2006/04/22 01:25:59 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/nodes/params.c,v 1.7 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -37,14 +37,14 @@ copyParamList(ParamListInfo from)
 
    /* sizeof(ParamListInfoData) includes the first array element */
    size = sizeof(ParamListInfoData) +
-       (from->numParams - 1) * sizeof(ParamExternData);
+       (from->numParams - 1) *sizeof(ParamExternData);
 
    retval = (ParamListInfo) palloc(size);
    memcpy(retval, from, size);
 
    /*
-    * Flat-copy is not good enough for pass-by-ref data values, so make
-    * pass over the array to copy those.
+    * Flat-copy is not good enough for pass-by-ref data values, so make a
+    * pass over the array to copy those.
     */
    for (i = 0; i < retval->numParams; i++)
    {
index 0c2b6920cd1b5c1fa79f0c2d9a721bfcdbd45f56..12da0781a0d8d5d0e551af76569b611d3de8ce41 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.153 2006/09/19 22:49:52 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.154 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -43,13 +43,13 @@ static void set_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti);
 static void set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
                       RangeTblEntry *rte);
 static void set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
-                                   Index rti, RangeTblEntry *rte);
+                       Index rti, RangeTblEntry *rte);
 static void set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel,
                      Index rti, RangeTblEntry *rte);
 static void set_function_pathlist(PlannerInfo *root, RelOptInfo *rel,
                      RangeTblEntry *rte);
 static void set_values_pathlist(PlannerInfo *root, RelOptInfo *rel,
-                     RangeTblEntry *rte);
+                   RangeTblEntry *rte);
 static RelOptInfo *make_rel_from_joinlist(PlannerInfo *root, List *joinlist);
 static RelOptInfo *make_one_rel_by_joins(PlannerInfo *root, int levels_needed,
                      List *initial_rels);
@@ -253,7 +253,7 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
  * set_append_rel_pathlist
  *   Build access paths for an "append relation"
  *
- * The passed-in rel and RTE represent the entire append relation.  The
+ * The passed-in rel and RTE represent the entire append relation. The
  * relation's contents are computed by appending together the output of
  * the individual member relations.  Note that in the inheritance case,
  * the first member relation is actually the same table as is mentioned in
@@ -271,8 +271,8 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
    /*
     * XXX for now, can't handle inherited expansion of FOR UPDATE/SHARE; can
     * we do better?  (This will take some redesign because the executor
-    * currently supposes that every rowMark relation is involved in every
-    * row returned by the query.)
+    * currently supposes that every rowMark relation is involved in every row
+    * returned by the query.)
     */
    if (get_rowmark(root->parse, parentRTindex))
        ereport(ERROR,
@@ -336,16 +336,16 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
                                         childrel->max_attr);
 
        /*
-        * Compute the child's access paths, and add the cheapest one
-        * to the Append path we are constructing for the parent.
+        * Compute the child's access paths, and add the cheapest one to the
+        * Append path we are constructing for the parent.
         *
-        * It's possible that the child is itself an appendrel, in which
-        * case we can "cut out the middleman" and just add its child
-        * paths to our own list.  (We don't try to do this earlier because
-        * we need to apply both levels of transformation to the quals.)
-        * This test also handles the case where the child rel need not
-        * be scanned because of constraint exclusion: it'll have an
-        * Append path with no subpaths, and will vanish from our list.
+        * It's possible that the child is itself an appendrel, in which case
+        * we can "cut out the middleman" and just add its child paths to our
+        * own list.  (We don't try to do this earlier because we need to
+        * apply both levels of transformation to the quals.) This test also
+        * handles the case where the child rel need not be scanned because of
+        * constraint exclusion: it'll have an Append path with no subpaths,
+        * and will vanish from our list.
         */
        set_rel_pathlist(root, childrel, childRTindex);
 
index 269a6ed7e78621f5faef4d5333831dda2294da2a..f51bac9b0e8c88fc22eaadf378ac4b35e24b90ab 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.81 2006/07/14 14:52:20 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/clausesel.c,v 1.82 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -429,16 +429,16 @@ clause_selectivity(PlannerInfo *root,
        rinfo = (RestrictInfo *) clause;
 
        /*
-        * If the clause is marked pseudoconstant, then it will be used as
-        * gating qual and should not affect selectivity estimates; hence
-        * return 1.0.  The only exception is that a constant FALSE may
-        * be taken as having selectivity 0.0, since it will surely mean
-        * no rows out of the plan.  This case is simple enough that we
-        * need not bother caching the result.
+        * If the clause is marked pseudoconstant, then it will be used as a
+        * gating qual and should not affect selectivity estimates; hence
+        * return 1.0.  The only exception is that a constant FALSE may be
+        * taken as having selectivity 0.0, since it will surely mean no rows
+        * out of the plan.  This case is simple enough that we need not
+        * bother caching the result.
         */
        if (rinfo->pseudoconstant)
        {
-           if (! IsA(rinfo->clause, Const))
+           if (!IsA(rinfo->clause, Const))
                return s1;
        }
 
@@ -529,7 +529,7 @@ clause_selectivity(PlannerInfo *root,
    else if (IsA(clause, Const))
    {
        /* bool constant is pretty easy... */
-       Const  *con = (Const *) clause;
+       Const      *con = (Const *) clause;
 
        s1 = con->constisnull ? 0.0 :
            DatumGetBool(con->constvalue) ? 1.0 : 0.0;
@@ -542,7 +542,7 @@ clause_selectivity(PlannerInfo *root,
        if (IsA(subst, Const))
        {
            /* bool constant is pretty easy... */
-           Const  *con = (Const *) subst;
+           Const      *con = (Const *) subst;
 
            s1 = con->constisnull ? 0.0 :
                DatumGetBool(con->constvalue) ? 1.0 : 0.0;
index cd289423ecdbd95a2bbcd3bbdbc9693161e8cec3..f2a6d294ee8ba5c4da916ac2499a8939b49e4b2c 100644 (file)
@@ -54,7 +54,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.166 2006/09/19 22:49:52 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.167 2006/10/04 00:29:53 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -92,7 +92,7 @@ double        cpu_tuple_cost = DEFAULT_CPU_TUPLE_COST;
 double     cpu_index_tuple_cost = DEFAULT_CPU_INDEX_TUPLE_COST;
 double     cpu_operator_cost = DEFAULT_CPU_OPERATOR_COST;
 
-int        effective_cache_size = DEFAULT_EFFECTIVE_CACHE_SIZE;
+int            effective_cache_size = DEFAULT_EFFECTIVE_CACHE_SIZE;
 
 Cost       disable_cost = 100000000.0;
 
@@ -276,13 +276,13 @@ cost_index(IndexPath *path, PlannerInfo *root,
    if (outer_rel != NULL && outer_rel->rows > 1)
    {
        /*
-        * For repeated indexscans, scale up the number of tuples fetched
-        * in the Mackert and Lohman formula by the number of scans, so
-        * that we estimate the number of pages fetched by all the scans.
-        * Then pro-rate the costs for one scan.  In this case we assume
-        * all the fetches are random accesses.  XXX it'd be good to
-        * include correlation in this model, but it's not clear how to do
-        * that without double-counting cache effects.
+        * For repeated indexscans, scale up the number of tuples fetched in
+        * the Mackert and Lohman formula by the number of scans, so that we
+        * estimate the number of pages fetched by all the scans. Then
+        * pro-rate the costs for one scan.  In this case we assume all the
+        * fetches are random accesses.  XXX it'd be good to include
+        * correlation in this model, but it's not clear how to do that
+        * without double-counting cache effects.
         */
        double      num_scans = outer_rel->rows;
 
@@ -385,7 +385,7 @@ cost_index(IndexPath *path, PlannerInfo *root,
  * computed for us by query_planner.
  *
  * Caller is expected to have ensured that tuples_fetched is greater than zero
- * and rounded to integer (see clamp_row_est).  The result will likewise be
+ * and rounded to integer (see clamp_row_est). The result will likewise be
  * greater than zero and integral.
  */
 double
@@ -406,7 +406,8 @@ index_pages_fetched(double tuples_fetched, BlockNumber pages,
    Assert(T <= total_pages);
 
    /* b is pro-rated share of effective_cache_size */
-   b = (double) effective_cache_size * T / total_pages;
+   b = (double) effective_cache_size *T / total_pages;
+
    /* force it positive and integral */
    if (b <= 1.0)
        b = 1.0;
@@ -543,10 +544,10 @@ cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
    if (outer_rel != NULL && outer_rel->rows > 1)
    {
        /*
-        * For repeated bitmap scans, scale up the number of tuples fetched
-        * in the Mackert and Lohman formula by the number of scans, so
-        * that we estimate the number of pages fetched by all the scans.
-        * Then pro-rate for one scan.
+        * For repeated bitmap scans, scale up the number of tuples fetched in
+        * the Mackert and Lohman formula by the number of scans, so that we
+        * estimate the number of pages fetched by all the scans. Then
+        * pro-rate for one scan.
         */
        double      num_scans = outer_rel->rows;
 
@@ -573,7 +574,7 @@ 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 seq_page_cost apiece.  The effect is nonlinear,
+    * appropriate to charge seq_page_cost apiece.  The effect is nonlinear,
     * too. For lack of a better idea, interpolate like this to determine the
     * cost per page.
     */
@@ -748,7 +749,7 @@ cost_tidscan(Path *path, PlannerInfo *root,
        {
            /* Each element of the array yields 1 tuple */
            ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) lfirst(l);
-           Node *arraynode = (Node *) lsecond(saop->args);
+           Node       *arraynode = (Node *) lsecond(saop->args);
 
            ntuples += estimate_array_length(arraynode);
        }
@@ -849,8 +850,8 @@ cost_valuesscan(Path *path, PlannerInfo *root, RelOptInfo *baserel)
    Assert(baserel->rtekind == RTE_VALUES);
 
    /*
-    * For now, estimate list evaluation cost at one operator eval per
-    * list (probably pretty bogus, but is it worth being smarter?)
+    * For now, estimate list evaluation cost at one operator eval per list
+    * (probably pretty bogus, but is it worth being smarter?)
     */
    cpu_per_tuple = cpu_operator_cost;
 
@@ -875,7 +876,7 @@ cost_valuesscan(Path *path, PlannerInfo *root, RelOptInfo *baserel)
  * If the total volume exceeds work_mem, we switch to a tape-style merge
  * algorithm.  There will still be about t*log2(t) tuple comparisons in
  * total, but we will also need to write and read each tuple once per
- * merge pass.  We expect about ceil(logM(r)) merge passes where r is the
+ * merge pass. We expect about ceil(logM(r)) merge passes where r is the
  * number of initial runs formed and M is the merge order used by tuplesort.c.
  * Since the average initial run should be about twice work_mem, we have
  *     disk traffic = 2 * relsize * ceil(logM(p / (2*work_mem)))
@@ -1745,7 +1746,7 @@ cost_qual_eval_walker(Node *node, QualCost *total)
         * array elements before the answer is determined.
         */
        ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) node;
-       Node *arraynode = (Node *) lsecond(saop->args);
+       Node       *arraynode = (Node *) lsecond(saop->args);
 
        total->per_tuple +=
            cpu_operator_cost * estimate_array_length(arraynode) * 0.5;
@@ -1967,7 +1968,7 @@ set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
     *
     * 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?)  (XXX this is not really right, because it
+    * of being even smarter?)  (XXX this is not really right, because it
     * assumes all the restriction clauses are join clauses; we should figure
     * pushed-down clauses separately.)
     *
@@ -2132,10 +2133,10 @@ set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel)
    Assert(rte->rtekind == RTE_VALUES);
 
    /*
-    * Estimate number of rows the values list will return.
-    * We know this precisely based on the list length (well,
-    * barring set-returning functions in list items, but that's
-    * a refinement not catered for anywhere else either).
+    * Estimate number of rows the values list will return. We know this
+    * precisely based on the list length (well, barring set-returning
+    * functions in list items, but that's a refinement not catered for
+    * anywhere else either).
     */
    rel->tuples = list_length(rte->values_lists);
 
index 7810012b2b05709165df8f782d4c4b6b71f42f4e..b15affa54d5a331ac34128e3982ea6feb1e60805 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.211 2006/07/22 15:41:55 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.212 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,10 +54,10 @@ static List *find_saop_paths(PlannerInfo *root, RelOptInfo *rel,
                List *clauses, List *outer_clauses,
                bool istoplevel, RelOptInfo *outer_rel);
 static Path *choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel,
-                              List *paths, RelOptInfo *outer_rel);
+                 List *paths, RelOptInfo *outer_rel);
 static int bitmap_path_comparator(const void *a, const void *b);
 static Cost bitmap_and_cost_est(PlannerInfo *root, RelOptInfo *rel,
-                               List *paths, RelOptInfo *outer_rel);
+                   List *paths, RelOptInfo *outer_rel);
 static List *pull_indexpath_quals(Path *bitmapqual);
 static bool lists_intersect_ptr(List *list1, List *list2);
 static bool match_clause_to_indexcol(IndexOptInfo *index,
@@ -66,7 +66,7 @@ static bool match_clause_to_indexcol(IndexOptInfo *index,
                         Relids outer_relids,
                         SaOpControl saop_control);
 static bool is_indexable_operator(Oid expr_op, Oid opclass,
-                                 bool indexkey_on_left);
+                     bool indexkey_on_left);
 static bool match_rowcompare_to_indexcol(IndexOptInfo *index,
                             int indexcol,
                             Oid opclass,
@@ -324,8 +324,8 @@ find_usable_indexes(PlannerInfo *root, RelOptInfo *rel,
        /*
         * 1. Match the index against the available restriction clauses.
         * found_clause is set true only if at least one of the current
-        * clauses was used (and, if saop_control is SAOP_REQUIRE, it
-        * has to have been a ScalarArrayOpExpr clause).
+        * clauses was used (and, if saop_control is SAOP_REQUIRE, it has to
+        * have been a ScalarArrayOpExpr clause).
         */
        restrictclauses = group_clauses_by_indexkey(index,
                                                    clauses,
@@ -422,8 +422,8 @@ find_saop_paths(PlannerInfo *root, RelOptInfo *rel,
    ListCell   *l;
 
    /*
-    * Since find_usable_indexes is relatively expensive, don't bother to
-    * run it unless there are some top-level ScalarArrayOpExpr clauses.
+    * Since find_usable_indexes is relatively expensive, don't bother to run
+    * it unless there are some top-level ScalarArrayOpExpr clauses.
     */
    foreach(l, clauses)
    {
@@ -588,15 +588,15 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel,
     * 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
+    * 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.  (Another
-    * way it can happen is that best_inner_indexscan will find the same OR
-    * join clauses that create_or_index_quals has pulled OR restriction
-    * clauses out of, and then both versions show up as duplicate paths.)  We
+    * can happen if there are multiple possibly usable indexes.  (Another way
+    * it can happen is that best_inner_indexscan will find the same OR join
+    * clauses that create_or_index_quals has pulled OR restriction clauses
+    * out of, and then both versions show up as duplicate paths.)  We
     * consider an index redundant if any of 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
@@ -796,7 +796,7 @@ lists_intersect_ptr(List *list1, List *list2)
 
    foreach(cell1, list1)
    {
-       void   *datum1 = lfirst(cell1);
+       void       *datum1 = lfirst(cell1);
        ListCell   *cell2;
 
        foreach(cell2, list2)
@@ -963,7 +963,7 @@ group_clauses_by_indexkey(IndexOptInfo *index,
  *   It is also possible to match RowCompareExpr clauses to indexes (but
  *   currently, only btree indexes handle this).  In this routine we will
  *   report a match if the first column of the row comparison matches the
- *   target index column.  This is sufficient to guarantee that some index
+ *   target index column.  This is sufficient to guarantee that some index
  *   condition can be constructed from the RowCompareExpr --- whether the
  *   remaining columns match the index too is considered in
  *   expand_indexqual_rowcompare().
@@ -1004,10 +1004,10 @@ match_clause_to_indexcol(IndexOptInfo *index,
    bool        plain_op;
 
    /*
-    * Never match pseudoconstants to indexes.  (Normally this could not
-    * happen anyway, since a pseudoconstant clause couldn't contain a
-    * Var, but what if someone builds an expression index on a constant?
-    * It's not totally unreasonable to do so with a partial index, either.)
+    * Never match pseudoconstants to indexes.  (Normally this could not
+    * happen anyway, since a pseudoconstant clause couldn't contain a Var,
+    * but what if someone builds an expression index on a constant? It's not
+    * totally unreasonable to do so with a partial index, either.)
     */
    if (rinfo->pseudoconstant)
        return false;
@@ -1421,9 +1421,9 @@ best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel,
     * NOTE: because we cache on outer_relids rather than outer_rel->relids,
     * we will report the same path and hence path cost for joins with
     * different sets of irrelevant rels on the outside.  Now that cost_index
-    * is sensitive to outer_rel->rows, this is not really right.  However
-    * the error is probably not large.  Is it worth establishing a separate
-    * cache entry for each distinct outer_rel->relids set to get this right?
+    * is sensitive to outer_rel->rows, this is not really right.  However the
+    * error is probably not large.  Is it worth establishing a separate cache
+    * entry for each distinct outer_rel->relids set to get this right?
     */
    foreach(l, rel->index_inner_paths)
    {
@@ -1442,11 +1442,11 @@ best_inner_indexscan(PlannerInfo *root, RelOptInfo *rel,
     *
     * Note: because we include restriction clauses, we will find indexscans
     * that could be plain indexscans, ie, they don't require the join context
-    * at all.  This may seem redundant, but we need to include those scans in
+    * at all.  This may seem redundant, but we need to include those scans in
     * the input given to choose_bitmap_and() to be sure we find optimal AND
-    * combinations of join and non-join scans.  Also, even if the "best
-    * inner indexscan" is just a plain indexscan, it will have a different
-    * cost estimate because of cache effects.
+    * combinations of join and non-join scans.  Also, even if the "best inner
+    * indexscan" is just a plain indexscan, it will have a different cost
+    * estimate because of cache effects.
     */
    clause_list = find_clauses_for_join(root, rel, outer_relids, isouterjoin);
 
@@ -2210,7 +2210,7 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
        foreach(l, (List *) lfirst(clausegroup_item))
        {
            RestrictInfo *rinfo = (RestrictInfo *) lfirst(l);
-           Expr   *clause = rinfo->clause;
+           Expr       *clause = rinfo->clause;
 
            /* First check for boolean cases */
            if (IsBooleanOpclass(curClass))
@@ -2240,7 +2240,7 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
            {
                resultquals = list_concat(resultquals,
                                          expand_indexqual_opclause(rinfo,
-                                                                   curClass));
+                                                                 curClass));
            }
            else if (IsA(clause, ScalarArrayOpExpr))
            {
@@ -2340,6 +2340,7 @@ static List *
 expand_indexqual_opclause(RestrictInfo *rinfo, Oid opclass)
 {
    Expr       *clause = rinfo->clause;
+
    /* we know these will succeed */
    Node       *leftop = get_leftop(clause);
    Node       *rightop = get_rightop(clause);
@@ -2421,7 +2422,7 @@ expand_indexqual_opclause(RestrictInfo *rinfo, Oid opclass)
  * column matches) or a simple OpExpr (if the first-column match is all
  * there is).  In these cases the modified clause is always "<=" or ">="
  * even when the original was "<" or ">" --- this is necessary to match all
- * the rows that could match the original.  (We are essentially building a
+ * the rows that could match the original. (We are essentially building a
  * lossy version of the row comparison when we do this.)
  */
 static RestrictInfo *
@@ -2430,18 +2431,18 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
                            int indexcol)
 {
    RowCompareExpr *clause = (RowCompareExpr *) rinfo->clause;
-   bool    var_on_left;
-   int     op_strategy;
-   Oid     op_subtype;
-   bool    op_recheck;
-   int     matching_cols;
-   Oid     expr_op;
-   List   *opclasses;
-   List   *subtypes;
-   List   *new_ops;
-   ListCell *largs_cell;
-   ListCell *rargs_cell;
-   ListCell *opnos_cell;
+   bool        var_on_left;
+   int         op_strategy;
+   Oid         op_subtype;
+   bool        op_recheck;
+   int         matching_cols;
+   Oid         expr_op;
+   List       *opclasses;
+   List       *subtypes;
+   List       *new_ops;
+   ListCell   *largs_cell;
+   ListCell   *rargs_cell;
+   ListCell   *opnos_cell;
 
    /* We have to figure out (again) how the first col matches */
    var_on_left = match_index_to_operand((Node *) linitial(clause->largs),
@@ -2459,12 +2460,12 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
    subtypes = list_make1_oid(op_subtype);
 
    /*
-    * See how many of the remaining columns match some index column
-    * in the same way.  A note about rel membership tests: we assume
-    * that the clause as a whole is already known to use only Vars from
-    * the indexed relation and possibly some acceptable outer relations.
-    * So the "other" side of any potential index condition is OK as long
-    * as it doesn't use Vars from the indexed relation.
+    * See how many of the remaining columns match some index column in the
+    * same way.  A note about rel membership tests: we assume that the clause
+    * as a whole is already known to use only Vars from the indexed relation
+    * and possibly some acceptable outer relations. So the "other" side of
+    * any potential index condition is OK as long as it doesn't use Vars from
+    * the indexed relation.
     */
    matching_cols = 1;
    largs_cell = lnext(list_head(clause->largs));
@@ -2498,10 +2499,10 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
            break;              /* no good, volatile comparison value */
 
        /*
-        * The Var side can match any column of the index.  If the user
-        * does something weird like having multiple identical index
-        * columns, we insist the match be on the first such column,
-        * to avoid confusing the executor.
+        * The Var side can match any column of the index.  If the user does
+        * something weird like having multiple identical index columns, we
+        * insist the match be on the first such column, to avoid confusing
+        * the executor.
         */
        for (i = 0; i < index->ncolumns; i++)
        {
@@ -2534,9 +2535,9 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
        return rinfo;
 
    /*
-    * We have to generate a subset rowcompare (possibly just one OpExpr).
-    * The painful part of this is changing < to <= or > to >=, so deal with
-    * that first.
+    * We have to generate a subset rowcompare (possibly just one OpExpr). The
+    * painful part of this is changing < to <= or > to >=, so deal with that
+    * first.
     */
    if (op_strategy == BTLessEqualStrategyNumber ||
        op_strategy == BTGreaterEqualStrategyNumber)
@@ -2546,8 +2547,8 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
    }
    else
    {
-       ListCell *opclasses_cell;
-       ListCell *subtypes_cell;
+       ListCell   *opclasses_cell;
+       ListCell   *subtypes_cell;
 
        if (op_strategy == BTLessStrategyNumber)
            op_strategy = BTLessEqualStrategyNumber;
@@ -2561,13 +2562,13 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
            expr_op = get_opclass_member(lfirst_oid(opclasses_cell),
                                         lfirst_oid(subtypes_cell),
                                         op_strategy);
-           if (!OidIsValid(expr_op))               /* should not happen */
+           if (!OidIsValid(expr_op))   /* should not happen */
                elog(ERROR, "could not find member %d of opclass %u",
                     op_strategy, lfirst_oid(opclasses_cell));
            if (!var_on_left)
            {
                expr_op = get_commutator(expr_op);
-               if (!OidIsValid(expr_op))           /* should not happen */
+               if (!OidIsValid(expr_op))       /* should not happen */
                    elog(ERROR, "could not find commutator of member %d of opclass %u",
                         op_strategy, lfirst_oid(opclasses_cell));
            }
@@ -2596,7 +2597,7 @@ expand_indexqual_rowcompare(RestrictInfo *rinfo,
    }
    else
    {
-       Expr *opexpr;
+       Expr       *opexpr;
 
        opexpr = make_opclause(linitial_oid(new_ops), BOOLOID, false,
                               copyObject(linitial(clause->largs)),
index f5e9b1e987e189c90ad18bc376d0493c79283075..6882439ca3a4b656069f12f9f667a708c0e8cbb6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.106 2006/08/17 17:06:37 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.107 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,7 +33,7 @@ static void hash_inner_and_outer(PlannerInfo *root, RelOptInfo *joinrel,
                     RelOptInfo *outerrel, RelOptInfo *innerrel,
                     List *restrictlist, JoinType jointype);
 static Path *best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
-                                    RelOptInfo *outer_rel, JoinType jointype);
+                        RelOptInfo *outer_rel, JoinType jointype);
 static List *select_mergejoin_clauses(RelOptInfo *joinrel,
                         RelOptInfo *outerrel,
                         RelOptInfo *innerrel,
@@ -544,9 +544,9 @@ match_unsorted_outer(PlannerInfo *root,
         * mergejoin using a subset of the merge clauses.  Here, we consider
         * both cheap startup cost and cheap total cost.  We can ignore
         * inner_cheapest_total on the first iteration, since we already made
-        * a path with it --- but not on later iterations with shorter
-        * sort keys, because then we are considering a different situation,
-        * viz using a simpler mergejoin to avoid a sort of the inner rel.
+        * a path with it --- but not on later iterations with shorter sort
+        * keys, because then we are considering a different situation, viz
+        * using a simpler mergejoin to avoid a sort of the inner rel.
         */
        num_sortkeys = list_length(innersortkeys);
        if (num_sortkeys > 1 && !useallclauses)
@@ -792,7 +792,7 @@ hash_inner_and_outer(PlannerInfo *root,
  * best_appendrel_indexscan
  *   Finds the best available set of inner indexscans for a nestloop join
  *   with the given append relation on the inside and the given outer_rel
- *   outside.  Returns an AppendPath comprising the best inner scans, or
+ *   outside.  Returns an AppendPath comprising the best inner scans, or
  *   NULL if there are no possible inner indexscans.
  */
 static Path *
@@ -820,9 +820,9 @@ best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
        Assert(childrel->reloptkind == RELOPT_OTHER_MEMBER_REL);
 
        /*
-        * Check to see if child was rejected by constraint exclusion.
-        * If so, it will have a cheapest_total_path that's an Append path
-        * with no members (see set_plain_rel_pathlist).
+        * Check to see if child was rejected by constraint exclusion. If so,
+        * it will have a cheapest_total_path that's an Append path with no
+        * members (see set_plain_rel_pathlist).
         */
        if (IsA(childrel->cheapest_total_path, AppendPath) &&
            ((AppendPath *) childrel->cheapest_total_path)->subpaths == NIL)
@@ -835,10 +835,10 @@ best_appendrel_indexscan(PlannerInfo *root, RelOptInfo *rel,
                                             outer_rel, jointype);
 
        /*
-        * If no luck on an indexpath for this rel, we'll still consider
-        * an Append substituting the cheapest-total inner path.  However
-        * we must find at least one indexpath, else there's not going to
-        * be any improvement over the base path for the appendrel.
+        * If no luck on an indexpath for this rel, we'll still consider an
+        * Append substituting the cheapest-total inner path.  However we must
+        * find at least one indexpath, else there's not going to be any
+        * improvement over the base path for the appendrel.
         */
        if (bestinnerjoin)
            found_indexscan = true;
index ac12bbd5f73d4f1b90258b5be2ff8bce397b8dc6..bed9db50430e1bcdb0f935ba25b827a12eb19ec0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.79 2006/03/05 15:58:28 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.80 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -87,11 +87,11 @@ make_rels_by_joins(PlannerInfo *root, int level, List **joinrels)
 
            /*
             * An exception occurs when there is a clauseless join inside a
-            * construct that restricts join order, i.e., an outer join RHS
-            * or an IN (sub-SELECT) construct.  Here, the rel may well have
-            * join clauses against stuff outside the OJ RHS or IN sub-SELECT,
-            * but the clauseless join *must* be done before we can make use
-            * of those join clauses.   So do the clauseless join bit.
+            * construct that restricts join order, i.e., an outer join RHS or
+            * an IN (sub-SELECT) construct.  Here, the rel may well have join
+            * clauses against stuff outside the OJ RHS or IN sub-SELECT, but
+            * the clauseless join *must* be done before we can make use of
+            * those join clauses.   So do the clauseless join bit.
             *
             * See also the last-ditch case below.
             */
@@ -386,9 +386,9 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
    joinrelids = bms_union(rel1->relids, rel2->relids);
 
    /*
-    * If we have any outer joins, the proposed join might be illegal; and
-    * in any case we have to determine its join type.  Scan the OJ list
-    * for conflicts.
+    * If we have any outer joins, the proposed join might be illegal; and in
+    * any case we have to determine its join type.  Scan the OJ list for
+    * conflicts.
     */
    jointype = JOIN_INNER;      /* default if no match to an OJ */
    is_valid_inner = true;
@@ -485,16 +485,16 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
        InClauseInfo *ininfo = (InClauseInfo *) lfirst(l);
 
        /*
-        * 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.)
+        * 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.)
         */
        if (!bms_overlap(ininfo->righthand, joinrelids))
            continue;
 
        /*
-        * If we are still building the IN clause's RHS, then this IN
-        * clause isn't relevant yet.
+        * If we are still building the IN clause's RHS, then this IN clause
+        * isn't relevant yet.
         */
        if (bms_is_subset(joinrelids, ininfo->righthand))
            continue;
index 0e602a4476d12c706e1eebc298f27e117a742a99..56142535c131a398efa3dd1ca473b30badde9831 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.80 2006/07/14 14:52:20 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.81 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -106,8 +106,8 @@ create_or_index_quals(PlannerInfo *root, RelOptInfo *rel)
             * 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_rel = NULL so that sub-clauses
-            * that are actually joins will be ignored.
+            * indexquals.  We pass outer_rel = NULL so that sub-clauses that
+            * are actually joins will be ignored.
             */
            List       *orpaths;
            ListCell   *k;
index fb5d38255db8dc26534c49bc47085cf929c87c28..b254598fcf34a92996a0c498637812186836d6f6 100644 (file)
@@ -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.78 2006/08/17 17:02:49 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.79 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -909,7 +909,7 @@ get_cheapest_fractional_path_for_pathkeys(List *paths,
  * representing a backwards scan of the index. Return NIL if can't do it.
  *
  * If 'canonical' is TRUE, we remove duplicate pathkeys (which can occur
- * if two index columns are equijoined, eg WHERE x = 1 AND y = 1).  This
+ * if two index columns are equijoined, eg WHERE x = 1 AND y = 1). This
  * is required if the result is to be compared directly to a canonical query
  * pathkeys list.  However, some callers want a list with exactly one entry
  * per index column, and they must pass FALSE.
@@ -1106,8 +1106,8 @@ convert_subquery_pathkeys(PlannerInfo *root, RelOptInfo *rel,
                    outer_expr = (Node *)
                        makeRelabelType((Expr *) outer_expr,
                                        ((RelabelType *) sub_key)->resulttype,
-                                       ((RelabelType *) sub_key)->resulttypmod,
-                                       ((RelabelType *) sub_key)->relabelformat);
+                                    ((RelabelType *) sub_key)->resulttypmod,
+                                  ((RelabelType *) sub_key)->relabelformat);
                }
                else
                    continue;
index a912994987a6fa238a45cd7930cb3682abf76aca..a7dd5b262daf0a9c9d195f5598f1fac8893f59e0 100644 (file)
@@ -24,7 +24,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.27 2006/03/05 15:58:28 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/path/tidpath.c,v 1.28 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,7 +125,7 @@ IsTidEqualAnyClause(ScalarArrayOpExpr *node, int varno)
    /* CTID must be first argument */
    if (arg1 && IsA(arg1, Var))
    {
-       Var    *var = (Var *) arg1;
+       Var        *var = (Var *) arg1;
 
        if (var->varattno == SelfItemPointerAttributeNumber &&
            var->vartype == TIDOID &&
@@ -187,7 +187,7 @@ TidQualFromExpr(Node *expr, int varno)
    {
        foreach(l, ((BoolExpr *) expr)->args)
        {
-           List   *frtn = TidQualFromExpr((Node *) lfirst(l), varno);
+           List       *frtn = TidQualFromExpr((Node *) lfirst(l), varno);
 
            if (frtn)
                rlst = list_concat(rlst, frtn);
index ae51505954f1f796d2749a8de36957601e69be47..14f1f1a10f4e2071a9db39ec0138657ee054f555 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.216 2006/08/02 01:59:45 joe Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.217 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -60,7 +60,7 @@ static SubqueryScan *create_subqueryscan_plan(PlannerInfo *root, Path *best_path
 static FunctionScan *create_functionscan_plan(PlannerInfo *root, Path *best_path,
                         List *tlist, List *scan_clauses);
 static ValuesScan *create_valuesscan_plan(PlannerInfo *root, Path *best_path,
-                        List *tlist, List *scan_clauses);
+                      List *tlist, List *scan_clauses);
 static NestLoop *create_nestloop_plan(PlannerInfo *root, NestPath *best_path,
                     Plan *outer_plan, Plan *inner_plan);
 static MergeJoin *create_mergejoin_plan(PlannerInfo *root, MergePath *best_path,
@@ -98,7 +98,7 @@ static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid,
 static FunctionScan *make_functionscan(List *qptlist, List *qpqual,
                  Index scanrelid);
 static ValuesScan *make_valuesscan(List *qptlist, List *qpqual,
-                 Index scanrelid);
+               Index scanrelid);
 static BitmapAnd *make_bitmap_and(List *bitmapplans);
 static BitmapOr *make_bitmap_or(List *bitmapplans);
 static NestLoop *make_nestloop(List *tlist,
@@ -216,9 +216,9 @@ 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,
-    * except for pseudoconstants which we'll take care of below.
+    * Extract the relevant restriction clauses from the parent relation. The
+    * executor must apply all these restrictions during the scan, except for
+    * pseudoconstants which we'll take care of below.
     */
    scan_clauses = rel->baserestrictinfo;
 
@@ -282,9 +282,9 @@ create_scan_plan(PlannerInfo *root, Path *best_path)
    }
 
    /*
-    * If there are any pseudoconstant clauses attached to this node,
-    * insert a gating Result node that evaluates the pseudoconstants
-    * as one-time quals.
+    * If there are any pseudoconstant clauses attached to this node, insert a
+    * gating Result node that evaluates the pseudoconstants as one-time
+    * quals.
     */
    if (root->hasPseudoConstantQuals)
        plan = create_gating_plan(root, plan, scan_clauses);
@@ -327,8 +327,8 @@ use_physical_tlist(RelOptInfo *rel)
    int         i;
 
    /*
-    * We can do this for real relation scans, subquery scans, function
-    * scans, and values scans (but not for, eg, joins).
+    * We can do this for real relation scans, subquery scans, function scans,
+    * and values scans (but not for, eg, joins).
     */
    if (rel->rtekind != RTE_RELATION &&
        rel->rtekind != RTE_SUBQUERY &&
@@ -466,9 +466,9 @@ create_join_plan(PlannerInfo *root, JoinPath *best_path)
    }
 
    /*
-    * If there are any pseudoconstant clauses attached to this node,
-    * insert a gating Result node that evaluates the pseudoconstants
-    * as one-time quals.
+    * If there are any pseudoconstant clauses attached to this node, insert a
+    * gating Result node that evaluates the pseudoconstants as one-time
+    * quals.
     */
    if (root->hasPseudoConstantQuals)
        plan = create_gating_plan(root, plan, best_path->joinrestrictinfo);
@@ -991,9 +991,9 @@ create_bitmap_scan_plan(PlannerInfo *root,
     *
     * Unlike create_indexscan_plan(), we need take no special thought here
     * for partial index predicates; this is because the predicate conditions
-    * are already listed in bitmapqualorig and indexquals.  Bitmap scans
-    * have to do it that way because predicate conditions need to be rechecked
-    * if the scan becomes lossy.
+    * are already listed in bitmapqualorig and indexquals.  Bitmap scans have
+    * to do it that way because predicate conditions need to be rechecked if
+    * the scan becomes lossy.
     */
    qpqual = NIL;
    foreach(l, scan_clauses)
@@ -1137,6 +1137,7 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
                subindexquals = lappend(subindexquals,
                                        make_ands_explicit(subindexqual));
        }
+
        /*
         * In the presence of ScalarArrayOpExpr quals, we might have built
         * BitmapOrPaths with just one subpath; don't add an OR step.
@@ -1152,7 +1153,7 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
            plan->total_cost = opath->path.total_cost;
            plan->plan_rows =
                clamp_row_est(opath->bitmapselectivity * opath->path.parent->tuples);
-           plan->plan_width = 0;   /* meaningless */
+           plan->plan_width = 0;       /* meaningless */
        }
 
        /*
@@ -1202,10 +1203,10 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
            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), ipath->indexclauses))
            {
@@ -1244,8 +1245,8 @@ create_tidscan_plan(PlannerInfo *root, TidPath *best_path,
    scan_clauses = extract_actual_clauses(scan_clauses, false);
 
    /*
-    * Remove any clauses that are TID quals.  This is a bit tricky since
-    * the tidquals list has implicit OR semantics.
+    * Remove any clauses that are TID quals.  This is a bit tricky since the
+    * tidquals list has implicit OR semantics.
     */
    ortidquals = best_path->tidquals;
    if (list_length(ortidquals) > 1)
@@ -1333,7 +1334,7 @@ create_functionscan_plan(PlannerInfo *root, Path *best_path,
  */
 static ValuesScan *
 create_valuesscan_plan(PlannerInfo *root, Path *best_path,
-                        List *tlist, List *scan_clauses)
+                      List *tlist, List *scan_clauses)
 {
    ValuesScan *scan_plan;
    Index       scan_relid = best_path->parent->relid;
@@ -1411,9 +1412,9 @@ create_nestloop_plan(PlannerInfo *root,
         * 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 duplication.  (Also, to change this we'd have to be
-        * wary of UPDATE/DELETE/SELECT FOR UPDATE target relations; see
-        * notes above about EvalPlanQual.)
+        * to detect duplication.  (Also, to change this we'd have to be wary
+        * of UPDATE/DELETE/SELECT FOR UPDATE target relations; see notes
+        * above about EvalPlanQual.)
         */
        BitmapHeapPath *innerpath = (BitmapHeapPath *) best_path->innerjoinpath;
 
@@ -1693,7 +1694,7 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path,
 
        if (IsA(clause, OpExpr))
        {
-           OpExpr *op = (OpExpr *) clause;
+           OpExpr     *op = (OpExpr *) clause;
 
            if (list_length(op->args) != 2)
                elog(ERROR, "indexqual clause is not binary opclause");
@@ -1718,7 +1719,7 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path,
        else if (IsA(clause, RowCompareExpr))
        {
            RowCompareExpr *rc = (RowCompareExpr *) clause;
-           ListCell *lc;
+           ListCell   *lc;
 
            /*
             * Check to see if the indexkey is on the right; if so, commute
@@ -1734,13 +1735,13 @@ fix_indexqual_references(List *indexquals, IndexPath *index_path,
             * attribute this is and change the indexkey operand as needed.
             *
             * Save the index opclass for only the first column.  We will
-            * return the operator and opclass info for just the first
-            * column of the row comparison; the executor will have to
-            * look up the rest if it needs them.
+            * return the operator and opclass info for just the first column
+            * of the row comparison; the executor will have to look up the
+            * rest if it needs them.
             */
            foreach(lc, rc->largs)
            {
-               Oid     tmp_opclass;
+               Oid         tmp_opclass;
 
                lfirst(lc) = fix_indexqual_operand(lfirst(lc),
                                                   index,
index 8299f6756b8587fb652c0b12d89f21ff2031959a..2a8e1f528e9857a7105e74f8515fed66a48f64cb 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.122 2006/09/19 22:49:52 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.123 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,10 +40,10 @@ int         join_collapse_limit;
 static void add_vars_to_targetlist(PlannerInfo *root, List *vars,
                       Relids where_needed);
 static List *deconstruct_recurse(PlannerInfo *root, Node *jtnode,
-                                bool below_outer_join, Relids *qualscope);
+                   bool below_outer_join, Relids *qualscope);
 static OuterJoinInfo *make_outerjoininfo(PlannerInfo *root,
-                                        Relids left_rels, Relids right_rels,
-                                        bool is_full_join, Node *clause);
+                  Relids left_rels, Relids right_rels,
+                  bool is_full_join, Node *clause);
 static void distribute_qual_to_rels(PlannerInfo *root, Node *clause,
                        bool is_pushed_down,
                        bool is_deduced,
@@ -71,12 +71,12 @@ static void check_hashjoinable(RestrictInfo *restrictinfo);
  *   appearing in the jointree.
  *
  * The initial invocation must pass root->parse->jointree as the value of
- * jtnode.  Internally, the function recurses through the jointree.
+ * jtnode. Internally, the function recurses through the jointree.
  *
  * At the end of this process, there should be one baserel RelOptInfo for
  * every non-join RTE that is used in the query.  Therefore, this routine
  * is the only place that should call build_simple_rel with reloptkind
- * RELOPT_BASEREL.  (Note: build_simple_rel recurses internally to build
+ * RELOPT_BASEREL. (Note: build_simple_rel recurses internally to build
  * "other rel" RelOptInfos for the members of any appendrels we find here.)
  */
 void
@@ -181,7 +181,7 @@ add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed)
  * deconstruct_jointree
  *   Recursively scan the query's join tree for WHERE and JOIN/ON qual
  *   clauses, and add these to the appropriate restrictinfo and joininfo
- *   lists belonging to base RelOptInfos.  Also, add OuterJoinInfo nodes
+ *   lists belonging to base RelOptInfos.  Also, add OuterJoinInfo nodes
  *   to root->oj_info_list for any outer joins appearing in the query tree.
  *   Return a "joinlist" data structure showing the join order decisions
  *   that need to be made by make_one_rel().
@@ -198,9 +198,9 @@ add_vars_to_targetlist(PlannerInfo *root, List *vars, Relids where_needed)
  * be evaluated at the lowest level where all the variables it mentions are
  * available.  However, we cannot push a qual down into the nullable side(s)
  * of an outer join since the qual might eliminate matching rows and cause a
- * NULL row to be incorrectly emitted by the join.  Therefore, we artificially
+ * NULL row to be incorrectly emitted by the join. Therefore, we artificially
  * OR the minimum-relids of such an outer join into the required_relids of
- * clauses appearing above it.  This forces those clauses to be delayed until
+ * clauses appearing above it. This forces those clauses to be delayed until
  * application of the outer join (or maybe even higher in the join tree).
  */
 List *
@@ -258,20 +258,19 @@ deconstruct_recurse(PlannerInfo *root, Node *jtnode, bool below_outer_join,
        ListCell   *l;
 
        /*
-        * First, recurse to handle child joins.  We collapse subproblems
-        * into a single joinlist whenever the resulting joinlist wouldn't
-        * exceed from_collapse_limit members.  Also, always collapse
-        * one-element subproblems, since that won't lengthen the joinlist
-        * anyway.
+        * First, recurse to handle child joins.  We collapse subproblems into
+        * a single joinlist whenever the resulting joinlist wouldn't exceed
+        * from_collapse_limit members.  Also, always collapse one-element
+        * subproblems, since that won't lengthen the joinlist anyway.
         */
        *qualscope = NULL;
        joinlist = NIL;
        remaining = list_length(f->fromlist);
        foreach(l, f->fromlist)
        {
-           Relids  sub_qualscope;
-           List   *sub_joinlist;
-           int     sub_members;
+           Relids      sub_qualscope;
+           List       *sub_joinlist;
+           int         sub_members;
 
            sub_joinlist = deconstruct_recurse(root, lfirst(l),
                                               below_outer_join,
@@ -407,7 +406,8 @@ deconstruct_recurse(PlannerInfo *root, Node *jtnode, bool below_outer_join,
            (list_length(leftjoinlist) + list_length(rightjoinlist) <=
             join_collapse_limit))
            joinlist = list_concat(leftjoinlist, rightjoinlist);
-       else                    /* force the join order at this node */
+       else
+           /* force the join order at this node */
            joinlist = list_make1(list_make2(leftjoinlist, rightjoinlist));
    }
    else
@@ -454,9 +454,9 @@ make_outerjoininfo(PlannerInfo *root,
     * any nullable rel is FOR UPDATE/SHARE.
     *
     * You might be wondering why this test isn't made far upstream in the
-    * parser.  It's because the parser hasn't got enough info --- consider
-    * FOR UPDATE applied to a view.  Only after rewriting and flattening
-    * do we know whether the view contains an outer join.
+    * parser.  It's because the parser hasn't got enough info --- consider
+    * FOR UPDATE applied to a view.  Only after rewriting and flattening do
+    * we know whether the view contains an outer join.
     */
    foreach(l, root->parse->rowMarks)
    {
@@ -475,7 +475,7 @@ make_outerjoininfo(PlannerInfo *root,
    {
        ojinfo->min_lefthand = left_rels;
        ojinfo->min_righthand = right_rels;
-       ojinfo->lhs_strict = false;         /* don't care about this */
+       ojinfo->lhs_strict = false;     /* don't care about this */
        return ojinfo;
    }
 
@@ -494,19 +494,19 @@ make_outerjoininfo(PlannerInfo *root,
    ojinfo->lhs_strict = bms_overlap(strict_relids, left_rels);
 
    /*
-    * Required LHS is basically the LHS rels mentioned in the clause...
-    * but if there aren't any, punt and make it the full LHS, to avoid
-    * having an empty min_lefthand which will confuse later processing.
-    * (We don't try to be smart about such cases, just correct.)
-    * We may have to add more rels based on lower outer joins; see below.
+    * Required LHS is basically the LHS rels mentioned in the clause... but
+    * if there aren't any, punt and make it the full LHS, to avoid having an
+    * empty min_lefthand which will confuse later processing. (We don't try
+    * to be smart about such cases, just correct.) We may have to add more
+    * rels based on lower outer joins; see below.
     */
    ojinfo->min_lefthand = bms_intersect(clause_relids, left_rels);
    if (bms_is_empty(ojinfo->min_lefthand))
        ojinfo->min_lefthand = bms_copy(left_rels);
 
    /*
-    * Required RHS is normally the full set of RHS rels.  Sometimes we
-    * can exclude some, see below.
+    * Required RHS is normally the full set of RHS rels.  Sometimes we can
+    * exclude some, see below.
     */
    ojinfo->min_righthand = bms_copy(right_rels);
 
@@ -532,6 +532,7 @@ make_outerjoininfo(PlannerInfo *root,
            ojinfo->min_lefthand = bms_add_members(ojinfo->min_lefthand,
                                                   otherinfo->min_righthand);
        }
+
        /*
         * For a lower OJ in our RHS, if our join condition does not use the
         * lower join's RHS and the lower OJ's join condition is strict, we
@@ -630,23 +631,23 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause,
     * If the clause is an outer-join clause, we must force it to the OJ's
     * semantic level to preserve semantics.
     *
-    * Otherwise, when the clause contains volatile functions, we force it
-    * to be evaluated at its original syntactic level.  This preserves the
+    * Otherwise, when the clause contains volatile functions, we force it to
+    * be evaluated at its original syntactic level.  This preserves the
     * expected semantics.
     *
-    * When the clause contains no volatile functions either, it is actually
-    * pseudoconstant clause that will not change value during any one
-    * execution of the plan, and hence can be used as a one-time qual in
-    * gating Result plan node.  We put such a clause into the regular
+    * When the clause contains no volatile functions either, it is actually a
+    * pseudoconstant clause that will not change value during any one
+    * execution of the plan, and hence can be used as a one-time qual in a
+    * gating Result plan node.  We put such a clause into the regular
     * RestrictInfo lists for the moment, but eventually createplan.c will
     * pull it out and make a gating Result node immediately above whatever
-    * plan node the pseudoconstant clause is assigned to.  It's usually
-    * best to put a gating node as high in the plan tree as possible.
-    * If we are not below an outer join, we can actually push the
-    * pseudoconstant qual all the way to the top of the tree.  If we are
-    * below an outer join, we leave the qual at its original syntactic level
-    * (we could push it up to just below the outer join, but that seems more
-    * complex than it's worth).
+    * plan node the pseudoconstant clause is assigned to.  It's usually best
+    * to put a gating node as high in the plan tree as possible. If we are
+    * not below an outer join, we can actually push the pseudoconstant qual
+    * all the way to the top of the tree.  If we are below an outer join, we
+    * leave the qual at its original syntactic level (we could push it up to
+    * just below the outer join, but that seems more complex than it's
+    * worth).
     */
    if (bms_is_empty(relids))
    {
@@ -793,8 +794,8 @@ 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".
-    * Note that for an outer-join qual, we have to compare to ojscope not
+    * A qual originating from WHERE is always considered "pushed down". Note
+    * that for an outer-join qual, we have to compare to ojscope not
     * qualscope.
     */
    if (!is_pushed_down)
index 2baf8e391d636b6c047edbdfc06597bc8ea0da01..e64340ed21c1122b1470302f246649d62d1d77f4 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.21 2006/08/12 02:52:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/planagg.c,v 1.22 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -217,7 +217,7 @@ find_minmax_aggs_walker(Node *node, List **context)
    {
        Aggref     *aggref = (Aggref *) node;
        Oid         aggsortop;
-       Expr        *curTarget;
+       Expr       *curTarget;
        MinMaxAggInfo *info;
        ListCell   *l;
 
@@ -464,7 +464,7 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info)
    subparse->limitOffset = NULL;
    subparse->limitCount = (Node *) makeConst(INT8OID, sizeof(int64),
                                              Int64GetDatum(1),
-                                             false, false /* not by val */);
+                                             false, false /* not by val */ );
 
    /*
     * Generate the plan for the subquery.  We already have a Path for the
@@ -478,9 +478,9 @@ make_agg_subplan(PlannerInfo *root, MinMaxAggInfo *info)
     * in our cost estimates.  But that looks painful, and in most cases the
     * fraction of NULLs isn't high enough to change the decision.
     *
-    * The NOT NULL qual has to go on the actual indexscan; create_plan
-    * might have stuck a gating Result atop that, if there were any
-    * pseudoconstant quals.
+    * The NOT NULL qual has to go on the actual indexscan; create_plan might
+    * have stuck a gating Result atop that, if there were any pseudoconstant
+    * quals.
     */
    plan = create_plan(&subroot, (Path *) info->path);
 
index ae44e2bc35ceef00a1846f7b6c6c61b84d2b2d7e..e01379e8e3f528ad2c2d181b5184ae4f63b58639 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/plan/planmain.c,v 1.96 2006/09/19 22:49:52 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/planmain.c,v 1.97 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -126,8 +126,8 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction,
    /*
     * Construct RelOptInfo nodes for all base relations in query, and
     * indirectly for all appendrel member relations ("other rels").  This
-    * will give us a RelOptInfo for every "simple" (non-join) rel involved
-    * in the query.
+    * will give us a RelOptInfo for every "simple" (non-join) rel involved in
+    * the query.
     *
     * Note: the reason we find the rels by searching the jointree and
     * appendrel list, rather than just scanning the rangetable, is that the
@@ -137,11 +137,11 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction,
    add_base_rels_to_query(root, (Node *) parse->jointree);
 
    /*
-    * We should now have size estimates for every actual table involved
-    * in the query, so we can compute total_table_pages.  Note that
-    * appendrels are not double-counted here, even though we don't bother
-    * to distinguish RelOptInfos for appendrel parents, because the parents
-    * will still have size zero.
+    * We should now have size estimates for every actual table involved in
+    * the query, so we can compute total_table_pages.  Note that appendrels
+    * are not double-counted here, even though we don't bother to distinguish
+    * RelOptInfos for appendrel parents, because the parents will still have
+    * size zero.
     *
     * XXX if a table is self-joined, we will count it once per appearance,
     * which perhaps is the wrong thing ... but that's not completely clear,
@@ -155,7 +155,7 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction,
        if (brel == NULL)
            continue;
 
-       Assert(brel->relid == rti); /* sanity check on array */
+       Assert(brel->relid == rti);     /* sanity check on array */
 
        total_pages += (double) brel->pages;
    }
@@ -165,8 +165,8 @@ query_planner(PlannerInfo *root, List *tlist, double tuple_fraction,
     * 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, and
-    * form a target joinlist for make_one_rel() to work from.
+    * also build lists of equijoined keys for pathkey construction, and form
+    * a target joinlist for make_one_rel() to work from.
     *
     * Note: all subplan nodes will have "flat" (var-only) tlists. This
     * implies that all expression evaluations are done at the root of the
index f8eb95baf43a5f2482bf76854901ebab84f90c1f..da18bc5a6f5a2aec0886a583e1d91f026fcf9a13 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.208 2006/08/12 02:52:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.209 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -427,9 +427,9 @@ 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.
-    * We can skip it in VALUES lists, however, since they can't contain
-    * any Vars at all.
+    * else sublinks expanded out from join aliases wouldn't get processed. We
+    * can skip it in VALUES lists, however, since they can't contain any Vars
+    * at all.
     */
    if (root->hasJoinRTEs && kind != EXPRKIND_VALUES)
        expr = flatten_join_alias_vars(root, expr);
@@ -450,8 +450,8 @@ preprocess_expression(PlannerInfo *root, Node *expr, int kind)
     * 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.
     *
-    * For VALUES lists we never do this at all, again on the grounds that
-    * we should optimize for one-time evaluation.
+    * For VALUES lists we never do this at all, again on the grounds that we
+    * should optimize for one-time evaluation.
     */
    if (kind != EXPRKIND_VALUES &&
        (root->parse->jointree->fromlist != NIL ||
@@ -593,8 +593,8 @@ inheritance_planner(PlannerInfo *root)
        subplan = grouping_planner(&subroot, 0.0 /* retrieve all tuples */ );
 
        /*
-        * If this child rel was excluded by constraint exclusion, exclude
-        * it from the plan.
+        * If this child rel was excluded by constraint exclusion, exclude it
+        * from the plan.
         */
        if (is_dummy_plan(subplan))
            continue;
@@ -1098,12 +1098,12 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
 
    /*
     * Deal with the RETURNING clause if any.  It's convenient to pass the
-    * returningList through setrefs.c now rather than at top level (if
-    * we waited, handling inherited UPDATE/DELETE would be much harder).
+    * returningList through setrefs.c now rather than at top level (if we
+    * waited, handling inherited UPDATE/DELETE would be much harder).
     */
    if (parse->returningList)
    {
-       List   *rlist;
+       List       *rlist;
 
        rlist = set_returning_clause_references(parse->returningList,
                                                result_plan,
@@ -1132,11 +1132,11 @@ is_dummy_plan(Plan *plan)
 {
    if (IsA(plan, Result))
    {
-       List *rcqual = (List *) ((Result *) plan)->resconstantqual;
+       List       *rcqual = (List *) ((Result *) plan)->resconstantqual;
 
        if (list_length(rcqual) == 1)
        {
-           Const *constqual = (Const *) linitial(rcqual);
+           Const      *constqual = (Const *) linitial(rcqual);
 
            if (constqual && IsA(constqual, Const))
            {
index 3f3a7199417820691ea1a3af2508eb25658637ba..298c8d1cff61a8a5290fe45b9d41ae157a4677d7 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.125 2006/08/28 14:32:41 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.126 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -453,13 +453,13 @@ trivial_subqueryscan(SubqueryScan *plan)
            return false;       /* tlist doesn't match junk status */
 
        /*
-        * We accept either a Var referencing the corresponding element of
-        * the subplan tlist, or a Const equaling the subplan element.
-        * See generate_setop_tlist() for motivation.
+        * We accept either a Var referencing the corresponding element of the
+        * subplan tlist, or a Const equaling the subplan element. See
+        * generate_setop_tlist() for motivation.
         */
        if (ptle->expr && IsA(ptle->expr, Var))
        {
-           Var    *var = (Var *) ptle->expr;
+           Var        *var = (Var *) ptle->expr;
 
            Assert(var->varno == plan->scan.scanrelid);
            Assert(var->varlevelsup == 0);
@@ -793,7 +793,7 @@ set_join_references(Join *join)
  *
  * To handle bitmap-scan plan trees, we have to be able to recurse down
  * to the bottom BitmapIndexScan nodes; likewise, appendrel indexscans
- * require recursing through Append nodes.  This is split out as a separate
+ * require recursing through Append nodes. This is split out as a separate
  * function so that it can recurse.
  */
 static void
@@ -1339,7 +1339,7 @@ replace_vars_with_subplan_refs_mutator(Node *node,
  * adjust any Vars that refer to other tables to reference junk tlist
  * entries in the top plan's targetlist.  Vars referencing the result
  * table should be left alone, however (the executor will evaluate them
- * using the actual heap tuple, after firing triggers if any).  In the
+ * using the actual heap tuple, after firing triggers if any). In the
  * adjusted RETURNING list, result-table Vars will still have their
  * original varno, but Vars for other rels will have varno OUTER.
  *
@@ -1359,8 +1359,8 @@ set_returning_clause_references(List *rlist,
 
    /*
     * We can perform the desired Var fixup by abusing the join_references
-    * machinery that normally handles inner indexscan fixup.  We search
-    * the top plan's targetlist for Vars of non-result relations, and use
+    * machinery that normally handles inner indexscan fixup.  We search the
+    * top plan's targetlist for Vars of non-result relations, and use
     * join_references to convert RETURNING Vars into references to those
     * tlist entries, while leaving result-rel Vars as-is.
     */
index 95e560478d9cb867df182481999ac71ff169b2c2..94c97a55aa5f7ac3cd01e68f13d5142e372d67b7 100644 (file)
@@ -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.111 2006/08/02 01:59:46 joe Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.112 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -85,10 +85,10 @@ typedef struct finalize_primnode_context
 
 
 static Node *convert_testexpr(Node *testexpr,
-                             int rtindex,
-                             List **righthandIds);
+                int rtindex,
+                List **righthandIds);
 static Node *convert_testexpr_mutator(Node *node,
-                                     convert_testexpr_context *context);
+                        convert_testexpr_context *context);
 static bool subplan_is_hashable(SubLink *slink, SubPlan *node);
 static bool hash_ok_operator(OpExpr *expr);
 static Node *replace_correlation_vars_mutator(Node *node, void *context);
@@ -498,13 +498,13 @@ convert_testexpr_mutator(Node *node,
        return NULL;
    if (IsA(node, Param))
    {
-       Param  *param = (Param *) node;
+       Param      *param = (Param *) node;
 
        if (param->paramkind == PARAM_SUBLINK)
        {
            /*
-            * We expect to encounter the Params in column-number sequence.
-            * We could handle non-sequential order if necessary, but for now
+            * We expect to encounter the Params in column-number sequence. We
+            * could handle non-sequential order if necessary, but for now
             * there's no need.  (This is also a useful cross-check that we
             * aren't finding any unexpected Params.)
             */
@@ -514,13 +514,14 @@ convert_testexpr_mutator(Node *node,
            if (context->rtindex)
            {
                /* Make the Var node representing the subplan's result */
-               Var    *newvar;
+               Var        *newvar;
 
                newvar = makeVar(context->rtindex,
                                 param->paramid,
                                 param->paramtype,
                                 -1,
                                 0);
+
                /*
                 * Copy it for caller.  NB: we need a copy to avoid having
                 * doubly-linked substructure in the modified parse tree.
@@ -584,10 +585,10 @@ subplan_is_hashable(SubLink *slink, SubPlan *node)
        return false;
 
    /*
-    * The estimated size of the subquery result must fit in work_mem.
-    * (Note: we use sizeof(HeapTupleHeaderData) here even though the tuples
-    * will actually be stored as MinimalTuples; this provides some fudge
-    * factor for hashtable overhead.)
+    * The estimated size of the subquery result must fit in work_mem. (Note:
+    * we use sizeof(HeapTupleHeaderData) here even though the tuples will
+    * actually be stored as MinimalTuples; this provides some fudge factor
+    * for hashtable overhead.)
     */
    subquery_size = node->plan->plan_rows *
        (MAXALIGN(node->plan->plan_width) + MAXALIGN(sizeof(HeapTupleHeaderData)));
@@ -616,7 +617,7 @@ subplan_is_hashable(SubLink *slink, SubPlan *node)
    {
        foreach(l, ((BoolExpr *) slink->testexpr)->args)
        {
-           Node    *andarg = (Node *) lfirst(l);
+           Node       *andarg = (Node *) lfirst(l);
 
            if (!IsA(andarg, OpExpr))
                return false;   /* probably can't happen */
@@ -686,8 +687,8 @@ convert_IN_to_join(PlannerInfo *root, SubLink *sublink)
        return NULL;
    if (sublink->testexpr && IsA(sublink->testexpr, OpExpr))
    {
-       List    *opclasses;
-       List    *opstrats;
+       List       *opclasses;
+       List       *opstrats;
 
        get_op_btree_interpretation(((OpExpr *) sublink->testexpr)->opno,
                                    &opclasses, &opstrats);
index bea7c03a739e3ad01b89a1abb2b5a08d682ea945..eedd1a8ff0744a86be3259129e647b8dcfc5854e 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.43 2006/08/19 02:48:53 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/prep/prepjointree.c,v 1.44 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,20 +40,20 @@ typedef struct reduce_outer_joins_state
 } reduce_outer_joins_state;
 
 static Node *pull_up_simple_subquery(PlannerInfo *root, Node *jtnode,
-                                    RangeTblEntry *rte,
-                                    bool below_outer_join,
-                                    bool append_rel_member);
+                       RangeTblEntry *rte,
+                       bool below_outer_join,
+                       bool append_rel_member);
 static Node *pull_up_simple_union_all(PlannerInfo *root, Node *jtnode,
-                                     RangeTblEntry *rte);
+                        RangeTblEntry *rte);
 static void pull_up_union_leaf_queries(Node *setOp, PlannerInfo *root,
-                                      int parentRTindex, Query *setOpQuery);
+                          int parentRTindex, Query *setOpQuery);
 static void make_setop_translation_lists(Query *query,
                             Index newvarno,
                             List **col_mappings, List **translated_vars);
 static bool is_simple_subquery(Query *subquery);
 static bool is_simple_union_all(Query *subquery);
 static bool is_simple_union_all_recurse(Node *setOp, Query *setOpQuery,
-                                       List *colTypes);
+                           List *colTypes);
 static bool has_nullable_targetlist(Query *subquery);
 static bool is_safe_append_member(Query *subquery);
 static void resolvenew_in_jointree(Node *jtnode, int varno,
@@ -66,7 +66,7 @@ static void reduce_outer_joins_pass2(Node *jtnode,
 static void fix_in_clause_relids(List *in_info_list, int varno,
                     Relids subrelids);
 static void fix_append_rel_relids(List *append_rel_list, int varno,
-                                 Relids subrelids);
+                     Relids subrelids);
 static Node *find_jointree_node_for_rel(Node *jtnode, int relid);
 
 
@@ -136,7 +136,7 @@ pull_up_IN_clauses(PlannerInfo *root, Node *node)
  * side of an outer join.  This restricts what we can do.
  *
  * append_rel_member is true if we are looking at a member subquery of
- * an append relation.  This puts some different restrictions on what
+ * an append relation. This puts some different restrictions on what
  * we can do.
  *
  * A tricky aspect of this code is that if we pull up a subquery we have
@@ -173,8 +173,8 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode,
         * variables evaluated at the right place in the modified plan tree.
         * Fix it someday.
         *
-        * If we are looking at an append-relation member, we can't pull
-        * it up unless is_safe_append_member says so.
+        * If we are looking at an append-relation member, we can't pull it up
+        * unless is_safe_append_member says so.
         */
        if (rte->rtekind == RTE_SUBQUERY &&
            is_simple_subquery(rte->subquery) &&
@@ -186,14 +186,15 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode,
 
        /*
         * Alternatively, is it a simple UNION ALL subquery?  If so, flatten
-        * into an "append relation".  We can do this regardless of nullability
-        * considerations since this transformation does not result in
-        * propagating non-Var expressions into upper levels of the query.
+        * into an "append relation".  We can do this regardless of
+        * nullability considerations since this transformation does not
+        * result in propagating non-Var expressions into upper levels of the
+        * query.
         *
         * It's also safe to do this regardless of whether this query is
-        * itself an appendrel member.  (If you're thinking we should try
-        * to flatten the two levels of appendrel together, you're right;
-        * but we handle that in set_append_rel_pathlist, not here.)
+        * itself an appendrel member.  (If you're thinking we should try to
+        * flatten the two levels of appendrel together, you're right; but we
+        * handle that in set_append_rel_pathlist, not here.)
         */
        if (rte->rtekind == RTE_SUBQUERY &&
            is_simple_union_all(rte->subquery))
@@ -258,7 +259,7 @@ pull_up_subqueries(PlannerInfo *root, Node *jtnode,
  *     Attempt to pull up a single simple subquery.
  *
  * jtnode is a RangeTblRef that has been tentatively identified as a simple
- * subquery by pull_up_subqueries.  We return the replacement jointree node,
+ * subquery by pull_up_subqueries. We return the replacement jointree node,
  * or jtnode itself if we determine that the subquery can't be pulled up after
  * all.
  */
@@ -275,11 +276,10 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
    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(rte->subquery);
 
@@ -287,8 +287,8 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
     * 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?
+    * subquery_planner().  Can we refactor to avoid code duplication, or
+    * would that just make things uglier?
     */
    subroot = makeNode(PlannerInfo);
    subroot->parse = subquery;
@@ -296,12 +296,12 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
    subroot->append_rel_list = NIL;
 
    /*
-    * 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.
     */
    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
@@ -310,19 +310,19 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
     *
     * Note: below_outer_join = 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.  Likewise, we say we aren't handling
-    * an appendrel member.
+    * slate for outer-join semantics.  Likewise, we say we aren't handling an
+    * appendrel member.
     */
    subquery->jointree = (FromExpr *)
        pull_up_subqueries(subroot, (Node *) subquery->jointree, false, 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 in pull_up_subqueries.
+    * 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 in
+    * pull_up_subqueries.
     */
    if (is_simple_subquery(subquery) &&
        (!below_outer_join || has_nullable_targetlist(subquery)) &&
@@ -335,18 +335,18 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
        /*
         * 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;
    }
 
    /*
-    * Adjust level-0 varnos in subquery so that we can append its
-    * rangetable to upper query's.  We have to fix the subquery's
-    * in_info_list and append_rel_list, as well.
+    * Adjust level-0 varnos in subquery so that we can append its rangetable
+    * to upper query's.  We have to fix the subquery's in_info_list and
+    * append_rel_list, as well.
     */
    rtoffset = list_length(parse->rtable);
    OffsetVarNodes((Node *) subquery, rtoffset, 0);
@@ -354,18 +354,18 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
    OffsetVarNodes((Node *) subroot->append_rel_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);
    IncrementVarSublevelsUp((Node *) subroot->append_rel_list, -1, 1);
 
    /*
-    * 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.)
+    * 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.)
     */
    subtlist = subquery->targetList;
    parse->targetList = (List *)
@@ -404,27 +404,27 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
    }
 
    /*
-    * 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);
 
    /*
-    * Pull up any FOR UPDATE/SHARE markers, too.  (OffsetVarNodes
-    * already adjusted the marker rtindexes, so just concat the lists.)
+    * Pull up any FOR UPDATE/SHARE markers, too.  (OffsetVarNodes already
+    * adjusted the marker rtindexes, so just concat the lists.)
     */
    parse->rowMarks = list_concat(parse->rowMarks, subquery->rowMarks);
 
    /*
-    * 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.)
     *
-    * Likewise, relids appearing in AppendRelInfo nodes have to be fixed
-    * (but we took care of their translated_vars lists above).  We already
-    * checked that this won't require introducing multiple subrelids into
-    * the single-slot AppendRelInfo structs.
+    * Likewise, relids appearing in AppendRelInfo nodes have to be fixed (but
+    * we took care of their translated_vars lists above).  We already checked
+    * that this won't require introducing multiple subrelids into the
+    * single-slot AppendRelInfo structs.
     */
    if (root->in_info_list || root->append_rel_list)
    {
@@ -444,8 +444,8 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
                                        subroot->append_rel_list);
 
    /*
-    * We don't have to do the equivalent bookkeeping for outer-join
-    * info, because that hasn't been set up yet.
+    * We don't have to do the equivalent bookkeeping for outer-join info,
+    * because that hasn't been set up yet.
     */
    Assert(root->oj_info_list == NIL);
    Assert(subroot->oj_info_list == NIL);
@@ -457,8 +457,8 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
    /* subquery won't be pulled up if it hasAggs, so no work there */
 
    /*
-    * Return the adjusted subquery jointree to replace the
-    * RangeTblRef entry in parent's jointree.
+    * Return the adjusted subquery jointree to replace the RangeTblRef entry
+    * in parent's jointree.
     */
    return (Node *) subquery->jointree;
 }
@@ -468,7 +468,7 @@ pull_up_simple_subquery(PlannerInfo *root, Node *jtnode, RangeTblEntry *rte,
  *     Pull up a single simple UNION ALL subquery.
  *
  * jtnode is a RangeTblRef that has been identified as a simple UNION ALL
- * subquery by pull_up_subqueries.  We pull up the leaf subqueries and
+ * subquery by pull_up_subqueries. We pull up the leaf subqueries and
  * build an "append relation" for the union set.  The result value is just
  * jtnode, since we don't actually need to change the query jointree.
  */
@@ -524,9 +524,9 @@ pull_up_union_leaf_queries(Node *setOp, PlannerInfo *root, int parentRTindex,
 
        /*
         * Upper-level vars in subquery are now one level closer to their
-        * parent than before.  We don't have to worry about offsetting
-        * varnos, though, because any such vars must refer to stuff above
-        * the level of the query we are pulling into.
+        * parent than before.  We don't have to worry about offsetting
+        * varnos, though, because any such vars must refer to stuff above the
+        * level of the query we are pulling into.
         */
        IncrementVarSublevelsUp((Node *) subquery, -1, 1);
 
@@ -658,9 +658,9 @@ is_simple_subquery(Query *subquery)
 
    /*
     * Don't pull up a subquery that has any volatile functions in its
-    * targetlist.  Otherwise we might introduce multiple evaluations of
-    * these functions, if they get copied to multiple places in the upper
-    * query, leading to surprising results.
+    * targetlist.  Otherwise we might introduce multiple evaluations of these
+    * functions, if they get copied to multiple places in the upper query,
+    * leading to surprising results.
     */
    if (contain_volatile_functions((Node *) subquery->targetList))
        return false;
@@ -799,16 +799,15 @@ is_safe_append_member(Query *subquery)
    ListCell   *l;
 
    /*
-    * It's only safe to pull up the child if its jointree contains
-    * exactly one RTE, else the AppendRelInfo data structure breaks.
-    * The one base RTE could be buried in several levels of FromExpr,
-    * however.
+    * It's only safe to pull up the child if its jointree contains exactly
+    * one RTE, else the AppendRelInfo data structure breaks. The one base RTE
+    * could be buried in several levels of FromExpr, however.
     *
-    * Also, the child can't have any WHERE quals because there's no
-    * place to put them in an appendrel.  (This is a bit annoying...)
-    * If we didn't need to check this, we'd just test whether
-    * get_relids_in_jointree() yields a singleton set, to be more
-    * consistent with the coding of fix_append_rel_relids().
+    * Also, the child can't have any WHERE quals because there's no place to
+    * put them in an appendrel.  (This is a bit annoying...) If we didn't
+    * need to check this, we'd just test whether get_relids_in_jointree()
+    * yields a singleton set, to be more consistent with the coding of
+    * fix_append_rel_relids().
     */
    jtnode = subquery->jointree;
    while (IsA(jtnode, FromExpr))
@@ -825,10 +824,10 @@ is_safe_append_member(Query *subquery)
    /*
     * XXX For the moment we also have to insist that the subquery's tlist
     * includes only simple Vars.  This is pretty annoying, but fixing it
-    * seems to require nontrivial changes --- mainly because joinrel
-    * tlists are presently assumed to contain only Vars.  Perhaps a
-    * pseudo-variable mechanism similar to the one speculated about
-    * in pull_up_subqueries' comments would help?  FIXME someday.
+    * seems to require nontrivial changes --- mainly because joinrel tlists
+    * are presently assumed to contain only Vars.  Perhaps a pseudo-variable
+    * mechanism similar to the one speculated about in pull_up_subqueries'
+    * comments would help?  FIXME someday.
     */
    foreach(l, subquery->targetList)
    {
@@ -1190,9 +1189,9 @@ fix_append_rel_relids(List *append_rel_list, int varno, Relids subrelids)
 
    /*
     * We only want to extract the member relid once, but we mustn't fail
-    * immediately if there are multiple members; it could be that none of
-    * the AppendRelInfo nodes refer to it.  So compute it on first use.
-    * Note that bms_singleton_member will complain if set is not singleton.
+    * immediately if there are multiple members; it could be that none of the
+    * AppendRelInfo nodes refer to it.  So compute it on first use. Note that
+    * bms_singleton_member will complain if set is not singleton.
     */
    foreach(l, append_rel_list)
    {
index b0d2e7d18cdd4d05cd5253751e42933486c661d8..22e1dd07f2fa7b492258ca7ec1f5ca2965f18d18 100644 (file)
@@ -25,7 +25,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.55 2006/07/14 14:52:21 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/prep/prepqual.c,v 1.56 2006/10/04 00:29:54 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -212,7 +212,7 @@ push_nots(Expr *qual)
 
        if (negator)
        {
-           OpExpr *newopexpr = makeNode(OpExpr);
+           OpExpr     *newopexpr = makeNode(OpExpr);
 
            newopexpr->opno = negator;
            newopexpr->opfuncid = InvalidOid;
@@ -228,9 +228,9 @@ push_nots(Expr *qual)
    {
        /*
         * Negate a ScalarArrayOpExpr if there is a negator for its operator;
-        * for example x = ANY (list) becomes x <> ALL (list).
-        * Otherwise, retain the clause as it is (the NOT can't be pushed down
-        * any farther).
+        * for example x = ANY (list) becomes x <> ALL (list). Otherwise,
+        * retain the clause as it is (the NOT can't be pushed down any
+        * farther).
         */
        ScalarArrayOpExpr *saopexpr = (ScalarArrayOpExpr *) qual;
        Oid         negator = get_negator(saopexpr->opno);
index c4bbd9d2eeccce2e1bfcbc4515cb7e175e193160..4d442421694a549af619bd69528402cd388624cf 100644 (file)
@@ -16,7 +16,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.83 2006/08/12 02:52:05 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/prep/preptlist.c,v 1.84 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -157,13 +157,13 @@ preprocess_targetlist(PlannerInfo *root, List *tlist)
    /*
     * If the query has a RETURNING list, add resjunk entries for any Vars
     * used in RETURNING that belong to other relations.  We need to do this
-    * to make these Vars available for the RETURNING calculation.  Vars
-    * that belong to the result rel don't need to be added, because they
-    * will be made to refer to the actual heap tuple.
+    * to make these Vars available for the RETURNING calculation.  Vars that
+    * belong to the result rel don't need to be added, because they will be
+    * made to refer to the actual heap tuple.
     */
    if (parse->returningList && list_length(parse->rtable) > 1)
    {
-       List   *vars;
+       List       *vars;
        ListCell   *l;
 
        vars = pull_var_clause((Node *) parse->returningList, false);
index 3bf7223199f06a66968cb6cdc52d676fdf3c5581..44aebd9ed3f44503f7bf752617692223c1200c7b 100644 (file)
@@ -6,14 +6,14 @@
  *
  * There are two code paths in the planner for set-operation queries.
  * If a subquery consists entirely of simple UNION ALL operations, it
- * is converted into an "append relation".  Otherwise, it is handled
+ * is converted into an "append relation". Otherwise, it is handled
  * by the general code in this module (plan_set_operations and its
  * subroutines).  There is some support code here for the append-relation
  * case, but most of the heavy lifting for that is done elsewhere,
  * notably in prepjointree.c and allpaths.c.
  *
  * There is also some code here to support planning of queries that use
- * inheritance (SELECT FROM foo*).  Inheritance trees are converted into
+ * inheritance (SELECT FROM foo*). Inheritance trees are converted into
  * append relations, and thenceforth share code with the UNION ALL case.
  *
  *
@@ -22,7 +22,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.133 2006/08/10 02:36:28 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.134 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -69,14 +69,14 @@ static List *generate_append_tlist(List *colTypes, bool flag,
                      List *input_plans,
                      List *refnames_tlist);
 static void expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte,
-                                    Index rti);
+                        Index rti);
 static void make_inh_translation_lists(Relation oldrelation,
-                                      Relation newrelation,
-                                      Index newvarno,
-                                      List **col_mappings,
-                                      List **translated_vars);
+                          Relation newrelation,
+                          Index newvarno,
+                          List **col_mappings,
+                          List **translated_vars);
 static Node *adjust_appendrel_attrs_mutator(Node *node,
-                                           AppendRelInfo *context);
+                              AppendRelInfo *context);
 static Relids adjust_relid_set(Relids relids, Index oldrelid, Index newrelid);
 static List *adjust_inherited_tlist(List *tlist,
                       AppendRelInfo *context);
@@ -713,21 +713,21 @@ find_all_inheritors(Oid parentrel)
 /*
  * expand_inherited_tables
  *     Expand each rangetable entry that represents an inheritance set
- *     into an "append relation".  At the conclusion of this process,
+ *     into an "append relation".  At the conclusion of this process,
  *     the "inh" flag is set in all and only those RTEs that are append
  *     relation parents.
  */
 void
 expand_inherited_tables(PlannerInfo *root)
 {
-   Index   nrtes;
-   Index   rti;
-   ListCell *rl;
+   Index       nrtes;
+   Index       rti;
+   ListCell   *rl;
 
    /*
-    * expand_inherited_rtentry may add RTEs to parse->rtable; there is
-    * no need to scan them since they can't have inh=true.  So just
-    * scan as far as the original end of the rtable list.
+    * expand_inherited_rtentry may add RTEs to parse->rtable; there is no
+    * need to scan them since they can't have inh=true.  So just scan as far
+    * as the original end of the rtable list.
     */
    nrtes = list_length(root->parse->rtable);
    rl = list_head(root->parse->rtable);
@@ -745,7 +745,7 @@ expand_inherited_tables(PlannerInfo *root)
  *     Check whether a rangetable entry represents an inheritance set.
  *     If so, add entries for all the child tables to the query's
  *     rangetable, and build AppendRelInfo nodes for all the child tables
- *     and add them to root->append_rel_list.  If not, clear the entry's
+ *     and add them to root->append_rel_list.  If not, clear the entry's
  *     "inh" flag to prevent later code from looking for AppendRelInfos.
  *
  * Note that the original RTE is considered to represent the whole
@@ -801,22 +801,22 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
    }
 
    /*
-    * Must open the parent relation to examine its tupdesc.  We need not
-    * lock it since the rewriter already obtained at least AccessShareLock
-    * on each relation used in the query.
+    * Must open the parent relation to examine its tupdesc.  We need not lock
+    * it since the rewriter already obtained at least AccessShareLock on each
+    * relation used in the query.
     */
    oldrelation = heap_open(parentOID, NoLock);
 
    /*
-    * However, for each child relation we add to the query, we must obtain
-    * an appropriate lock, because this will be the first use of those
-    * relations in the parse/rewrite/plan pipeline.
+    * However, for each child relation we add to the query, we must obtain an
+    * appropriate lock, because this will be the first use of those relations
+    * in the parse/rewrite/plan pipeline.
     *
     * If the parent 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.  (This code should match the parser and rewriter.)
+    * possible deadlocks.  (This code should match the parser and rewriter.)
     */
    if (rti == parse->resultRelation)
        lockmode = RowExclusiveLock;
@@ -900,8 +900,8 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
 
    /*
     * The executor will check the parent table's access permissions when it
-    * examines the parent's added RTE entry.  There's no need to check
-    * twice, so turn off access check bits in the original RTE.
+    * examines the parent's added RTE entry.  There's no need to check twice,
+    * so turn off access check bits in the original RTE.
     */
    rte->requiredPerms = 0;
 }
@@ -948,8 +948,8 @@ make_inh_translation_lists(Relation oldrelation, Relation newrelation,
        atttypmod = att->atttypmod;
 
        /*
-        * When we are generating the "translation list" for the parent
-        * table of an inheritance set, no need to search for matches.
+        * When we are generating the "translation list" for the parent table
+        * of an inheritance set, no need to search for matches.
         */
        if (oldrelation == newrelation)
        {
@@ -964,9 +964,8 @@ make_inh_translation_lists(Relation oldrelation, Relation newrelation,
 
        /*
         * Otherwise we have to search for the matching column by name.
-        * There's no guarantee it'll have the same column position,
-        * because of cases like ALTER TABLE ADD COLUMN and multiple
-        * inheritance.
+        * There's no guarantee it'll have the same column position, because
+        * of cases like ALTER TABLE ADD COLUMN and multiple inheritance.
         */
        for (new_attno = 0; new_attno < newnatts; new_attno++)
        {
@@ -979,7 +978,7 @@ make_inh_translation_lists(Relation oldrelation, Relation newrelation,
            if (atttypid != att->atttypid || atttypmod != att->atttypmod)
                elog(ERROR, "attribute \"%s\" of relation \"%s\" does not match parent's type",
                     attname, RelationGetRelationName(newrelation));
-           
+
            numbers = lappend_int(numbers, new_attno + 1);
            vars = lappend(vars, makeVar(newvarno,
                                         (AttrNumber) (new_attno + 1),
@@ -1060,7 +1059,7 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context)
            var->varnoold = context->child_relid;
            if (var->varattno > 0)
            {
-               Node   *newnode;
+               Node       *newnode;
 
                if (var->varattno > list_length(context->translated_vars))
                    elog(ERROR, "attribute %d of relation \"%s\" does not exist",
@@ -1075,10 +1074,10 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context)
            else if (var->varattno == 0)
            {
                /*
-                * Whole-row Var: if we are dealing with named rowtypes,
-                * we can use a whole-row Var for the child table plus a
-                * coercion step to convert the tuple layout to the parent's
-                * rowtype.  Otherwise we have to generate a RowExpr.
+                * Whole-row Var: if we are dealing with named rowtypes, we
+                * can use a whole-row Var for the child table plus a coercion
+                * step to convert the tuple layout to the parent's rowtype.
+                * Otherwise we have to generate a RowExpr.
                 */
                if (OidIsValid(context->child_reltype))
                {
@@ -1217,9 +1216,9 @@ adjust_appendrel_attrs_mutator(Node *node, AppendRelInfo *context)
     * 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 finished APPEND
-    * plan, which will cause trouble in the executor.  This is a kluge that
-    * should go away when we redesign querytrees.
+    * same subplan node referenced from each arm of the finished 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))
    {
@@ -1267,7 +1266,7 @@ adjust_relid_set(Relids relids, Index oldrelid, Index newrelid)
  *
  * The relid sets are adjusted by substituting child_relid for parent_relid.
  * (NOTE: oldrel is not necessarily the parent_relid relation!)  We are also
- * careful to map attribute numbers within the array properly.  User
+ * careful to map attribute numbers within the array properly. User
  * attributes have to be mapped through col_mappings, but system attributes
  * and whole-row references always have the same attno.
  *
@@ -1353,7 +1352,7 @@ adjust_inherited_tlist(List *tlist, AppendRelInfo *context)
    foreach(tl, tlist)
    {
        TargetEntry *tle = (TargetEntry *) lfirst(tl);
-       int     newattno;
+       int         newattno;
 
        if (tle->resjunk)
            continue;           /* ignore junk items */
index 99d3147aeb5da80214128732ea733648c28063e3..c9d9512b2f5dc576c554e737447aeb9391bbdc9e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.221 2006/09/28 20:51:41 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.222 2006/10/04 00:29:55 momjian Exp $
  *
  * HISTORY
  *   AUTHOR            DATE            MAJOR EVENT
@@ -403,7 +403,7 @@ count_agg_clauses_walker(Node *node, AggClauseCounts *counts)
        Form_pg_aggregate aggform;
        Oid         aggtranstype;
        int         i;
-       ListCell    *l;
+       ListCell   *l;
 
        Assert(aggref->agglevelsup == 0);
        counts->numAggs++;
@@ -887,7 +887,7 @@ contain_nonstrict_functions_walker(Node *node, void *context)
  *
  * Returns the set of all Relids that are referenced in the clause in such
  * a way that the clause cannot possibly return TRUE if any of these Relids
- * is an all-NULL row.  (It is OK to err on the side of conservatism; hence
+ * is an all-NULL row. (It is OK to err on the side of conservatism; hence
  * the analysis here is simplistic.)
  *
  * The semantics here are subtly different from contain_nonstrict_functions:
@@ -1020,7 +1020,7 @@ find_nonnullable_rels_walker(Node *node, bool top_level)
 static bool
 is_strict_saop(ScalarArrayOpExpr *expr, bool falseOK)
 {
-   Node   *rightop;
+   Node       *rightop;
 
    /* The contained operator must be strict. */
    if (!op_strict(expr->opno))
@@ -1288,12 +1288,13 @@ CommuteRowCompareExpr(RowCompareExpr *clause)
    }
 
    clause->opnos = newops;
+
    /*
-    * Note: we don't bother to update the opclasses list, but just set
-    * it to empty.  This is OK since this routine is currently only used
-    * for index quals, and the index machinery won't use the opclass
-    * information.  The original opclass list is NOT valid if we have
-    * commuted any cross-type comparisons, so don't leave it in place.
+    * Note: we don't bother to update the opclasses list, but just set it to
+    * empty.  This is OK since this routine is currently only used for index
+    * quals, and the index machinery won't use the opclass information.  The
+    * original opclass list is NOT valid if we have commuted any cross-type
+    * comparisons, so don't leave it in place.
     */
    clause->opclasses = NIL;    /* XXX */
 
@@ -2109,9 +2110,9 @@ eval_const_expressions_mutator(Node *node,
                                             context);
        if (arg && IsA(arg, RowExpr))
        {
-           RowExpr  *rarg = (RowExpr *) arg;
-           List    *newargs = NIL;
-           ListCell *l;
+           RowExpr    *rarg = (RowExpr *) arg;
+           List       *newargs = NIL;
+           ListCell   *l;
 
            /*
             * We break ROW(...) IS [NOT] NULL into separate tests on its
@@ -2120,15 +2121,15 @@ eval_const_expressions_mutator(Node *node,
             */
            foreach(l, rarg->args)
            {
-               Node *relem = (Node *) lfirst(l);
+               Node       *relem = (Node *) lfirst(l);
 
                /*
-                * A constant field refutes the whole NullTest if it's of
-                * the wrong nullness; else we can discard it.
+                * A constant field refutes the whole NullTest if it's of the
+                * wrong nullness; else we can discard it.
                 */
                if (relem && IsA(relem, Const))
                {
-                   Const  *carg = (Const *) relem;
+                   Const      *carg = (Const *) relem;
 
                    if (carg->constisnull ?
                        (ntest->nulltesttype == IS_NOT_NULL) :
@@ -2152,8 +2153,8 @@ eval_const_expressions_mutator(Node *node,
        }
        if (arg && IsA(arg, Const))
        {
-           Const  *carg = (Const *) arg;
-           bool    result;
+           Const      *carg = (Const *) arg;
+           bool        result;
 
            switch (ntest->nulltesttype)
            {
@@ -2166,7 +2167,7 @@ eval_const_expressions_mutator(Node *node,
                default:
                    elog(ERROR, "unrecognized nulltesttype: %d",
                         (int) ntest->nulltesttype);
-                   result = false; /* keep compiler quiet */
+                   result = false;     /* keep compiler quiet */
                    break;
            }
 
@@ -2188,8 +2189,8 @@ eval_const_expressions_mutator(Node *node,
                                             context);
        if (arg && IsA(arg, Const))
        {
-           Const  *carg = (Const *) arg;
-           bool    result;
+           Const      *carg = (Const *) arg;
+           bool        result;
 
            switch (btest->booltesttype)
            {
@@ -2218,7 +2219,7 @@ eval_const_expressions_mutator(Node *node,
                default:
                    elog(ERROR, "unrecognized booltesttype: %d",
                         (int) btest->booltesttype);
-                   result = false; /* keep compiler quiet */
+                   result = false;     /* keep compiler quiet */
                    break;
            }
 
@@ -3174,7 +3175,7 @@ expression_tree_walker(Node *node,
            break;
        case T_Aggref:
            {
-               Aggref   *expr = (Aggref *) node;
+               Aggref     *expr = (Aggref *) node;
 
                if (expression_tree_walker((Node *) expr->args,
                                           walker, context))
@@ -3452,8 +3453,8 @@ query_tree_walker(Query *query,
    if (query->utilityStmt)
    {
        /*
-        * Certain utility commands contain general-purpose Querys embedded
-        * in them --- if this is one, invoke the walker on the sub-Query.
+        * Certain utility commands contain general-purpose Querys embedded in
+        * them --- if this is one, invoke the walker on the sub-Query.
         */
        if (IsA(query->utilityStmt, CopyStmt))
        {
@@ -3828,8 +3829,8 @@ expression_tree_mutator(Node *node,
            break;
        case T_RowCompareExpr:
            {
-               RowCompareExpr    *rcexpr = (RowCompareExpr *) node;
-               RowCompareExpr    *newnode;
+               RowCompareExpr *rcexpr = (RowCompareExpr *) node;
+               RowCompareExpr *newnode;
 
                FLATCOPY(newnode, rcexpr, RowCompareExpr);
                MUTATE(newnode->largs, rcexpr->largs, List *);
index 2cc79ed239eb3b94f585ab3239b2cd7c3949296e..01f3151bee8c651577f5bff2da0f7d667a365cb8 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.132 2006/08/02 01:59:46 joe Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.133 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -418,7 +418,7 @@ create_seqscan_path(PlannerInfo *root, RelOptInfo *rel)
  *         for an ordered index, or NoMovementScanDirection for
  *         an unordered index.
  * 'outer_rel' is the outer relation if this is a join inner indexscan path.
- *         (pathkeys and indexscandir are ignored if so.)  NULL if not.
+ *         (pathkeys and indexscandir are ignored if so.)  NULL if not.
  *
  * Returns the new path node.
  */
@@ -680,12 +680,12 @@ create_result_path(List *quals)
    /* Ideally should define cost_result(), but I'm too lazy */
    pathnode->path.startup_cost = 0;
    pathnode->path.total_cost = cpu_tuple_cost;
+
    /*
-    * In theory we should include the qual eval cost as well, but
-    * at present that doesn't accomplish much except duplicate work that
-    * will be done again in make_result; since this is only used for
-    * degenerate cases, nothing interesting will be done with the path
-    * cost values...
+    * In theory we should include the qual eval cost as well, but at present
+    * that doesn't accomplish much except duplicate work that will be done
+    * again in make_result; since this is only used for degenerate cases,
+    * nothing interesting will be done with the path cost values...
     */
 
    return pathnode;
index aba4b881571effc1109aab826b33fda8e7381e30..de14ddd2dc083f32d7f4c0592dad8a4c389c3cec 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.126 2006/09/19 22:49:53 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.127 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -78,9 +78,9 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
    List       *indexinfos = NIL;
 
    /*
-    * We need not lock the relation since it was already locked, either
-    * by the rewriter or when expand_inherited_rtentry() added it to the
-    * query's rangetable.
+    * We need not lock the relation since it was already locked, either by
+    * the rewriter or when expand_inherited_rtentry() added it to the query's
+    * rangetable.
     */
    relation = heap_open(relationObjectId, NoLock);
 
@@ -95,8 +95,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
 
    /*
     * Estimate relation size --- unless it's an inheritance parent, in which
-    * case the size will be computed later in set_append_rel_pathlist, and
-    * we must leave it zero for now to avoid bollixing the total_table_pages
+    * case the size will be computed later in set_append_rel_pathlist, and we
+    * must leave it zero for now to avoid bollixing the total_table_pages
     * calculation.
     */
    if (!inhparent)
@@ -152,9 +152,9 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
 
            /*
             * Ignore invalid indexes, since they can't safely be used for
-            * queries.  Note that this is OK because the data structure
-            * we are constructing is only used by the planner --- the
-            * executor still needs to insert into "invalid" indexes!
+            * queries.  Note that this is OK because the data structure we
+            * are constructing is only used by the planner --- the executor
+            * still needs to insert into "invalid" indexes!
             */
            if (!index->indisvalid)
            {
@@ -508,14 +508,14 @@ relation_excluded_by_constraints(RelOptInfo *rel, RangeTblEntry *rte)
    /*
     * 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.
-    * Since they're ANDed, we can just ignore any mutable constraints in
-    * the list, and reason about the rest.
+    * conclusions from plan-time evaluation of non-immutable functions. Since
+    * they're ANDed, we can just ignore any mutable constraints in the list,
+    * and reason about the rest.
     */
    safe_constraints = NIL;
    foreach(lc, constraint_pred)
    {
-       Node *pred = (Node *) lfirst(lc);
+       Node       *pred = (Node *) lfirst(lc);
 
        if (!contain_mutable_functions(pred))
            safe_constraints = lappend(safe_constraints, pred);
@@ -526,9 +526,9 @@ relation_excluded_by_constraints(RelOptInfo *rel, RangeTblEntry *rte)
     * refute the entire collection at once.  This may allow us to make proofs
     * that would fail if we took them individually.
     *
-    * Note: we use rel->baserestrictinfo, not safe_restrictions as might
-    * seem an obvious optimization.  Some of the clauses might be OR clauses
-    * that have volatile and nonvolatile subclauses, and it's OK to make
+    * Note: we use rel->baserestrictinfo, not safe_restrictions as might seem
+    * an obvious optimization.  Some of the clauses might be OR clauses that
+    * have volatile and nonvolatile subclauses, and it's OK to make
     * deductions with the nonvolatile parts.
     */
    if (predicate_refuted_by(safe_constraints, rel->baserestrictinfo))
index b909e6d4bf26d50f93b8889b6178e4938a56f626..4a2609a4ab6a55d0fcd50b563e6746e4e2c89190 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.9 2006/09/28 20:51:42 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.10 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -208,6 +208,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
            switch (pclass)
            {
                case CLASS_AND:
+
                    /*
                     * AND-clause => AND-clause if A implies each of B's items
                     */
@@ -224,6 +225,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_OR:
+
                    /*
                     * AND-clause => OR-clause if A implies any of B's items
                     *
@@ -241,6 +243,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
                    iterate_end(pred_info);
                    if (result)
                        return result;
+
                    /*
                     * Also check if any of A's items implies B
                     *
@@ -258,6 +261,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_ATOM:
+
                    /*
                     * AND-clause => atom if any of A's items implies B
                     */
@@ -279,6 +283,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
            switch (pclass)
            {
                case CLASS_OR:
+
                    /*
                     * 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.
@@ -286,7 +291,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
                    result = true;
                    iterate_begin(citem, clause, clause_info)
                    {
-                       bool    presult = false;
+                       bool        presult = false;
 
                        iterate_begin(pitem, predicate, pred_info)
                        {
@@ -308,6 +313,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
 
                case CLASS_AND:
                case CLASS_ATOM:
+
                    /*
                     * OR-clause => AND-clause if each of A's items implies B
                     *
@@ -331,6 +337,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
            switch (pclass)
            {
                case CLASS_AND:
+
                    /*
                     * atom => AND-clause if A implies each of B's items
                     */
@@ -347,6 +354,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_OR:
+
                    /*
                     * atom => OR-clause if A implies any of B's items
                     */
@@ -363,6 +371,7 @@ predicate_implied_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_ATOM:
+
                    /*
                     * atom => atom is the base case
                     */
@@ -427,6 +436,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
            switch (pclass)
            {
                case CLASS_AND:
+
                    /*
                     * AND-clause R=> AND-clause if A refutes any of B's items
                     *
@@ -444,6 +454,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    iterate_end(pred_info);
                    if (result)
                        return result;
+
                    /*
                     * Also check if any of A's items refutes B
                     *
@@ -461,6 +472,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_OR:
+
                    /*
                     * AND-clause R=> OR-clause if A refutes each of B's items
                     */
@@ -477,6 +489,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_ATOM:
+
                    /*
                     * If B is a NOT-clause, A R=> B if A => B's arg
                     */
@@ -484,6 +497,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    if (not_arg &&
                        predicate_implied_by_recurse(clause, not_arg))
                        return true;
+
                    /*
                     * AND-clause R=> atom if any of A's items refutes B
                     */
@@ -505,6 +519,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
            switch (pclass)
            {
                case CLASS_OR:
+
                    /*
                     * OR-clause R=> OR-clause if A refutes each of B's items
                     */
@@ -521,6 +536,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_AND:
+
                    /*
                     * OR-clause R=> AND-clause if each of A's items refutes
                     * any of B's items.
@@ -528,7 +544,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    result = true;
                    iterate_begin(citem, clause, clause_info)
                    {
-                       bool    presult = false;
+                       bool        presult = false;
 
                        iterate_begin(pitem, predicate, pred_info)
                        {
@@ -549,6 +565,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_ATOM:
+
                    /*
                     * If B is a NOT-clause, A R=> B if A => B's arg
                     */
@@ -556,6 +573,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    if (not_arg &&
                        predicate_implied_by_recurse(clause, not_arg))
                        return true;
+
                    /*
                     * OR-clause R=> atom if each of A's items refutes B
                     */
@@ -574,6 +592,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
            break;
 
        case CLASS_ATOM:
+
            /*
             * If A is a NOT-clause, A R=> B if B => A's arg
             */
@@ -584,6 +603,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
            switch (pclass)
            {
                case CLASS_AND:
+
                    /*
                     * atom R=> AND-clause if A refutes any of B's items
                     */
@@ -600,6 +620,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_OR:
+
                    /*
                     * atom R=> OR-clause if A refutes each of B's items
                     */
@@ -616,6 +637,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    return result;
 
                case CLASS_ATOM:
+
                    /*
                     * If B is a NOT-clause, A R=> B if A => B's arg
                     */
@@ -623,6 +645,7 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
                    if (not_arg &&
                        predicate_implied_by_recurse(clause, not_arg))
                        return true;
+
                    /*
                     * atom R=> atom is the base case
                     */
@@ -654,8 +677,8 @@ predicate_classify(Node *clause, PredIterInfo info)
    Assert(!IsA(clause, RestrictInfo));
 
    /*
-    * If we see a List, assume it's an implicit-AND list; this is the
-    * correct semantics for lists of RestrictInfo nodes.
+    * If we see a List, assume it's an implicit-AND list; this is the correct
+    * semantics for lists of RestrictInfo nodes.
     */
    if (IsA(clause, List))
    {
@@ -685,13 +708,13 @@ predicate_classify(Node *clause, PredIterInfo info)
    if (IsA(clause, ScalarArrayOpExpr))
    {
        ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) clause;
-       Node   *arraynode = (Node *) lsecond(saop->args);
+       Node       *arraynode = (Node *) lsecond(saop->args);
 
        /*
-        * We can break this down into an AND or OR structure, but only if
-        * we know how to iterate through expressions for the array's
-        * elements.  We can do that if the array operand is a non-null
-        * constant or a simple ArrayExpr.
+        * We can break this down into an AND or OR structure, but only if we
+        * know how to iterate through expressions for the array's elements.
+        * We can do that if the array operand is a non-null constant or a
+        * simple ArrayExpr.
         */
        if (arraynode && IsA(arraynode, Const) &&
            !((Const *) arraynode)->constisnull)
@@ -716,7 +739,7 @@ predicate_classify(Node *clause, PredIterInfo info)
 }
 
 /*
- * PredIterInfo routines for iterating over regular Lists.  The iteration
+ * PredIterInfo routines for iterating over regular Lists. The iteration
  * state variable is the next ListCell to visit.
  */
 static void
@@ -852,7 +875,7 @@ arrayexpr_startup_fn(Node *clause, PredIterInfo info)
 {
    ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) clause;
    ArrayExprIterState *state;
-   ArrayExpr *arrayexpr;
+   ArrayExpr  *arrayexpr;
 
    /* Create working state struct */
    state = (ArrayExprIterState *) palloc(sizeof(ArrayExprIterState));
index 331855f8e9fefcd4012f1de7a5b6f9e1ed9a3fcb..4d5bffdb7b1fed65a26943cd261b095e1e215179 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.82 2006/09/19 22:49:53 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.83 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -97,9 +97,10 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind)
        case RTE_SUBQUERY:
        case RTE_FUNCTION:
        case RTE_VALUES:
+
            /*
-            * Subquery, function, or values list --- set up attr range
-            * and arrays
+            * Subquery, function, or values list --- set up attr range and
+            * arrays
             *
             * Note: 0 is included in range to support whole-row Vars
             */
@@ -417,8 +418,8 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
        int         ndx;
 
        /*
-        * We can't run into any child RowExprs here, but we could find
-        * whole-row Var with a ConvertRowtypeExpr atop it.
+        * We can't run into any child RowExprs here, but we could find a
+        * whole-row Var with a ConvertRowtypeExpr atop it.
         */
        var = origvar;
        while (!IsA(var, Var))
index ec43ee39f0e493d7cd14030450d0f4c21ecc8d63..9176ae1680cb12fcba3fa1a185cc58efb94a8ddd 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.48 2006/07/01 18:38:33 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.49 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -169,14 +169,15 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
                 */
                return NIL;
            }
+
            /*
             * If the sublist contains multiple RestrictInfos, we create an
             * AND subclause.  If there's just one, we have to check if it's
             * an OR clause, and if so flatten it to preserve AND/OR flatness
             * of our output.
             *
-            * We construct lists with and without sub-RestrictInfos, so
-            * as not to have to regenerate duplicate RestrictInfos below.
+            * We construct lists with and without sub-RestrictInfos, so as
+            * not to have to regenerate duplicate RestrictInfos below.
             */
            if (list_length(sublist) > 1)
            {
@@ -186,7 +187,7 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
            }
            else
            {
-               RestrictInfo   *subri = (RestrictInfo *) linitial(sublist);
+               RestrictInfo *subri = (RestrictInfo *) linitial(sublist);
 
                Assert(IsA(subri, RestrictInfo));
                if (restriction_is_or_clause(subri))
index 582747a23f4bb7f996f5a08163e0bfc33d654b41..f4e58a3b8d148b72e638669c5314b29531d3911e 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.351 2006/09/18 16:04:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.352 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -99,7 +99,7 @@ static Query *transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt);
 static Query *transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
                    List **extras_before, List **extras_after);
 static List *transformInsertRow(ParseState *pstate, List *exprlist,
-                         List *stmtcols, List *icolumns, List *attrnos);
+                  List *stmtcols, List *icolumns, List *attrnos);
 static List *transformReturningList(ParseState *pstate, List *returningList);
 static Query *transformIndexStmt(ParseState *pstate, IndexStmt *stmt);
 static Query *transformRuleStmt(ParseState *query, RuleStmt *stmt,
@@ -133,7 +133,7 @@ static void transformFKConstraints(ParseState *pstate,
                       bool isAddConstraint);
 static void applyColumnNames(List *dst, List *src);
 static void getSetColTypes(ParseState *pstate, Node *node,
-                          List **colTypes, List **colTypmods);
+              List **colTypes, List **colTypmods);
 static void transformLockingClause(Query *qry, LockingClause *lc);
 static void transformConstraintAttrs(List *constraintList);
 static void transformColumnType(ParseState *pstate, ColumnDef *column);
@@ -343,7 +343,7 @@ transformStmt(ParseState *pstate, Node *parseTree,
 
        case T_CopyStmt:
            {
-               CopyStmt *n = (CopyStmt *) parseTree;
+               CopyStmt   *n = (CopyStmt *) parseTree;
 
                result = makeNode(Query);
                result->commandType = CMD_UTILITY;
@@ -552,8 +552,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
 
    /*
     * We have three cases to deal with: DEFAULT VALUES (selectStmt == NULL),
-    * VALUES list, or general SELECT input.  We special-case VALUES, both
-    * for efficiency and so we can handle DEFAULT specifications.
+    * VALUES list, or general SELECT input.  We special-case VALUES, both for
+    * efficiency and so we can handle DEFAULT specifications.
     */
    isGeneralSelect = (selectStmt && selectStmt->valuesLists == NIL);
 
@@ -602,8 +602,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
    {
        /*
         * We have INSERT ... DEFAULT VALUES.  We can handle this case by
-        * emitting an empty targetlist --- all columns will be defaulted
-        * when the planner expands the targetlist.
+        * emitting an empty targetlist --- all columns will be defaulted when
+        * the planner expands the targetlist.
         */
        exprList = NIL;
    }
@@ -705,25 +705,25 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
    else if (list_length(selectStmt->valuesLists) > 1)
    {
        /*
-        * Process INSERT ... VALUES with multiple VALUES sublists.
-        * We generate a VALUES RTE holding the transformed expression
-        * lists, and build up a targetlist containing Vars that reference
-        * the VALUES RTE.
+        * Process INSERT ... VALUES with multiple VALUES sublists. We
+        * generate a VALUES RTE holding the transformed expression lists, and
+        * build up a targetlist containing Vars that reference the VALUES
+        * RTE.
         */
        List       *exprsLists = NIL;
        int         sublist_length = -1;
 
        foreach(lc, selectStmt->valuesLists)
        {
-           List   *sublist = (List *) lfirst(lc);
+           List       *sublist = (List *) lfirst(lc);
 
            /* Do basic expression transformation (same as a ROW() expr) */
            sublist = transformExpressionList(pstate, sublist);
 
            /*
-            * All the sublists must be the same length, *after* transformation
-            * (which might expand '*' into multiple items).  The VALUES RTE
-            * can't handle anything different.
+            * All the sublists must be the same length, *after*
+            * transformation (which might expand '*' into multiple items).
+            * The VALUES RTE can't handle anything different.
             */
            if (sublist_length < 0)
            {
@@ -747,8 +747,8 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
 
        /*
         * There mustn't have been any table references in the expressions,
-        * else strange things would happen, like Cartesian products of
-        * those tables with the VALUES list ...
+        * else strange things would happen, like Cartesian products of those
+        * tables with the VALUES list ...
         */
        if (pstate->p_joinlist != NIL)
            ereport(ERROR,
@@ -756,10 +756,10 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
                     errmsg("VALUES must not contain table references")));
 
        /*
-        * Another thing we can't currently support is NEW/OLD references
-        * in rules --- seems we'd need something like SQL99's LATERAL
-        * construct to ensure that the values would be available while
-        * evaluating the VALUES RTE.  This is a shame.  FIXME
+        * Another thing we can't currently support is NEW/OLD references in
+        * rules --- seems we'd need something like SQL99's LATERAL construct
+        * to ensure that the values would be available while evaluating the
+        * VALUES RTE.  This is a shame.  FIXME
         */
        if (list_length(pstate->p_rtable) != 1 &&
            contain_vars_of_level((Node *) exprsLists, 0))
@@ -793,7 +793,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
         *          INSERT INTO foo VALUES(bar.*)
         *
         * The sublist is just computed directly as the Query's targetlist,
-        * with no VALUES RTE.  So it works just like SELECT without FROM.
+        * with no VALUES RTE.  So it works just like SELECT without FROM.
         *----------
         */
        List       *valuesLists = selectStmt->valuesLists;
@@ -818,7 +818,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
    attnos = list_head(attrnos);
    foreach(lc, exprList)
    {
-       Expr *expr = (Expr *) lfirst(lc);
+       Expr       *expr = (Expr *) lfirst(lc);
        ResTarget  *col;
        TargetEntry *tle;
 
@@ -836,10 +836,10 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
    }
 
    /*
-    * If we have a RETURNING clause, we need to add the target relation
-    * to the query namespace before processing it, so that Var references
-    * in RETURNING will work.  Also, remove any namespace entries added
-    * in a sub-SELECT or VALUES list.
+    * If we have a RETURNING clause, we need to add the target relation to
+    * the query namespace before processing it, so that Var references in
+    * RETURNING will work.  Also, remove any namespace entries added in a
+    * sub-SELECT or VALUES list.
     */
    if (stmt->returningList)
    {
@@ -875,7 +875,7 @@ static List *
 transformInsertRow(ParseState *pstate, List *exprlist,
                   List *stmtcols, List *icolumns, List *attrnos)
 {
-   List   *result;
+   List       *result;
    ListCell   *lc;
    ListCell   *icols;
    ListCell   *attnos;
@@ -884,7 +884,7 @@ transformInsertRow(ParseState *pstate, List *exprlist,
     * Check length of expr list.  It must not have more expressions than
     * there are target columns.  We allow fewer, but only if no explicit
     * columns list was given (the remaining columns are implicitly
-    * defaulted).  Note we must check this *after* transformation because
+    * defaulted).  Note we must check this *after* transformation because
     * that could expand '*' into multiple items.
     */
    if (list_length(exprlist) > list_length(icolumns))
@@ -905,7 +905,7 @@ transformInsertRow(ParseState *pstate, List *exprlist,
    attnos = list_head(attrnos);
    foreach(lc, exprlist)
    {
-       Expr *expr = (Expr *) lfirst(lc);
+       Expr       *expr = (Expr *) lfirst(lc);
        ResTarget  *col;
 
        col = (ResTarget *) lfirst(icols);
@@ -1292,10 +1292,10 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
    TupleConstr *constr;
    AclResult   aclresult;
 
-   bool including_defaults = false;
-   bool including_constraints = false;
-   bool including_indexes = false;
-   ListCell *elem;
+   bool        including_defaults = false;
+   bool        including_constraints = false;
+   bool        including_indexes = false;
+   ListCell   *elem;
 
    relation = heap_openrv(inhRelation->relation, AccessShareLock);
 
@@ -1318,32 +1318,33 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
    constr = tupleDesc->constr;
 
    foreach(elem, inhRelation->options)
+   {
+       int         option = lfirst_int(elem);
+
+       switch (option)
        {
-           int option = lfirst_int(elem);
-           switch (option)
-           {
-               case CREATE_TABLE_LIKE_INCLUDING_DEFAULTS:
-                   including_defaults = true;
-                   break;
-               case CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS:
-                   including_defaults = false;
-                   break;
-               case CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS:
-                   including_constraints = true;
-                   break;
-               case CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS:
-                   including_constraints = false;
-                   break;
-               case CREATE_TABLE_LIKE_INCLUDING_INDEXES:
-                   including_indexes = true;
-                   break;
-               case CREATE_TABLE_LIKE_EXCLUDING_INDEXES:
-                   including_indexes = false;
-                   break;
-               default:
-                   elog(ERROR, "unrecognized CREATE TABLE LIKE option: %d", option);
-           }
+           case CREATE_TABLE_LIKE_INCLUDING_DEFAULTS:
+               including_defaults = true;
+               break;
+           case CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS:
+               including_defaults = false;
+               break;
+           case CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS:
+               including_constraints = true;
+               break;
+           case CREATE_TABLE_LIKE_EXCLUDING_CONSTRAINTS:
+               including_constraints = false;
+               break;
+           case CREATE_TABLE_LIKE_INCLUDING_INDEXES:
+               including_indexes = true;
+               break;
+           case CREATE_TABLE_LIKE_EXCLUDING_INDEXES:
+               including_indexes = false;
+               break;
+           default:
+               elog(ERROR, "unrecognized CREATE TABLE LIKE option: %d", option);
        }
+   }
 
    if (including_indexes)
        elog(ERROR, "TODO");
@@ -1418,14 +1419,16 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
        }
    }
 
-   if (including_constraints && tupleDesc->constr) {
-       int ccnum;
+   if (including_constraints && tupleDesc->constr)
+   {
+       int         ccnum;
        AttrNumber *attmap = varattnos_map_schema(tupleDesc, cxt->columns);
 
-       for(ccnum = 0; ccnum < tupleDesc->constr->num_check; ccnum++) {
-           char *ccname = tupleDesc->constr->check[ccnum].ccname;
-           char *ccbin = tupleDesc->constr->check[ccnum].ccbin;
-           Node *ccbin_node = stringToNode(ccbin);
+       for (ccnum = 0; ccnum < tupleDesc->constr->num_check; ccnum++)
+       {
+           char       *ccname = tupleDesc->constr->check[ccnum].ccname;
+           char       *ccbin = tupleDesc->constr->check[ccnum].ccbin;
+           Node       *ccbin_node = stringToNode(ccbin);
            Constraint *n = makeNode(Constraint);
 
            change_varattnos_of_a_node(ccbin_node, attmap);
@@ -1435,7 +1438,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
            n->raw_expr = ccbin_node;
            n->cooked_expr = NULL;
            n->indexspace = NULL;
-           cxt->ckconstraints = lappend(cxt->ckconstraints, (Node*)n);
+           cxt->ckconstraints = lappend(cxt->ckconstraints, (Node *) n);
        }
    }
 
@@ -1888,7 +1891,7 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
    if (pstate->p_hasAggs)
        ereport(ERROR,
                (errcode(ERRCODE_GROUPING_ERROR),
-       errmsg("cannot use aggregate function in rule WHERE condition")));
+          errmsg("cannot use aggregate function in rule WHERE condition")));
 
    /* save info about sublinks in where clause */
    qry->hasSubLinks = pstate->p_hasSubLinks;
@@ -2175,8 +2178,8 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
    RangeTblEntry *rte;
    RangeTblRef *rtr;
    ListCell   *lc;
-   ListCell *lc2;
-   int i;
+   ListCell   *lc2;
+   int         i;
 
    qry->commandType = CMD_SELECT;
 
@@ -2190,21 +2193,21 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
    Assert(stmt->op == SETOP_NONE);
 
    /*
-    * For each row of VALUES, transform the raw expressions and gather
-    * type information.  This is also a handy place to reject DEFAULT
-    * nodes, which the grammar allows for simplicity.
+    * For each row of VALUES, transform the raw expressions and gather type
+    * information.  This is also a handy place to reject DEFAULT nodes, which
+    * the grammar allows for simplicity.
     */
    foreach(lc, stmt->valuesLists)
    {
-       List   *sublist = (List *) lfirst(lc);
+       List       *sublist = (List *) lfirst(lc);
 
        /* Do basic expression transformation (same as a ROW() expr) */
        sublist = transformExpressionList(pstate, sublist);
 
        /*
         * All the sublists must be the same length, *after* transformation
-        * (which might expand '*' into multiple items).  The VALUES RTE
-        * can't handle anything different.
+        * (which might expand '*' into multiple items).  The VALUES RTE can't
+        * handle anything different.
         */
        if (sublist_length < 0)
        {
@@ -2226,7 +2229,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
        i = 0;
        foreach(lc2, sublist)
        {
-           Node  *col = (Node *) lfirst(lc2);
+           Node       *col = (Node *) lfirst(lc2);
 
            if (IsA(col, SetToDefault))
                ereport(ERROR,
@@ -2238,8 +2241,8 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
    }
 
    /*
-    * Now resolve the common types of the columns, and coerce everything
-    * to those types.
+    * Now resolve the common types of the columns, and coerce everything to
+    * those types.
     */
    for (i = 0; i < sublist_length; i++)
    {
@@ -2249,13 +2252,13 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
    newExprsLists = NIL;
    foreach(lc, exprsLists)
    {
-       List   *sublist = (List *) lfirst(lc);
-       List   *newsublist = NIL;
+       List       *sublist = (List *) lfirst(lc);
+       List       *newsublist = NIL;
 
        i = 0;
        foreach(lc2, sublist)
        {
-           Node  *col = (Node *) lfirst(lc2);
+           Node       *col = (Node *) lfirst(lc2);
 
            col = coerce_to_common_type(pstate, col, coltypes[i], "VALUES");
            newsublist = lappend(newsublist, col);
@@ -2283,8 +2286,8 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
    qry->targetList = expandRelAttrs(pstate, rte, rtr->rtindex, 0);
 
    /*
-    * The grammar allows attaching ORDER BY, LIMIT, and FOR UPDATE
-    * to a VALUES, so cope.
+    * The grammar allows attaching ORDER BY, LIMIT, and FOR UPDATE to a
+    * VALUES, so cope.
     */
    qry->sortClause = transformSortClause(pstate,
                                          stmt->sortClause,
@@ -2299,7 +2302,7 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
    if (stmt->lockingClause)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                errmsg("SELECT FOR UPDATE/SHARE cannot be applied to VALUES")));
+            errmsg("SELECT FOR UPDATE/SHARE cannot be applied to VALUES")));
 
    /* handle any CREATE TABLE AS spec */
    if (stmt->into)
@@ -2313,10 +2316,10 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
    }
 
    /*
-    * There mustn't have been any table references in the expressions,
-    * else strange things would happen, like Cartesian products of
-    * those tables with the VALUES list.  We have to check this after
-    * parsing ORDER BY et al since those could insert more junk.
+    * There mustn't have been any table references in the expressions, else
+    * strange things would happen, like Cartesian products of those tables
+    * with the VALUES list.  We have to check this after parsing ORDER BY et
+    * al since those could insert more junk.
     */
    if (list_length(pstate->p_joinlist) != 1)
        ereport(ERROR,
@@ -2324,10 +2327,10 @@ transformValuesClause(ParseState *pstate, SelectStmt *stmt)
                 errmsg("VALUES must not contain table references")));
 
    /*
-    * Another thing we can't currently support is NEW/OLD references
-    * in rules --- seems we'd need something like SQL99's LATERAL
-    * construct to ensure that the values would be available while
-    * evaluating the VALUES RTE.  This is a shame.  FIXME
+    * Another thing we can't currently support is NEW/OLD references in rules
+    * --- seems we'd need something like SQL99's LATERAL construct to ensure
+    * that the values would be available while evaluating the VALUES RTE.
+    * This is a shame.  FIXME
     */
    if (list_length(pstate->p_rtable) != 1 &&
        contain_vars_of_level((Node *) newExprsLists, 0))
@@ -2390,8 +2393,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
    /*
     * Find leftmost leaf SelectStmt; extract the one-time-only items from it
     * and from the top-level node.  (Most of the INTO options can be
-    * transferred to the Query immediately, but intoColNames has to be
-    * saved to apply below.)
+    * transferred to the Query immediately, but intoColNames has to be saved
+    * to apply below.)
     */
    leftmostSelect = stmt->larg;
    while (leftmostSelect && leftmostSelect->op != SETOP_NONE)
@@ -2865,9 +2868,9 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
    qry->hasSubLinks = pstate->p_hasSubLinks;
 
    /*
-    * Top-level aggregates are simply disallowed in UPDATE, per spec.
-    * (From an implementation point of view, this is forced because the
-    * implicit ctid reference would otherwise be an ungrouped variable.)
+    * Top-level aggregates are simply disallowed in UPDATE, per spec. (From
+    * an implementation point of view, this is forced because the implicit
+    * ctid reference would otherwise be an ungrouped variable.)
     */
    if (pstate->p_hasAggs)
        ereport(ERROR,
@@ -2890,7 +2893,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
    {
        TargetEntry *tle = (TargetEntry *) lfirst(tl);
        ResTarget  *origTarget;
-       int     attrno;
+       int         attrno;
 
        if (tle->resjunk)
        {
@@ -2916,7 +2919,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
                    (errcode(ERRCODE_UNDEFINED_COLUMN),
                     errmsg("column \"%s\" of relation \"%s\" does not exist",
                            origTarget->name,
-                           RelationGetRelationName(pstate->p_target_relation)),
+                        RelationGetRelationName(pstate->p_target_relation)),
                     parser_errposition(pstate, origTarget->location)));
 
        updateTargetListEntry(pstate, tle, origTarget->name,
@@ -2948,9 +2951,9 @@ transformReturningList(ParseState *pstate, List *returningList)
        return NIL;             /* nothing to do */
 
    /*
-    * We need to assign resnos starting at one in the RETURNING list.
-    * Save and restore the main tlist's value of p_next_resno, just in
-    * case someone looks at it later (probably won't happen).
+    * We need to assign resnos starting at one in the RETURNING list. Save
+    * and restore the main tlist's value of p_next_resno, just in case
+    * someone looks at it later (probably won't happen).
     */
    save_next_resno = pstate->p_next_resno;
    pstate->p_next_resno = 1;
@@ -2975,7 +2978,7 @@ transformReturningList(ParseState *pstate, List *returningList)
    if (list_length(pstate->p_rtable) != length_rtable)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                errmsg("RETURNING may not contain references to other relations")));
+        errmsg("RETURNING may not contain references to other relations")));
 
    /* mark column origins */
    markTargetListOrigins(pstate, rlist);
@@ -3204,7 +3207,7 @@ static Query *
 transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
 {
    Query      *result = makeNode(Query);
-   List       *argtype_oids;       /* argtype OIDs in a list */
+   List       *argtype_oids;   /* argtype OIDs in a list */
    Oid        *argtoids = NULL;    /* and as an array */
    int         nargs;
    List       *queries;
@@ -3233,10 +3236,9 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
    }
 
    /*
-    * Analyze the statement using these parameter types (any
-    * parameters passed in from above us will not be visible to it),
-    * allowing information about unknown parameters to be deduced
-    * from context.
+    * Analyze the statement using these parameter types (any parameters
+    * passed in from above us will not be visible to it), allowing
+    * information about unknown parameters to be deduced from context.
     */
    queries = parse_analyze_varparams((Node *) stmt->query,
                                      pstate->p_sourcetext,
@@ -3250,8 +3252,8 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
        elog(ERROR, "unexpected extra stuff in prepared statement");
 
    /*
-    * Check that all parameter types were determined, and convert the
-    * array of OIDs into a list for storage.
+    * Check that all parameter types were determined, and convert the array
+    * of OIDs into a list for storage.
     */
    argtype_oids = NIL;
    for (i = 0; i < nargs; i++)
@@ -3360,7 +3362,7 @@ CheckSelectLocking(Query *qry)
    if (qry->havingQual != NULL)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                errmsg("SELECT FOR UPDATE/SHARE is not allowed with HAVING clause")));
+       errmsg("SELECT FOR UPDATE/SHARE is not allowed with HAVING clause")));
    if (qry->hasAggs)
        ereport(ERROR,
                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -3500,15 +3502,15 @@ applyLockingClause(Query *qry, Index rtindex, bool forUpdate, bool noWait)
    if ((rc = get_rowmark(qry, rtindex)) != NULL)
    {
        /*
-        * If the same RTE is specified both FOR UPDATE and FOR SHARE,
-        * treat it as FOR UPDATE.  (Reasonable, since you can't take
-        * both a shared and exclusive lock at the same time; it'll
-        * end up being exclusive anyway.)
+        * If the same RTE is specified both FOR UPDATE and FOR SHARE, treat
+        * it as FOR UPDATE.  (Reasonable, since you can't take both a shared
+        * and exclusive lock at the same time; it'll end up being exclusive
+        * anyway.)
         *
-        * We also consider that NOWAIT wins if it's specified both ways.
-        * This is a bit more debatable but raising an error doesn't
-        * seem helpful.  (Consider for instance SELECT FOR UPDATE NOWAIT
-        * from a view that internally contains a plain FOR UPDATE spec.)
+        * We also consider that NOWAIT wins if it's specified both ways. This
+        * is a bit more debatable but raising an error doesn't seem helpful.
+        * (Consider for instance SELECT FOR UPDATE NOWAIT from a view that
+        * internally contains a plain FOR UPDATE spec.)
         */
        rc->forUpdate |= forUpdate;
        rc->noWait |= noWait;
index 70b6946d5fa78a8cbeced4049b72f8da5bc513e4..be584b514c6d42dcc6e62e332b0b2eeeb3aa85ca 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.157 2006/08/14 23:39:32 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.158 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -544,8 +544,8 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
    /*
     * If a coldeflist was supplied, ensure it defines a legal set of names
     * (no duplicates) and datatypes (no pseudo-types, for instance).
-    * addRangeTableEntryForFunction looked up the type names but didn't
-    * check them further than that.
+    * addRangeTableEntryForFunction looked up the type names but didn't check
+    * them further than that.
     */
    if (r->coldeflist)
    {
@@ -1338,10 +1338,10 @@ transformGroupClause(ParseState *pstate, List *grouplist,
    ListCell   *l;
 
    /* Preprocess the grouping clause, lookup TLEs */
-   foreach (l, grouplist)
+   foreach(l, grouplist)
    {
        TargetEntry *tle;
-       Oid          restype;
+       Oid         restype;
 
        tle = findTargetlistEntry(pstate, lfirst(l),
                                  targetlist, GROUP_CLAUSE);
@@ -1359,21 +1359,20 @@ transformGroupClause(ParseState *pstate, List *grouplist,
    }
 
    /*
-    * Now iterate through the ORDER BY clause. If we find a grouping
-    * element that matches the ORDER BY element, append the grouping
-    * element to the result set immediately. Otherwise, stop
-    * iterating. The effect of this is to look for a prefix of the
-    * ORDER BY list in the grouping clauses, and to move that prefix
-    * to the front of the GROUP BY.
+    * Now iterate through the ORDER BY clause. If we find a grouping element
+    * that matches the ORDER BY element, append the grouping element to the
+    * result set immediately. Otherwise, stop iterating. The effect of this
+    * is to look for a prefix of the ORDER BY list in the grouping clauses,
+    * and to move that prefix to the front of the GROUP BY.
     */
-   foreach (l, sortClause)
+   foreach(l, sortClause)
    {
-       SortClause  *sc = (SortClause *) lfirst(l);
-       ListCell    *prev = NULL;
-       ListCell    *tl;
-       bool         found = false;
+       SortClause *sc = (SortClause *) lfirst(l);
+       ListCell   *prev = NULL;
+       ListCell   *tl;
+       bool        found = false;
 
-       foreach (tl, tle_list)
+       foreach(tl, tle_list)
        {
            TargetEntry *tle = (TargetEntry *) lfirst(tl);
 
@@ -1399,17 +1398,17 @@ transformGroupClause(ParseState *pstate, List *grouplist,
    }
 
    /*
-    * Now add any remaining elements of the GROUP BY list in the
-    * order we received them.
+    * Now add any remaining elements of the GROUP BY list in the order we
+    * received them.
     *
-    * XXX: are there any additional criteria to consider when
-    * ordering grouping clauses?
+    * XXX: are there any additional criteria to consider when ordering
+    * grouping clauses?
     */
    foreach(l, tle_list)
    {
        TargetEntry *tle = (TargetEntry *) lfirst(l);
        GroupClause *gc;
-       Oid          sort_op;
+       Oid         sort_op;
 
        /* avoid making duplicate grouplist entries */
        if (targetIsInSortList(tle, result))
index 010c704c689d7ec81e7b95a03206972d97b97793..9cfe4391bdc88846d859e7b8ed23381b48f43d38 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.143 2006/07/26 19:31:51 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.144 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -163,11 +163,11 @@ coerce_type(ParseState *pstate, Node *node,
 
        /*
         * If the target type is a domain, we want to call its base type's
-        * input routine, not domain_in().  This is to avoid premature
-        * failure when the domain applies a typmod: existing input
-        * routines follow implicit-coercion semantics for length checks,
-        * which is not always what we want here.  The needed check will
-        * be applied properly inside coerce_to_domain().
+        * input routine, not domain_in().  This is to avoid premature failure
+        * when the domain applies a typmod: existing input routines follow
+        * implicit-coercion semantics for length checks, which is not always
+        * what we want here.  The needed check will be applied properly
+        * inside coerce_to_domain().
         */
        baseTypeMod = -1;
        baseTypeId = getBaseTypeAndTypmod(targetTypeId, &baseTypeMod);
@@ -180,13 +180,13 @@ coerce_type(ParseState *pstate, Node *node,
        newcon->constisnull = con->constisnull;
 
        /*
-        * 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.
+        * 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.
         *
-        * We assume here that UNKNOWN's internal representation is the
-        * same as CSTRING.
+        * We assume here that UNKNOWN's internal representation is the same
+        * as CSTRING.
         */
        if (!con->constisnull)
            newcon->constvalue = stringTypeDatum(targetType,
@@ -886,8 +886,8 @@ coerce_to_bigint(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 bigint, not type %s",
-                         constructName, format_type_be(inputTypeId))));
+                    errmsg("argument of %s must be type bigint, not type %s",
+                           constructName, format_type_be(inputTypeId))));
    }
 
    if (expression_returns_set(node))
index 0812c3d441848307ee8193ce39186c61346b9042..7c72ae9e22a7ba4ccca28719e1e10bbae3a83667 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.197 2006/08/12 20:05:55 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.198 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -65,7 +65,7 @@ static Node *transformIndirection(ParseState *pstate, Node *basenode,
 static Node *typecast_expression(ParseState *pstate, Node *expr,
                    TypeName *typename);
 static Node *make_row_comparison_op(ParseState *pstate, List *opname,
-                                   List *largs, List *rargs, int location);
+                      List *largs, List *rargs, int location);
 static Node *make_row_distinct_op(ParseState *pstate, List *opname,
                     RowExpr *lrow, RowExpr *rrow, int location);
 static Expr *make_distinct_op(ParseState *pstate, List *opname,
@@ -772,8 +772,8 @@ static Node *
 transformAExprOf(ParseState *pstate, A_Expr *a)
 {
    /*
-    * Checking an expression for match to a list of type names.
-    * Will result in a boolean constant node.
+    * Checking an expression for match to a list of type names. Will result
+    * in a boolean constant node.
     */
    Node       *lexpr = transformExpr(pstate, a->lexpr);
    ListCell   *telem;
@@ -791,7 +791,7 @@ transformAExprOf(ParseState *pstate, A_Expr *a)
    }
 
    /*
-    * We have two forms: equals or not equals. Flip the sense of the result
+    * We have two forms: equals or not equals. Flip the sense of the result
     * for not equals.
     */
    if (strcmp(strVal(linitial(a->name)), "<>") == 0)
@@ -820,10 +820,10 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
        useOr = true;
 
    /*
-    * We try to generate a ScalarArrayOpExpr from IN/NOT IN, but this is
-    * only possible if the inputs are all scalars (no RowExprs) and there
-    * is a suitable array type available.  If not, we fall back to a
-    * boolean condition tree with multiple copies of the lefthand expression.
+    * We try to generate a ScalarArrayOpExpr from IN/NOT IN, but this is only
+    * possible if the inputs are all scalars (no RowExprs) and there is a
+    * suitable array type available.  If not, we fall back to a boolean
+    * condition tree with multiple copies of the lefthand expression.
     *
     * First step: transform all the inputs, and detect whether any are
     * RowExprs.
@@ -834,7 +834,7 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
    rexprs = NIL;
    foreach(l, (List *) a->rexpr)
    {
-       Node   *rexpr = transformExpr(pstate, lfirst(l));
+       Node       *rexpr = transformExpr(pstate, lfirst(l));
 
        haveRowExpr |= (rexpr && IsA(rexpr, RowExpr));
        rexprs = lappend(rexprs, rexpr);
@@ -842,10 +842,10 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
    }
 
    /*
-    * If not forced by presence of RowExpr, try to resolve a common
-    * scalar type for all the expressions, and see if it has an array type.
-    * (But if there's only one righthand expression, we may as well just
-    * fall through and generate a simple = comparison.)
+    * If not forced by presence of RowExpr, try to resolve a common scalar
+    * type for all the expressions, and see if it has an array type. (But if
+    * there's only one righthand expression, we may as well just fall through
+    * and generate a simple = comparison.)
     */
    if (!haveRowExpr && list_length(rexprs) != 1)
    {
@@ -853,9 +853,9 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
        Oid         array_type;
 
        /*
-        * Select a common type for the array elements.  Note that since
-        * the LHS' type is first in the list, it will be preferred when
-        * there is doubt (eg, when all the RHS items are unknown literals).
+        * Select a common type for the array elements.  Note that since the
+        * LHS' type is first in the list, it will be preferred when there is
+        * doubt (eg, when all the RHS items are unknown literals).
         */
        scalar_type = select_common_type(typeids, "IN");
 
@@ -864,8 +864,8 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
        if (array_type != InvalidOid)
        {
            /*
-            * OK: coerce all the right-hand inputs to the common type
-            * and build an ArrayExpr for them.
+            * OK: coerce all the right-hand inputs to the common type and
+            * build an ArrayExpr for them.
             */
            List       *aexprs;
            ArrayExpr  *newa;
@@ -910,11 +910,11 @@ transformAExprIn(ParseState *pstate, A_Expr *a)
                !IsA(rexpr, RowExpr))
                ereport(ERROR,
                        (errcode(ERRCODE_SYNTAX_ERROR),
-                        errmsg("arguments of row IN must all be row expressions"),
+                  errmsg("arguments of row IN must all be row expressions"),
                         parser_errposition(pstate, a->location)));
            cmp = make_row_comparison_op(pstate,
                                         a->name,
-                                        (List *) copyObject(((RowExpr *) lexpr)->args),
+                             (List *) copyObject(((RowExpr *) lexpr)->args),
                                         ((RowExpr *) rexpr)->args,
                                         a->location);
        }
@@ -1111,8 +1111,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
    if (sublink->subLinkType == EXISTS_SUBLINK)
    {
        /*
-        * EXISTS needs no test expression or combining operator.
-        * These fields should be null already, but make sure.
+        * EXISTS needs no test expression or combining operator. These fields
+        * should be null already, but make sure.
         */
        sublink->testexpr = NULL;
        sublink->operName = NIL;
@@ -1140,8 +1140,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
        }
 
        /*
-        * EXPR and ARRAY need no test expression or combining operator.
-        * These fields should be null already, but make sure.
+        * EXPR and ARRAY need no test expression or combining operator. These
+        * fields should be null already, but make sure.
         */
        sublink->testexpr = NULL;
        sublink->operName = NIL;
@@ -1164,8 +1164,8 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
            left_list = list_make1(lefthand);
 
        /*
-        * Build a list of PARAM_SUBLINK nodes representing the
-        * output columns of the subquery.
+        * Build a list of PARAM_SUBLINK nodes representing the output columns
+        * of the subquery.
         */
        right_list = NIL;
        foreach(l, qtree->targetList)
@@ -1185,9 +1185,9 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
        }
 
        /*
-        * We could rely on make_row_comparison_op to complain if the
-        * list lengths differ, but we prefer to generate a more specific
-        * error message.
+        * We could rely on make_row_comparison_op to complain if the list
+        * lengths differ, but we prefer to generate a more specific error
+        * message.
         */
        if (list_length(left_list) < list_length(right_list))
            ereport(ERROR,
@@ -1968,8 +1968,8 @@ make_row_comparison_op(ParseState *pstate, List *opname,
                 parser_errposition(pstate, location)));
 
    /*
-    * We can't compare zero-length rows because there is no principled
-    * basis for figuring out what the operator is.
+    * We can't compare zero-length rows because there is no principled basis
+    * for figuring out what the operator is.
     */
    if (nopers == 0)
        ereport(ERROR,
@@ -1978,8 +1978,8 @@ make_row_comparison_op(ParseState *pstate, List *opname,
                 parser_errposition(pstate, location)));
 
    /*
-    * Identify all the pairwise operators, using make_op so that
-    * behavior is the same as in the simple scalar case.
+    * Identify all the pairwise operators, using make_op so that behavior is
+    * the same as in the simple scalar case.
     */
    opexprs = NIL;
    forboth(l, largs, r, rargs)
@@ -1999,9 +1999,9 @@ make_row_comparison_op(ParseState *pstate, List *opname,
        if (cmp->opresulttype != BOOLOID)
            ereport(ERROR,
                    (errcode(ERRCODE_DATATYPE_MISMATCH),
-                    errmsg("row comparison operator must yield type boolean, "
-                           "not type %s",
-                           format_type_be(cmp->opresulttype)),
+                  errmsg("row comparison operator must yield type boolean, "
+                         "not type %s",
+                         format_type_be(cmp->opresulttype)),
                     parser_errposition(pstate, location)));
        if (expression_returns_set((Node *) cmp))
            ereport(ERROR,
@@ -2012,16 +2012,16 @@ make_row_comparison_op(ParseState *pstate, List *opname,
    }
 
    /*
-    * If rows are length 1, just return the single operator.  In this
-    * case we don't insist on identifying btree semantics for the operator
-    * (but we still require it to return boolean).
+    * If rows are length 1, just return the single operator.  In this case we
+    * don't insist on identifying btree semantics for the operator (but we
+    * still require it to return boolean).
     */
    if (nopers == 1)
        return (Node *) linitial(opexprs);
 
    /*
     * Now we must determine which row comparison semantics (= <> < <= > >=)
-    * apply to this set of operators.  We look for btree opclasses containing
+    * apply to this set of operators.  We look for btree opclasses containing
     * the operators, and see which interpretations (strategy numbers) exist
     * for each operator.
     */
@@ -2031,14 +2031,15 @@ make_row_comparison_op(ParseState *pstate, List *opname,
    i = 0;
    foreach(l, opexprs)
    {
-       Bitmapset *this_strats;
+       Bitmapset  *this_strats;
        ListCell   *j;
 
        get_op_btree_interpretation(((OpExpr *) lfirst(l))->opno,
                                    &opclass_lists[i], &opstrat_lists[i]);
+
        /*
-        * convert strategy number list to a Bitmapset to make the intersection
-        * calculation easy.
+        * convert strategy number list to a Bitmapset to make the
+        * intersection calculation easy.
         */
        this_strats = NULL;
        foreach(j, opstrat_lists[i])
@@ -2074,21 +2075,21 @@ make_row_comparison_op(ParseState *pstate, List *opname,
                /*
                 * Prefer the interpretation with the most default opclasses.
                 */
-               int     best_defaults = 0;
-               bool    multiple_best = false;
-               int     this_rctype;
+               int         best_defaults = 0;
+               bool        multiple_best = false;
+               int         this_rctype;
 
                rctype = 0;     /* keep compiler quiet */
                while ((this_rctype = bms_first_member(strats)) >= 0)
                {
-                   int     ndefaults = 0;
+                   int         ndefaults = 0;
 
                    for (i = 0; i < nopers; i++)
                    {
                        forboth(l, opclass_lists[i], r, opstrat_lists[i])
                        {
-                           Oid     opclass = lfirst_oid(l);
-                           int     opstrat = lfirst_int(r);
+                           Oid         opclass = lfirst_oid(l);
+                           int         opstrat = lfirst_int(r);
 
                            if (opstrat == this_rctype &&
                                opclass_is_default(opclass))
@@ -2116,12 +2117,12 @@ make_row_comparison_op(ParseState *pstate, List *opname,
    }
 
    /*
-    * For = and <> cases, we just combine the pairwise operators with
-    * AND or OR respectively.
+    * For = and <> cases, we just combine the pairwise operators with AND or
+    * OR respectively.
     *
     * Note: this is presently the only place where the parser generates
-    * BoolExpr with more than two arguments.  Should be OK since the
-    * rest of the system thinks BoolExpr is N-argument anyway.
+    * BoolExpr with more than two arguments.  Should be OK since the rest of
+    * the system thinks BoolExpr is N-argument anyway.
     */
    if (rctype == ROWCOMPARE_EQ)
        return (Node *) makeBoolExpr(AND_EXPR, opexprs);
@@ -2129,20 +2130,20 @@ make_row_comparison_op(ParseState *pstate, List *opname,
        return (Node *) makeBoolExpr(OR_EXPR, opexprs);
 
    /*
-    * Otherwise we need to determine exactly which opclass to associate
-    * with each operator.
+    * Otherwise we need to determine exactly which opclass to associate with
+    * each operator.
     */
    opclasses = NIL;
    for (i = 0; i < nopers; i++)
    {
-       Oid     best_opclass = 0;
-       int     ndefault = 0;
-       int     nmatch = 0;
+       Oid         best_opclass = 0;
+       int         ndefault = 0;
+       int         nmatch = 0;
 
        forboth(l, opclass_lists[i], r, opstrat_lists[i])
        {
-           Oid     opclass = lfirst_oid(l);
-           int     opstrat = lfirst_int(r);
+           Oid         opclass = lfirst_oid(l);
+           int         opstrat = lfirst_int(r);
 
            if (opstrat == rctype)
            {
@@ -2161,7 +2162,7 @@ make_row_comparison_op(ParseState *pstate, List *opname,
                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                     errmsg("could not determine interpretation of row comparison operator %s",
                            strVal(llast(opname))),
-                    errdetail("There are multiple equally-plausible candidates."),
+              errdetail("There are multiple equally-plausible candidates."),
                     parser_errposition(pstate, location)));
    }
 
@@ -2251,7 +2252,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"),
                 parser_errposition(pstate, location)));
 
    /*
index b1b53164f8091cedd298e9de6b0438ffe8d76a40..a61099766b9a3fcf2ccb29be23cadb5b12fd09ef 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.189 2006/07/27 19:52:05 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.190 2006/10/04 00:29:55 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -36,7 +36,7 @@
 static Node *ParseComplexProjection(ParseState *pstate, char *funcname,
                       Node *first_arg, int location);
 static void unknown_attribute(ParseState *pstate, Node *relref, char *attname,
-                             int location);
+                 int location);
 
 
 /*
@@ -265,13 +265,13 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
 
        /*
         * Reject attempt to call a parameterless aggregate without (*)
-        * syntax.  This is mere pedantry but some folks insisted ...
+        * syntax.  This is mere pedantry but some folks insisted ...
         */
        if (fargs == NIL && !agg_star)
            ereport(ERROR,
                    (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-              errmsg("%s(*) must be used to call a parameterless aggregate function",
-                     NameListToString(funcname)),
+                    errmsg("%s(*) must be used to call a parameterless aggregate function",
+                           NameListToString(funcname)),
                     parser_errposition(pstate, location)));
 
        /* parse_agg.c does additional aggregate-specific processing */
index 9c1b58704e92496adbc5dd708afcbc30f2e7cfd5..8cad187550c834ba96b79f3251971d5e55d197ea 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.94 2006/08/02 01:59:47 joe Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_node.c,v 1.95 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,15 +61,15 @@ make_parsestate(ParseState *parentParseState)
  * is a dummy (always 0, in fact).
  *
  * The locations stored in raw parsetrees are byte offsets into the source
- * string.  We have to convert them to 1-based character indexes for reporting
- * to clients.  (We do things this way to avoid unnecessary overhead in the
+ * string. We have to convert them to 1-based character indexes for reporting
+ * to clients. (We do things this way to avoid unnecessary overhead in the
  * normal non-error case: computing character indexes would be much more
  * expensive than storing token offsets.)
  */
 int
 parser_errposition(ParseState *pstate, int location)
 {
-   int     pos;
+   int         pos;
 
    /* No-op if location was not provided */
    if (location < 0)
index be53472d048194a26cd960b5a5faaaa87123d820..d8ac0d0ff82f002bc45420849368810bd1476647 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.89 2006/07/14 14:52:22 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.90 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -29,7 +29,7 @@
 #include "utils/typcache.h"
 
 
-static Oid binary_oper_exact(List *opname, Oid arg1, Oid arg2);
+static Oid binary_oper_exact(List *opname, Oid arg1, Oid arg2);
 static FuncDetailCode oper_select_candidate(int nargs,
                      Oid *input_typeids,
                      FuncCandidateList candidates,
@@ -37,8 +37,8 @@ static FuncDetailCode oper_select_candidate(int nargs,
 static const char *op_signature_string(List *op, char oprkind,
                    Oid arg1, Oid arg2);
 static void op_error(ParseState *pstate, List *op, char oprkind,
-                    Oid arg1, Oid arg2,
-                    FuncDetailCode fdresult, int location);
+        Oid arg1, Oid arg2,
+        FuncDetailCode fdresult, int location);
 static Expr *make_op_expr(ParseState *pstate, Operator op,
             Node *ltree, Node *rtree,
             Oid ltypeId, Oid rtypeId);
@@ -701,10 +701,9 @@ left_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
        if (clist != NULL)
        {
            /*
-            * 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;
 
@@ -872,7 +871,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"),
                     parser_errposition(pstate, location)));
    }
 
@@ -902,12 +901,12 @@ 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"),
                 parser_errposition(pstate, location)));
    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"),
                 parser_errposition(pstate, location)));
 
    /*
index e9896be6349ff1aec739f61252220ad000b73e97..75d5a50702a50e24d07914fc19c43e6fa89099e6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.124 2006/08/02 01:59:47 joe Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.125 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,7 +48,7 @@ static void expandTupleDesc(TupleDesc tupdesc, Alias *eref,
                List **colnames, List **colvars);
 static int specialAttNum(const char *attname);
 static void warnAutoRange(ParseState *pstate, RangeVar *relation,
-                         int location);
+             int location);
 
 
 /*
@@ -970,7 +970,7 @@ addRangeTableEntryForValues(ParseState *pstate,
    numaliases = list_length(eref->colnames);
    while (numaliases < numcolumns)
    {
-       char    attrname[64];
+       char        attrname[64];
 
        numaliases++;
        snprintf(attrname, sizeof(attrname), "column%d", numaliases);
@@ -1146,6 +1146,7 @@ addImplicitRTE(ParseState *pstate, RangeVar *relation, int location)
 
    /* issue warning or error as needed */
    warnAutoRange(pstate, relation, location);
+
    /*
     * Note that we set inFromCl true, so that the RTE will be listed
     * explicitly if the parsetree is ever decompiled by ruleutils.c. This
@@ -1311,7 +1312,7 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
                varattno = 0;
                foreach(lc, (List *) linitial(rte->values_lists))
                {
-                   Node *col = (Node *) lfirst(lc);
+                   Node       *col = (Node *) lfirst(lc);
 
                    varattno++;
                    if (colnames)
@@ -1676,13 +1677,13 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
        case RTE_VALUES:
            {
                /* Values RTE --- get type info from first sublist */
-               List   *collist = (List *) linitial(rte->values_lists);
+               List       *collist = (List *) linitial(rte->values_lists);
                Node       *col;
 
                if (attnum < 1 || attnum > list_length(collist))
                    elog(ERROR, "values list %s does not have attribute %d",
                         rte->eref->aliasname, attnum);
-               col = (Node *) list_nth(collist, attnum-1);
+               col = (Node *) list_nth(collist, attnum - 1);
                *vartype = exprType(col);
                *vartypmod = exprTypmod(col);
            }
@@ -1963,15 +1964,15 @@ warnAutoRange(ParseState *pstate, RangeVar *relation, int location)
 
    /*
     * Check to see if there are any potential matches in the query's
-    * rangetable.  This affects the message we provide.
+    * rangetable.  This affects the message we provide.
     */
    rte = searchRangeTable(pstate, relation);
 
    /*
-    * If we found a match that has an alias and the alias is visible in
-    * the namespace, then the problem is probably use of the relation's
-    * real name instead of its alias, ie "SELECT foo.* FROM foo f".
-    * This mistake is common enough to justify a specific hint.
+    * If we found a match that has an alias and the alias is visible in the
+    * namespace, then the problem is probably use of the relation's real name
+    * instead of its alias, ie "SELECT foo.* FROM foo f". This mistake is
+    * common enough to justify a specific hint.
     *
     * If we found a match that doesn't meet those criteria, assume the
     * problem is illegal use of a relation outside its scope, as in the
@@ -1988,11 +1989,11 @@ warnAutoRange(ParseState *pstate, RangeVar *relation, int location)
        if (rte)
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_TABLE),
-                    errmsg("invalid reference to FROM-clause entry for table \"%s\"",
-                           relation->relname),
+           errmsg("invalid reference to FROM-clause entry for table \"%s\"",
+                  relation->relname),
                     (badAlias ?
-                     errhint("Perhaps you meant to reference the table alias \"%s\".",
-                             badAlias) :
+           errhint("Perhaps you meant to reference the table alias \"%s\".",
+                   badAlias) :
                      errhint("There is an entry for table \"%s\", but it cannot be referenced from this part of the query.",
                              rte->eref->aliasname)),
                     parser_errposition(pstate, location)));
@@ -2000,8 +2001,8 @@ warnAutoRange(ParseState *pstate, RangeVar *relation, int location)
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_TABLE),
                     (pstate->parentParseState ?
-                     errmsg("missing FROM-clause entry in subquery for table \"%s\"",
-                            relation->relname) :
+            errmsg("missing FROM-clause entry in subquery for table \"%s\"",
+                   relation->relname) :
                      errmsg("missing FROM-clause entry for table \"%s\"",
                             relation->relname)),
                     parser_errposition(pstate, location)));
@@ -2017,8 +2018,8 @@ warnAutoRange(ParseState *pstate, RangeVar *relation, int location)
                  errmsg("adding missing FROM-clause entry for table \"%s\"",
                         relation->relname)),
                 (badAlias ?
-                 errhint("Perhaps you meant to reference the table alias \"%s\".",
-                         badAlias) :
+           errhint("Perhaps you meant to reference the table alias \"%s\".",
+                   badAlias) :
                  (rte ?
                   errhint("There is an entry for table \"%s\", but it cannot be referenced from this part of the query.",
                           rte->eref->aliasname) : 0)),
index 961e3205432b9ecd03fcd171d9846d0c24ad0930..bb4b065eebb43d9685b26cd72200f34fa6e6156d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.148 2006/08/14 23:39:32 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.149 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -161,7 +161,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
  * This is the identical transformation to transformTargetList, except that
  * the input list elements are bare expressions without ResTarget decoration,
  * and the output elements are likewise just expressions without TargetEntry
- * decoration.  We use this for ROW() and VALUES() constructs.
+ * decoration. We use this for ROW() and VALUES() constructs.
  */
 List *
 transformExpressionList(ParseState *pstate, List *exprlist)
@@ -436,7 +436,7 @@ transformAssignedExpr(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."),
                     parser_errposition(pstate, location)));
    }
 
@@ -446,7 +446,7 @@ transformAssignedExpr(ParseState *pstate,
 
 /*
  * updateTargetListEntry()
- * This is used in UPDATE statements only. It prepares an UPDATE
+ * This is used in UPDATE statements only. It prepares an UPDATE
  * TargetEntry for assignment to a column of the target table.
  * This includes coercing the given value to the target column's type
  * (if necessary), and dealing with any subfield names or subscripts
@@ -687,7 +687,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."),
                     parser_errposition(pstate, location)));
        else
            ereport(ERROR,
@@ -697,7 +697,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."),
                     parser_errposition(pstate, location)));
    }
 
@@ -761,9 +761,9 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
            if (attrno == InvalidAttrNumber)
                ereport(ERROR,
                        (errcode(ERRCODE_UNDEFINED_COLUMN),
-                        errmsg("column \"%s\" of relation \"%s\" does not exist",
-                               name,
-                               RelationGetRelationName(pstate->p_target_relation)),
+                   errmsg("column \"%s\" of relation \"%s\" does not exist",
+                          name,
+                        RelationGetRelationName(pstate->p_target_relation)),
                         parser_errposition(pstate, col->location)));
 
            /*
@@ -825,8 +825,8 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
         *
         * (e.g., SELECT * FROM emp, dept)
         *
-        * Since the grammar only accepts bare '*' at top level of SELECT,
-        * we need not handle the targetlist==false case here.
+        * Since the grammar only accepts bare '*' at top level of SELECT, we
+        * need not handle the targetlist==false case here.
         */
        Assert(targetlist);
 
@@ -898,7 +898,7 @@ ExpandColumnRefStar(ParseState *pstate, ColumnRef *cref,
            return expandRelAttrs(pstate, rte, rtindex, sublevels_up);
        else
        {
-           List    *vars;
+           List       *vars;
 
            expandRTE(rte, rtindex, sublevels_up, false,
                      NULL, &vars);
@@ -1114,8 +1114,8 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
 
            /*
             * This case should not occur: a column of a table or values list
-            * shouldn't have type RECORD.  Fall through and fail
-            * (most likely) at the bottom.
+            * shouldn't have type RECORD.  Fall through and fail (most
+            * likely) at the bottom.
             */
            break;
        case RTE_SUBQUERY:
index 45666d88809f5a1e893a14a6d5a1cc0f35bb8c61..93c7db6b52a8f46a6ffd8c30ef1332d52b2b1651 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.84 2006/09/25 15:17:34 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.85 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -210,7 +210,7 @@ TypeNameListToString(List *typenames)
    initStringInfo(&string);
    foreach(l, typenames)
    {
-       TypeName *typename = (TypeName *) lfirst(l);
+       TypeName   *typename = (TypeName *) lfirst(l);
 
        Assert(IsA(typename, TypeName));
        if (l != list_head(typenames))
@@ -358,7 +358,7 @@ typeTypeRelid(Type typ)
 
 /*
  * Given a type structure and a string, returns the internal representation
- * of that string.  The "string" can be NULL to perform conversion of a NULL
+ * of that string. The "string" can be NULL to perform conversion of a NULL
  * (which might result in failure, if the input function rejects NULLs).
  */
 Datum
index 7f1c926f672277bdcfbceae20e999f437d0d1f48..674d4d497cc7d3d32afa63a0a5e07de6367d3ebd 100644 (file)
@@ -14,7 +14,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.67 2006/07/15 03:35:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.68 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,7 +64,7 @@ raw_parser(const char *str)
  * Intermediate filter between parser and base lexer (base_yylex in scan.l).
  *
  * The filter is needed because in some cases the standard SQL grammar
- * requires more than one token lookahead.  We reduce these cases to one-token
+ * requires more than one token lookahead. We reduce these cases to one-token
  * lookahead by combining tokens here, in order to keep the grammar LALR(1).
  *
  * Using a filter is simpler than trying to recognize multiword tokens
@@ -91,15 +91,16 @@ filtered_base_yylex(void)
    switch (cur_token)
    {
        case WITH:
+
            /*
             * WITH CASCADED, LOCAL, or CHECK must be reduced to one token
             *
-            * XXX an alternative way is to recognize just WITH_TIME and
-            * put the ugliness into the datetime datatype productions
-            * instead of WITH CHECK OPTION.  However that requires promoting
-            * WITH to a fully reserved word.  If we ever have to do that
-            * anyway (perhaps for SQL99 recursive queries), come back and
-            * simplify this code.
+            * XXX an alternative way is to recognize just WITH_TIME and put
+            * the ugliness into the datetime datatype productions instead of
+            * WITH CHECK OPTION.  However that requires promoting WITH to a
+            * fully reserved word.  If we ever have to do that anyway
+            * (perhaps for SQL99 recursive queries), come back and simplify
+            * this code.
             */
            lookahead_token = base_yylex();
            switch (lookahead_token)
index 1b69e32d8e2d8c819d3dd87a458b54678ca519ed..47bb0d9cb855b5f6372eb94903d54efd5011a033 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.12 2006/07/29 19:55:18 adunstan Exp $
+ *   $PostgreSQL: pgsql/src/backend/port/win32/socket.c,v 1.13 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -123,7 +123,7 @@ pgwin32_waitforsinglesocket(SOCKET s, int what)
                (errmsg_internal("Failed to reset socket waiting event: %i", (int) GetLastError())));
 
    /*
-    * make sure we don't multiplex this kernel event object with a different 
+    * make sure we don't multiplex this kernel event object with a different
     * socket from a previous call
     */
 
index 384ca9d4516a4dffe6be0a032026bd74cab22c46..5a764053f8cd65936ea8e8a70bdd7274a82d6e05 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.12 2006/08/09 21:18:13 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.13 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -59,7 +59,7 @@ pg_timer_thread(LPVOID param)
            {
                /* WaitForSingleObjectEx() uses milliseconds, round up */
                waittime = (timerCommArea.value.it_value.tv_usec + 999) / 1000 +
-                          timerCommArea.value.it_value.tv_sec * 1000;
+                   timerCommArea.value.it_value.tv_sec * 1000;
            }
            ResetEvent(timerCommArea.event);
            LeaveCriticalSection(&timerCommArea.crit_sec);
@@ -85,7 +85,7 @@ pg_timer_thread(LPVOID param)
  * to handle the timer setting and notification upon timeout.
  */
 int
-setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
+setitimer(int which, const struct itimerval * value, struct itimerval * ovalue)
 {
    Assert(value != NULL);
    Assert(value->it_interval.tv_sec == 0 && value->it_interval.tv_usec == 0);
index 3af18df634fb9e0e3578e579512440e55f11cfa2..0d99a9a0f5c55263d412512b4461e3d453467a09 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/port/win32_sema.c,v 1.2 2006/07/16 02:44:01 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/port/win32_sema.c,v 1.3 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,9 +32,10 @@ static void ReleaseSemaphores(int code, Datum arg);
  * so the semaphores are automatically freed when the last referencing
  * process exits.
  */
-void PGReserveSemaphores(int maxSemas, int port)
+void
+PGReserveSemaphores(int maxSemas, int port)
 {
-   mySemSet = (HANDLE *)malloc(maxSemas * sizeof(HANDLE));
+   mySemSet = (HANDLE *) malloc(maxSemas * sizeof(HANDLE));
    if (mySemSet == NULL)
        elog(PANIC, "out of memory");
    numSems = 0;
@@ -63,7 +64,8 @@ ReleaseSemaphores(int code, Datum arg)
  *
  * Initialize a PGSemaphore structure to represent a sema with count 1
  */
-void PGSemaphoreCreate(PGSemaphore sema)
+void
+PGSemaphoreCreate(PGSemaphore sema)
 {
    HANDLE      cur_handle;
    SECURITY_ATTRIBUTES sec_attrs;
@@ -89,7 +91,7 @@ void PGSemaphoreCreate(PGSemaphore sema)
    }
    else
        ereport(PANIC,
-               (errmsg("could not create semaphore: error code %d", (int)GetLastError())));
+               (errmsg("could not create semaphore: error code %d", (int) GetLastError())));
 }
 
 /*
@@ -97,7 +99,8 @@ void PGSemaphoreCreate(PGSemaphore sema)
  *
  * Reset a previously-initialized PGSemaphore to have count 0
  */
-void PGSemaphoreReset(PGSemaphore sema)
+void
+PGSemaphoreReset(PGSemaphore sema)
 {
    /*
     * There's no direct API for this in Win32, so we have to ratchet the
@@ -112,7 +115,8 @@ void PGSemaphoreReset(PGSemaphore sema)
  * Lock a semaphore (decrement count), blocking if count would be < 0.
  * Serve the interrupt if interruptOK is true.
  */
-void PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
+void
+PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
 {
    DWORD       ret;
    HANDLE      wh[2];
@@ -156,7 +160,8 @@ void PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
  *
  * Unlock a semaphore (increment count)
  */
-void PGSemaphoreUnlock(PGSemaphore sema)
+void
+PGSemaphoreUnlock(PGSemaphore sema)
 {
    if (!ReleaseSemaphore(*sema, 1, NULL))
        ereport(FATAL,
@@ -168,7 +173,8 @@ void PGSemaphoreUnlock(PGSemaphore sema)
  *
  * Lock a semaphore only if able to do so without blocking
  */
-bool PGSemaphoreTryLock(PGSemaphore sema)
+bool
+PGSemaphoreTryLock(PGSemaphore sema)
 {
    DWORD       ret;
 
@@ -189,7 +195,7 @@ bool PGSemaphoreTryLock(PGSemaphore sema)
    /* Otherwise we are in trouble */
    ereport(FATAL,
            (errmsg("could not try-lock semaphore: error code %d", (int) GetLastError())));
-   
+
    /* keep compiler quiet */
    return false;
 }
index 25a19b2b24b8062ea6d81e5f606f6b9639c49f20..2ba12c2f9e66e71eba65e0f2ece30a9ef3ecd331 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.26 2006/07/31 20:09:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.27 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -269,10 +269,10 @@ AutoVacMain(int argc, char *argv[])
    BaseInit();
 
    /*
-    * Create a per-backend PGPROC struct in shared memory, except in
-    * the EXEC_BACKEND case where this was done in SubPostmasterMain.
-    * We must do this before we can use LWLocks (and in the EXEC_BACKEND
-    * case we already had to do some stuff with LWLocks).
+    * Create a per-backend PGPROC struct in shared memory, except in the
+    * EXEC_BACKEND case where this was done in SubPostmasterMain. We must do
+    * this before we can use LWLocks (and in the EXEC_BACKEND case we already
+    * had to do some stuff with LWLocks).
     */
 #ifndef EXEC_BACKEND
    InitProcess();
@@ -305,9 +305,9 @@ AutoVacMain(int argc, char *argv[])
    PG_SETMASK(&UnBlockSig);
 
    /*
-    * Force zero_damaged_pages OFF in the autovac process, even if it is
-    * set in postgresql.conf.  We don't really want such a dangerous option
-    * being applied non-interactively.
+    * Force zero_damaged_pages OFF in the autovac process, even if it is set
+    * in postgresql.conf.  We don't really want such a dangerous option being
+    * applied non-interactively.
     */
    SetConfigOption("zero_damaged_pages", "false", PGC_SUSET, PGC_S_OVERRIDE);
 
@@ -387,8 +387,8 @@ AutoVacMain(int argc, char *argv[])
            }
 
            /*
-            * Otherwise, skip a database with no pgstat entry; it means it hasn't
-            * seen any activity.
+            * Otherwise, skip a database with no pgstat entry; it means it
+            * hasn't seen any activity.
             */
            tmp->entry = pgstat_fetch_stat_dbentry(tmp->oid);
            if (!tmp->entry)
@@ -409,7 +409,7 @@ AutoVacMain(int argc, char *argv[])
         * backend signalled the postmaster.  Pick up the database with the
         * greatest age, and apply a database-wide vacuum on it.
         */
-       int32           oldest = 0;
+       int32       oldest = 0;
 
        whole_db = true;
        foreach(cell, dblist)
@@ -535,7 +535,7 @@ process_whole_db(void)
    /* Start a transaction so our commands have one to play into. */
    StartTransactionCommand();
 
-    /* functions in indexes may want a snapshot set */
+   /* functions in indexes may want a snapshot set */
    ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
 
    /*
@@ -593,13 +593,13 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
    /* Start a transaction so our commands have one to play into. */
    StartTransactionCommand();
 
-    /* functions in indexes may want a snapshot set */
+   /* functions in indexes may want a snapshot set */
    ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
 
    /*
-    * Clean up any dead statistics collector entries for this DB.
-    * We always want to do this exactly once per DB-processing cycle,
-    * even if we find nothing worth vacuuming in the database.
+    * Clean up any dead statistics collector entries for this DB. We always
+    * want to do this exactly once per DB-processing cycle, even if we find
+    * nothing worth vacuuming in the database.
     */
    pgstat_vacuum_tabstat();
 
@@ -948,7 +948,7 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
 
 /*
  * autovac_report_activity
- *         Report to pgstat what autovacuum is doing
+ *     Report to pgstat what autovacuum is doing
  *
  * We send a SQL string corresponding to what the user would see if the
  * equivalent command was to be issued manually.
@@ -989,13 +989,13 @@ autovac_report_activity(VacuumStmt *vacstmt, List *relids)
        char       *nspname = get_namespace_name(get_rel_namespace(relid));
 
        /*
-        * Paranoia is appropriate here in case relation was recently
-        * dropped --- the lsyscache routines we just invoked will return
-        * NULL rather than failing.
+        * Paranoia is appropriate here in case relation was recently dropped
+        * --- the lsyscache routines we just invoked will return NULL rather
+        * than failing.
         */
        if (relname && nspname)
        {
-           int     len = strlen(activity);
+           int         len = strlen(activity);
 
            snprintf(activity + len, MAX_AUTOVAC_ACTIV_LEN - len,
                     " %s.%s", nspname, relname);
index 679b8a5c7239425eb04aab9e86026c15019e2c78..69a6734bc57b58fd87f0027c63cff5016f5e7c88 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.27 2006/08/17 23:04:06 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.28 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -207,14 +207,13 @@ BackgroundWriterMain(void)
 #endif
 
    /*
-    * Initialize so that first time-driven event happens at the correct
-    * time.
+    * Initialize so that first time-driven event happens at the correct time.
     */
    last_checkpoint_time = last_xlog_switch_time = time(NULL);
 
    /*
-    * Create a resource owner to keep track of our resources (currently
-    * only buffer pins).
+    * Create a resource owner to keep track of our resources (currently only
+    * buffer pins).
     */
    CurrentResourceOwner = ResourceOwnerCreate(NULL, "Background Writer");
 
@@ -406,17 +405,17 @@ BackgroundWriterMain(void)
            BgBufferSync();
 
        /*
-        * Check for archive_timeout, if so, switch xlog files.  First
-        * we do a quick check using possibly-stale local state.
+        * Check for archive_timeout, if so, switch xlog files.  First we do a
+        * quick check using possibly-stale local state.
         */
        if (XLogArchiveTimeout > 0 &&
            (int) (now - last_xlog_switch_time) >= XLogArchiveTimeout)
        {
            /*
-            * Update local state ... note that last_xlog_switch_time is
-            * the last time a switch was performed *or requested*.
+            * Update local state ... note that last_xlog_switch_time is the
+            * last time a switch was performed *or requested*.
             */
-           time_t  last_time = GetLastSegSwitchTime();
+           time_t      last_time = GetLastSegSwitchTime();
 
            last_xlog_switch_time = Max(last_xlog_switch_time, last_time);
 
@@ -427,7 +426,7 @@ BackgroundWriterMain(void)
            /* Now we can do the real check */
            if ((int) (now - last_xlog_switch_time) >= XLogArchiveTimeout)
            {
-               XLogRecPtr switchpoint;
+               XLogRecPtr  switchpoint;
 
                /* OK, it's time to switch */
                switchpoint = RequestXLogSwitch();
@@ -440,9 +439,10 @@ BackgroundWriterMain(void)
                    ereport(DEBUG1,
                            (errmsg("xlog switch forced (archive_timeout=%d)",
                                    XLogArchiveTimeout)));
+
                /*
-                * Update state in any case, so we don't retry constantly
-                * when the system is idle.
+                * Update state in any case, so we don't retry constantly when
+                * the system is idle.
                 */
                last_xlog_switch_time = now;
            }
@@ -463,9 +463,9 @@ BackgroundWriterMain(void)
            (bgwriter_lru_percent > 0.0 && bgwriter_lru_maxpages > 0))
            udelay = BgWriterDelay * 1000L;
        else if (XLogArchiveTimeout > 0)
-           udelay = 1000000L;   /* One second */
+           udelay = 1000000L;  /* One second */
        else
-           udelay = 10000000L;  /* Ten seconds */
+           udelay = 10000000L; /* Ten seconds */
 
        while (udelay > 999999L)
        {
index 715de0071c1abf612d0250d7085491476fe2b450..db4a57b017117b3bd3e167a0163c2964387ea4da 100644 (file)
@@ -13,7 +13,7 @@
  *
  * Copyright (c) 2001-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.138 2006/08/28 19:38:09 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.139 2006/10/04 00:29:56 momjian Exp $
  * ----------
  */
 #include "postgres.h"
@@ -136,8 +136,8 @@ static TransactionId pgStatLocalStatusXact = InvalidTransactionId;
 static PgBackendStatus *localBackendStatusTable = NULL;
 static int localNumBackends = 0;
 
-static volatile bool   need_exit = false;
-static volatile bool   need_statwrite = false;
+static volatile bool need_exit = false;
+static volatile bool need_statwrite = false;
 
 
 /* ----------
@@ -199,13 +199,13 @@ pgstat_init(void)
    char        test_byte;
    int         sel_res;
    int         tries = 0;
-   
+
 #define TESTBYTEVAL ((char) 199)
 
    /*
     * Force start of collector daemon if something to collect.  Note that
-    * pgstat_collect_querystring is now an independent facility that does
-    * not require the collector daemon.
+    * pgstat_collect_querystring is now an independent facility that does not
+    * require the collector daemon.
     */
    if (pgstat_collect_tuplelevel ||
        pgstat_collect_blocklevel)
@@ -262,8 +262,8 @@ pgstat_init(void)
 
        if (++tries > 1)
            ereport(LOG,
-               (errmsg("trying another address for the statistics collector")));
-       
+           (errmsg("trying another address for the statistics collector")));
+
        /*
         * Create the socket.
         */
@@ -479,7 +479,6 @@ pgstat_forkexec(void)
 
    return postmaster_forkexec(ac, av);
 }
-
 #endif   /* EXEC_BACKEND */
 
 
@@ -823,7 +822,7 @@ pgstat_drop_relation(Oid relid)
    msg.m_tableid[0] = relid;
    msg.m_nentries = 1;
 
-   len = offsetof(PgStat_MsgTabpurge, m_tableid[0]) + sizeof(Oid);
+   len = offsetof(PgStat_MsgTabpurge, m_tableid[0]) +sizeof(Oid);
 
    pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
    msg.m_databaseid = MyDatabaseId;
@@ -900,7 +899,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared,
    msg.m_databaseid = shared ? InvalidOid : MyDatabaseId;
    msg.m_tableoid = tableoid;
    msg.m_analyze = analyze;
-   msg.m_autovacuum = IsAutoVacuumProcess(); /* is this autovacuum? */
+   msg.m_autovacuum = IsAutoVacuumProcess();   /* is this autovacuum? */
    msg.m_vacuumtime = GetCurrentTimestamp();
    msg.m_tuples = tuples;
    pgstat_send(&msg, sizeof(msg));
@@ -925,7 +924,7 @@ pgstat_report_analyze(Oid tableoid, bool shared, PgStat_Counter livetuples,
    pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_ANALYZE);
    msg.m_databaseid = shared ? InvalidOid : MyDatabaseId;
    msg.m_tableoid = tableoid;
-   msg.m_autovacuum = IsAutoVacuumProcess(); /* is this autovacuum? */
+   msg.m_autovacuum = IsAutoVacuumProcess();   /* is this autovacuum? */
    msg.m_analyzetime = GetCurrentTimestamp();
    msg.m_live_tuples = livetuples;
    msg.m_dead_tuples = deadtuples;
@@ -1079,8 +1078,8 @@ pgstat_initstats(PgStat_Info *stats, Relation rel)
 void
 pgstat_count_xact_commit(void)
 {
-   if  (!pgstat_collect_tuplelevel &&
-        !pgstat_collect_blocklevel)
+   if (!pgstat_collect_tuplelevel &&
+       !pgstat_collect_blocklevel)
        return;
 
    pgStatXactCommit++;
@@ -1110,8 +1109,8 @@ pgstat_count_xact_commit(void)
 void
 pgstat_count_xact_rollback(void)
 {
-   if  (!pgstat_collect_tuplelevel &&
-        !pgstat_collect_blocklevel)
+   if (!pgstat_collect_tuplelevel &&
+       !pgstat_collect_blocklevel)
        return;
 
    pgStatXactRollback++;
@@ -1319,8 +1318,8 @@ pgstat_bestart(void)
    MyBEEntry = &BackendStatusArray[MyBackendId - 1];
 
    /*
-    * To minimize the time spent modifying the entry, fetch all the
-    * needed data first.
+    * To minimize the time spent modifying the entry, fetch all the needed
+    * data first.
     *
     * If we have a MyProcPort, use its session start time (for consistency,
     * and to save a kernel call).
@@ -1343,12 +1342,13 @@ pgstat_bestart(void)
 
    /*
     * Initialize my status entry, following the protocol of bumping
-    * st_changecount before and after; and make sure it's even afterwards.
-    * We use a volatile pointer here to ensure the compiler doesn't try to
-    * get cute.
+    * st_changecount before and after; and make sure it's even afterwards. We
+    * use a volatile pointer here to ensure the compiler doesn't try to get
+    * cute.
     */
    beentry = MyBEEntry;
-   do {
+   do
+   {
        beentry->st_changecount++;
    } while ((beentry->st_changecount & 1) == 0);
 
@@ -1389,9 +1389,9 @@ pgstat_beshutdown_hook(int code, Datum arg)
    pgstat_report_tabstat();
 
    /*
-    * Clear my status entry, following the protocol of bumping
-    * st_changecount before and after.  We use a volatile pointer here
-    * to ensure the compiler doesn't try to get cute.
+    * Clear my status entry, following the protocol of bumping st_changecount
+    * before and after.  We use a volatile pointer here to ensure the
+    * compiler doesn't try to get cute.
     */
    beentry->st_changecount++;
 
@@ -1420,8 +1420,8 @@ pgstat_report_activity(const char *cmd_str)
        return;
 
    /*
-    * To minimize the time spent modifying the entry, fetch all the
-    * needed data first.
+    * To minimize the time spent modifying the entry, fetch all the needed
+    * data first.
     */
    start_timestamp = GetCurrentStatementStartTimestamp();
 
@@ -1430,8 +1430,8 @@ pgstat_report_activity(const char *cmd_str)
 
    /*
     * Update my status entry, following the protocol of bumping
-    * st_changecount before and after.  We use a volatile pointer here
-    * to ensure the compiler doesn't try to get cute.
+    * st_changecount before and after.  We use a volatile pointer here to
+    * ensure the compiler doesn't try to get cute.
     */
    beentry->st_changecount++;
 
@@ -1499,20 +1499,19 @@ pgstat_read_current_status(void)
    for (i = 1; i <= MaxBackends; i++)
    {
        /*
-        * Follow the protocol of retrying if st_changecount changes while
-        * we copy the entry, or if it's odd.  (The check for odd is needed
-        * to cover the case where we are able to completely copy the entry
-        * while the source backend is between increment steps.)  We use a
-        * volatile pointer here to ensure the compiler doesn't try to get
-        * cute.
+        * Follow the protocol of retrying if st_changecount changes while we
+        * copy the entry, or if it's odd.  (The check for odd is needed to
+        * cover the case where we are able to completely copy the entry while
+        * the source backend is between increment steps.)  We use a volatile
+        * pointer here to ensure the compiler doesn't try to get cute.
         */
        for (;;)
        {
-           int     save_changecount = beentry->st_changecount;
+           int         save_changecount = beentry->st_changecount;
 
            /*
-            * XXX if PGBE_ACTIVITY_SIZE is really large, it might be best
-            * to use strcpy not memcpy for copying the activity string?
+            * XXX if PGBE_ACTIVITY_SIZE is really large, it might be best to
+            * use strcpy not memcpy for copying the activity string?
             */
            memcpy(localentry, (char *) beentry, sizeof(PgBackendStatus));
 
@@ -1589,7 +1588,7 @@ pgstat_send(void *msg, int len)
 /* ----------
  * PgstatCollectorMain() -
  *
- * Start up the statistics collector process.  This is the body of the
+ * Start up the statistics collector process.  This is the body of the
  * postmaster child process.
  *
  * The argc/argv parameters are valid only in EXEC_BACKEND case.
@@ -1602,6 +1601,7 @@ PgstatCollectorMain(int argc, char *argv[])
    bool        need_timer = false;
    int         len;
    PgStat_Msg  msg;
+
 #ifdef HAVE_POLL
    struct pollfd input_fd;
 #else
@@ -1655,8 +1655,8 @@ PgstatCollectorMain(int argc, char *argv[])
    pgstat_read_statsfile(&pgStatDBHash, InvalidOid);
 
    /*
-    * Setup the descriptor set for select(2).  Since only one bit in the
-    * set ever changes, we need not repeat FD_ZERO each time.
+    * Setup the descriptor set for select(2).  Since only one bit in the set
+    * ever changes, we need not repeat FD_ZERO each time.
     */
 #ifndef HAVE_POLL
    FD_ZERO(&rfds);
@@ -1666,13 +1666,13 @@ PgstatCollectorMain(int argc, char *argv[])
     * Loop to process messages until we get SIGQUIT or detect ungraceful
     * death of our parent postmaster.
     *
-    * For performance reasons, we don't want to do a PostmasterIsAlive()
-    * test after every message; instead, do it at statwrite time and if
+    * For performance reasons, we don't want to do a PostmasterIsAlive() test
+    * after every message; instead, do it at statwrite time and if
     * select()/poll() is interrupted by timeout.
     */
    for (;;)
    {
-       int     got_data;
+       int         got_data;
 
        /*
         * Quit if we get SIGQUIT from the postmaster.
@@ -1681,7 +1681,7 @@ PgstatCollectorMain(int argc, char *argv[])
            break;
 
        /*
-        * If time to write the stats file, do so.  Note that the alarm
+        * If time to write the stats file, do so.  Note that the alarm
         * interrupt isn't re-enabled immediately, but only after we next
         * receive a stats message; so no cycles are wasted when there is
         * nothing going on.
@@ -1701,9 +1701,9 @@ PgstatCollectorMain(int argc, char *argv[])
         * Wait for a message to arrive; but not for more than
         * PGSTAT_SELECT_TIMEOUT seconds. (This determines how quickly we will
         * shut down after an ungraceful postmaster termination; so it needn't
-        * be very fast.  However, on some systems SIGQUIT won't interrupt
-        * the poll/select call, so this also limits speed of response to
-        * SIGQUIT, which is more important.)
+        * be very fast.  However, on some systems SIGQUIT won't interrupt the
+        * poll/select call, so this also limits speed of response to SIGQUIT,
+        * which is more important.)
         *
         * We use poll(2) if available, otherwise select(2)
         */
@@ -1722,7 +1722,6 @@ PgstatCollectorMain(int argc, char *argv[])
        }
 
        got_data = (input_fd.revents != 0);
-
 #else                          /* !HAVE_POLL */
 
        FD_SET(pgStatSock, &rfds);
@@ -1744,7 +1743,6 @@ PgstatCollectorMain(int argc, char *argv[])
        }
 
        got_data = FD_ISSET(pgStatSock, &rfds);
-
 #endif   /* HAVE_POLL */
 
        /*
@@ -1826,20 +1824,20 @@ PgstatCollectorMain(int argc, char *argv[])
            {
                if (setitimer(ITIMER_REAL, &write_timeout, NULL))
                    ereport(ERROR,
-                         (errmsg("could not set statistics collector timer: %m")));
+                   (errmsg("could not set statistics collector timer: %m")));
                need_timer = false;
            }
        }
        else
        {
            /*
-            * We can only get here if the select/poll timeout elapsed.
-            * Check for postmaster death.
+            * We can only get here if the select/poll timeout elapsed. Check
+            * for postmaster death.
             */
            if (!PostmasterIsAlive(true))
                break;
        }
-   } /* end of message-processing loop */
+   }                           /* end of message-processing loop */
 
    /*
     * Save the final stats to reuse at next startup.
@@ -1953,9 +1951,9 @@ pgstat_write_statsfile(void)
    while ((dbentry = (PgStat_StatDBEntry *) hash_seq_search(&hstat)) != NULL)
    {
        /*
-        * Write out the DB entry including the number of live backends.
-        * We don't write the tables pointer since it's of no use to any
-        * other process.
+        * Write out the DB entry including the number of live backends. We
+        * don't write the tables pointer since it's of no use to any other
+        * process.
         */
        fputc('D', fpout);
        fwrite(dbentry, offsetof(PgStat_StatDBEntry, tables), 1, fpout);
@@ -1987,8 +1985,8 @@ pgstat_write_statsfile(void)
    {
        ereport(LOG,
                (errcode_for_file_access(),
-                errmsg("could not write temporary statistics file \"%s\": %m",
-                       PGSTAT_STAT_TMPFILE)));
+              errmsg("could not write temporary statistics file \"%s\": %m",
+                     PGSTAT_STAT_TMPFILE)));
        fclose(fpout);
        unlink(PGSTAT_STAT_TMPFILE);
    }
@@ -2491,10 +2489,10 @@ pgstat_recv_vacuum(PgStat_MsgVacuum *msg, int len)
    if (tabentry == NULL)
        return;
 
-   if (msg->m_autovacuum) 
+   if (msg->m_autovacuum)
        tabentry->autovac_vacuum_timestamp = msg->m_vacuumtime;
-   else 
-       tabentry->vacuum_timestamp = msg->m_vacuumtime; 
+   else
+       tabentry->vacuum_timestamp = msg->m_vacuumtime;
    tabentry->n_live_tuples = msg->m_tuples;
    tabentry->n_dead_tuples = 0;
    if (msg->m_analyze)
@@ -2539,9 +2537,9 @@ pgstat_recv_analyze(PgStat_MsgAnalyze *msg, int len)
    if (tabentry == NULL)
        return;
 
-   if (msg->m_autovacuum) 
+   if (msg->m_autovacuum)
        tabentry->autovac_analyze_timestamp = msg->m_analyzetime;
-   else 
+   else
        tabentry->analyze_timestamp = msg->m_analyzetime;
    tabentry->n_live_tuples = msg->m_live_tuples;
    tabentry->n_dead_tuples = msg->m_dead_tuples;
index 130415c74cb7e8b6dd8b42debdb88f068734d0a7..ed4de7269806cbac8c76352871b4106a9db30392 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.499 2006/08/15 18:26:58 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.500 2006/10/04 00:29:56 momjian Exp $
  *
  * NOTES
  *
@@ -141,9 +141,9 @@ typedef struct bkend
 static Dllist *BackendList;
 
 #ifdef EXEC_BACKEND
-/* 
+/*
  * Number of entries in the backend table. Twice the number of backends,
- * plus four other subprocesses (stats, bgwriter, autovac, logger). 
+ * plus four other subprocesses (stats, bgwriter, autovac, logger).
  */
 #define NUM_BACKENDARRAY_ELEMS (2*MaxBackends + 4)
 static Backend *ShmemBackendArray;
@@ -510,6 +510,7 @@ PostmasterMain(int argc, char *argv[])
                break;
 
            case 'T':
+
                /*
                 * In the event that some backend dumps core, send SIGSTOP,
                 * rather than SIGQUIT, to all its peers.  This lets the wily
@@ -519,21 +520,21 @@ PostmasterMain(int argc, char *argv[])
                break;
 
            case 't':
-           {
-               const char *tmp = get_stats_option_name(optarg);
-
-               if (tmp)
                {
-                   SetConfigOption(tmp, "true", PGC_POSTMASTER, PGC_S_ARGV);
-               }
-               else
-               {
-                   write_stderr("%s: invalid argument for option -t: \"%s\"\n",
-                                progname, optarg);
-                   ExitPostmaster(1);
+                   const char *tmp = get_stats_option_name(optarg);
+
+                   if (tmp)
+                   {
+                       SetConfigOption(tmp, "true", PGC_POSTMASTER, PGC_S_ARGV);
+                   }
+                   else
+                   {
+                       write_stderr("%s: invalid argument for option -t: \"%s\"\n",
+                                    progname, optarg);
+                       ExitPostmaster(1);
+                   }
+                   break;
                }
-               break;
-           }
 
            case 'W':
                SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV);
@@ -2468,9 +2469,9 @@ BackendStartup(Port *port)
         * postmaster's listen sockets.  (In EXEC_BACKEND case this is all
         * done in SubPostmasterMain.)
         */
-       IsUnderPostmaster = true;   /* we are a postmaster subprocess now */
+       IsUnderPostmaster = true;       /* we are a postmaster subprocess now */
 
-       MyProcPid = getpid();       /* reset MyProcPid */
+       MyProcPid = getpid();   /* reset MyProcPid */
 
        /* We don't want the postmaster's proc_exit() handlers */
        on_exit_reset();
@@ -2718,8 +2719,8 @@ BackendInitialize(Port *port)
     * 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,
-       update_process_title ? "authentication" : "");
-   
+                   update_process_title ? "authentication" : "");
+
    /*
     * Now perform authentication exchange.
     */
@@ -3252,12 +3253,11 @@ SubPostmasterMain(int argc, char *argv[])
        /*
         * Perform additional initialization and client authentication.
         *
-        * We want to do this before InitProcess() for a couple of reasons:
-        * 1. so that we aren't eating up a PGPROC slot while waiting on the 
-        * client.
-        * 2. so that if InitProcess() fails due to being out of PGPROC slots,
-        * we have already initialized libpq and are able to report the error
-        * to the client.
+        * We want to do this before InitProcess() for a couple of reasons: 1.
+        * so that we aren't eating up a PGPROC slot while waiting on the
+        * client. 2. so that if InitProcess() fails due to being out of
+        * PGPROC slots, we have already initialized libpq and are able to
+        * report the error to the client.
         */
        BackendInitialize(&port);
 
@@ -3268,16 +3268,15 @@ SubPostmasterMain(int argc, char *argv[])
        InitProcess();
 
        /*
-        *  Attach process to shared data structures.  If testing
-        *  EXEC_BACKEND on Linux, you must run this as root
-        *  before starting the postmaster:
+        * Attach process to shared data structures.  If testing EXEC_BACKEND
+        * on Linux, you must run this as root before starting the postmaster:
         *
-        *      echo 0 >/proc/sys/kernel/randomize_va_space
+        * echo 0 >/proc/sys/kernel/randomize_va_space
         *
-        *  This prevents a randomized stack base address that causes
-        *  child shared memory to be at a different address than
-        *  the parent, making it impossible to attached to shared
-        *  memory.  Return the value to '1' when finished.
+        * This prevents a randomized stack base address that causes child
+        * shared memory to be at a different address than the parent, making
+        * it impossible to attached to shared memory.  Return the value to
+        * '1' when finished.
         */
        CreateSharedMemoryAndSemaphores(false, 0);
 
index 17f437c385597f3e003c307870aa449e211446d7..d4f9c7f1ff645dcb4ba8a95a9913bbed06d0de78 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.114 2006/09/05 21:08:35 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteDefine.c,v 1.115 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,7 +32,7 @@
 
 
 static void checkRuleResultList(List *targetList, TupleDesc resultDesc,
-                               bool isSelect);
+                   bool isSelect);
 static bool setRuleCheckAsUser_walker(Node *node, Oid *context);
 static void setRuleCheckAsUser_Query(Query *qry, Oid userid);
 
@@ -286,7 +286,7 @@ DefineQueryRewrite(RuleStmt *stmt)
         */
        if (!replace && event_relation->rd_rules != NULL)
        {
-           int     i;
+           int         i;
 
            for (i = 0; i < event_relation->rd_rules->numLocks; i++)
            {
@@ -369,14 +369,14 @@ DefineQueryRewrite(RuleStmt *stmt)
    else
    {
        /*
-        * For non-SELECT rules, a RETURNING list can appear in at most one
-        * of the actions ... and there can't be any RETURNING list at all
-        * in a conditional or non-INSTEAD rule.  (Actually, there can be
-        * at most one RETURNING list across all rules on the same event,
-        * but it seems best to enforce that at rule expansion time.)  If
-        * there is a RETURNING list, it must match the event relation.
+        * For non-SELECT rules, a RETURNING list can appear in at most one of
+        * the actions ... and there can't be any RETURNING list at all in a
+        * conditional or non-INSTEAD rule.  (Actually, there can be at most
+        * one RETURNING list across all rules on the same event, but it seems
+        * best to enforce that at rule expansion time.)  If there is a
+        * RETURNING list, it must match the event relation.
         */
-       bool    haveReturning = false;
+       bool        haveReturning = false;
 
        foreach(l, action)
        {
@@ -387,7 +387,7 @@ DefineQueryRewrite(RuleStmt *stmt)
            if (haveReturning)
                ereport(ERROR,
                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                        errmsg("cannot have multiple RETURNING lists in a rule")));
+                 errmsg("cannot have multiple RETURNING lists in a rule")));
            haveReturning = true;
            if (event_qual != NULL)
                ereport(ERROR,
@@ -478,7 +478,7 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
                     isSelect ?
-                    errmsg("SELECT rule's target list has too many entries") :
+                  errmsg("SELECT rule's target list has too many entries") :
                     errmsg("RETURNING list has too many entries")));
 
        attr = resultDesc->attrs[i - 1];
@@ -513,9 +513,9 @@ checkRuleResultList(List *targetList, TupleDesc resultDesc, bool isSelect)
 
        /*
         * 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.
+        * "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 &&
@@ -638,4 +638,5 @@ RenameRewriteRule(Oid owningRel, const char *oldName,
    heap_freetuple(ruletup);
    heap_close(pg_rewrite_desc, RowExclusiveLock);
 }
+
 #endif
index 1af5bd7e7f57c4fb00d0079e661cfc9f26b5f633..81af9eebadd2d501313d408471369f19483f92b9 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.166 2006/09/02 17:06:52 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.167 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -43,13 +43,13 @@ static Query *rewriteRuleAction(Query *parsetree,
                  bool *returning_flag);
 static List *adjustJoinTreeList(Query *parsetree, bool removert, int rt_index);
 static void rewriteTargetList(Query *parsetree, Relation target_relation,
-                             List **attrno_list);
+                 List **attrno_list);
 static TargetEntry *process_matched_tle(TargetEntry *src_tle,
                    TargetEntry *prior_tle,
                    const char *attrName);
 static Node *get_assignment_input(Node *node);
 static void rewriteValuesRTE(RangeTblEntry *rte, Relation target_relation,
-                            List *attrnos);
+                List *attrnos);
 static void markQueryForLocking(Query *qry, bool forUpdate, bool noWait,
                    bool skipOldNew);
 static List *matchLocks(CmdType event, RuleLock *rulelocks,
@@ -431,10 +431,10 @@ rewriteRuleAction(Query *parsetree,
    }
 
    /*
-    * If rule_action has a RETURNING clause, then either throw it away
-    * if the triggering query has no RETURNING clause, or rewrite it to
-    * emit what the triggering query's RETURNING clause asks for.  Throw
-    * an error if more than one rule has a RETURNING clause.
+    * If rule_action has a RETURNING clause, then either throw it away if the
+    * triggering query has no RETURNING clause, or rewrite it to emit what
+    * the triggering query's RETURNING clause asks for.  Throw an error if
+    * more than one rule has a RETURNING clause.
     */
    if (!parsetree->returningList)
        rule_action->returningList = NIL;
@@ -443,7 +443,7 @@ rewriteRuleAction(Query *parsetree,
        if (*returning_flag)
            ereport(ERROR,
                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                    errmsg("cannot have RETURNING lists in multiple rules")));
+                  errmsg("cannot have RETURNING lists in multiple rules")));
        *returning_flag = true;
        rule_action->returningList = (List *)
            ResolveNew((Node *) parsetree->returningList,
@@ -907,12 +907,12 @@ searchForDefault(RangeTblEntry *rte)
 
    foreach(lc, rte->values_lists)
    {
-       List   *sublist = (List *) lfirst(lc);
-       ListCell *lc2;
+       List       *sublist = (List *) lfirst(lc);
+       ListCell   *lc2;
 
        foreach(lc2, sublist)
        {
-           Node  *col = (Node *) lfirst(lc2);
+           Node       *col = (Node *) lfirst(lc2);
 
            if (IsA(col, SetToDefault))
                return true;
@@ -952,15 +952,15 @@ rewriteValuesRTE(RangeTblEntry *rte, Relation target_relation, List *attrnos)
    newValues = NIL;
    foreach(lc, rte->values_lists)
    {
-       List   *sublist = (List *) lfirst(lc);
-       List   *newList = NIL;
-       ListCell *lc2;
-       ListCell *lc3;
+       List       *sublist = (List *) lfirst(lc);
+       List       *newList = NIL;
+       ListCell   *lc2;
+       ListCell   *lc3;
 
        forboth(lc2, sublist, lc3, attrnos)
        {
-           Node  *col = (Node *) lfirst(lc2);
-           int     attrno = lfirst_int(lc3);
+           Node       *col = (Node *) lfirst(lc2);
+           int         attrno = lfirst_int(lc3);
 
            if (IsA(col, SetToDefault))
            {
@@ -972,7 +972,7 @@ rewriteValuesRTE(RangeTblEntry *rte, Relation target_relation, List *attrnos)
                if (!att_tup->attisdropped)
                    new_expr = build_column_default(target_relation, attrno);
                else
-                   new_expr = NULL;        /* force a NULL if dropped */
+                   new_expr = NULL;    /* force a NULL if dropped */
 
                /*
                 * If there is no default (ie, default is effectively NULL),
@@ -1548,8 +1548,8 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
            RangeTblEntry *values_rte = NULL;
 
            /*
-            * If it's an INSERT ... VALUES (...), (...), ...
-            * there will be a single RTE for the VALUES targetlists.
+            * If it's an INSERT ... VALUES (...), (...), ... there will be a
+            * single RTE for the VALUES targetlists.
             */
            if (list_length(parsetree->jointree->fromlist) == 1)
            {
@@ -1567,7 +1567,7 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
 
            if (values_rte)
            {
-               List   *attrnos;
+               List       *attrnos;
 
                /* Process the main targetlist ... */
                rewriteTargetList(parsetree, rt_entry_relation, &attrnos);
@@ -1638,11 +1638,11 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
        }
 
        /*
-        * If there is an INSTEAD, and the original query has a RETURNING,
-        * we have to have found a RETURNING in the rule(s), else fail.
-        * (Because DefineQueryRewrite only allows RETURNING in unconditional
-        * INSTEAD rules, there's no need to worry whether the substituted
-        * RETURNING will actually be executed --- it must be.)
+        * If there is an INSTEAD, and the original query has a RETURNING, we
+        * have to have found a RETURNING in the rule(s), else fail. (Because
+        * DefineQueryRewrite only allows RETURNING in unconditional INSTEAD
+        * rules, there's no need to worry whether the substituted RETURNING
+        * will actually be executed --- it must be.)
         */
        if ((instead || qual_product != NULL) &&
            parsetree->returningList &&
@@ -1653,22 +1653,22 @@ RewriteQuery(Query *parsetree, List *rewrite_events)
                case CMD_INSERT:
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                            errmsg("cannot INSERT RETURNING on relation \"%s\"",
-                                   RelationGetRelationName(rt_entry_relation)),
+                        errmsg("cannot INSERT RETURNING on relation \"%s\"",
+                               RelationGetRelationName(rt_entry_relation)),
                             errhint("You need an unconditional ON INSERT DO INSTEAD rule with a RETURNING clause.")));
                    break;
                case CMD_UPDATE:
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                            errmsg("cannot UPDATE RETURNING on relation \"%s\"",
-                                   RelationGetRelationName(rt_entry_relation)),
+                        errmsg("cannot UPDATE RETURNING on relation \"%s\"",
+                               RelationGetRelationName(rt_entry_relation)),
                             errhint("You need an unconditional ON UPDATE DO INSTEAD rule with a RETURNING clause.")));
                    break;
                case CMD_DELETE:
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                            errmsg("cannot DELETE RETURNING on relation \"%s\"",
-                                   RelationGetRelationName(rt_entry_relation)),
+                        errmsg("cannot DELETE RETURNING on relation \"%s\"",
+                               RelationGetRelationName(rt_entry_relation)),
                             errhint("You need an unconditional ON DELETE DO INSTEAD rule with a RETURNING clause.")));
                    break;
                default:
index ce951a4601953ba3b845c84ebc0a3b2c8a6a93bc..96bfdf5f3afd87fd24ead4a7556e28a12e8a35e9 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.101 2006/07/14 14:52:22 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteManip.c,v 1.102 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -984,10 +984,11 @@ ResolveNew(Node *node, int target_varno, int sublevels_up,
    {
        if (IsA(result, Query))
            ((Query *) result)->hasSubLinks = true;
+
        /*
         * Note: if we're called on a non-Query node then it's the caller's
-        * responsibility to update hasSubLinks in the ancestor Query.
-        * This is pretty fragile and perhaps should be rethought ...
+        * responsibility to update hasSubLinks in the ancestor Query. This is
+        * pretty fragile and perhaps should be rethought ...
         */
    }
 
index f08001ce0375359e32ff38afb322b911d5a21ad9..d09b5d2c42f7f00e8af195b7b2d5cdad553b36c6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteRemove.c,v 1.67 2006/10/03 21:21:36 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteRemove.c,v 1.68 2006/10/04 00:29:56 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,7 +35,7 @@
  */
 void
 RemoveRewriteRule(Oid owningRel, const char *ruleName, DropBehavior behavior,
-                 bool missing_ok)
+                 bool missing_ok)
 {
    HeapTuple   tuple;
    Oid         eventRelationOid;
@@ -54,7 +54,7 @@ RemoveRewriteRule(Oid owningRel, const char *ruleName, DropBehavior behavior,
     */
    if (!HeapTupleIsValid(tuple))
    {
-       if (! missing_ok)
+       if (!missing_ok)
            ereport(ERROR,
                    (errcode(ERRCODE_UNDEFINED_OBJECT),
                     errmsg("rule \"%s\" for relation \"%s\" does not exist",
index aaa0dff6843f393d65e8ae088e1ca49bdd9284da..5efd9cc7b13c09fc906ffd93bb524ecf8547a291 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.211 2006/09/25 22:01:10 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.212 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -178,10 +178,10 @@ ReadBuffer(Relation reln, BlockNumber blockNum)
         * This can happen because mdread doesn't complain about reads beyond
         * EOF --- which is arguably bogus, but changing it seems tricky ---
         * and so a previous attempt to read a block just beyond EOF could
-        * have left a "valid" zero-filled buffer.  Unfortunately, we have
+        * have left a "valid" zero-filled buffer.  Unfortunately, we have
         * also seen this case occurring because of buggy Linux kernels that
         * sometimes return an lseek(SEEK_END) result that doesn't account for
-        * a recent write.  In that situation, the pre-existing buffer would
+        * a recent write.  In that situation, the pre-existing buffer would
         * contain valid data that we don't want to overwrite.  Since the
         * legitimate cases should always have left a zero-filled buffer,
         * complain if not PageIsNew.
@@ -194,10 +194,10 @@ ReadBuffer(Relation reln, BlockNumber blockNum)
                     errhint("This has been seen to occur with buggy kernels; consider updating your system.")));
 
        /*
-        * We *must* do smgrextend before succeeding, else the
-        * page will not be reserved by the kernel, and the next P_NEW call
-        * will decide to return the same page.  Clear the BM_VALID bit,
-        * do the StartBufferIO call that BufferAlloc didn't, and proceed.
+        * We *must* do smgrextend before succeeding, else the page will not
+        * be reserved by the kernel, and the next P_NEW call will decide to
+        * return the same page.  Clear the BM_VALID bit, do the StartBufferIO
+        * call that BufferAlloc didn't, and proceed.
         */
        if (isLocalBuf)
        {
@@ -208,11 +208,12 @@ ReadBuffer(Relation reln, BlockNumber blockNum)
        else
        {
            /*
-            * Loop to handle the very small possibility that someone
-            * re-sets BM_VALID between our clearing it and StartBufferIO
-            * inspecting it.
+            * Loop to handle the very small possibility that someone re-sets
+            * BM_VALID between our clearing it and StartBufferIO inspecting
+            * it.
             */
-           do {
+           do
+           {
                LockBufHdr(bufHdr);
                Assert(bufHdr->flags & BM_VALID);
                bufHdr->flags &= ~BM_VALID;
@@ -311,10 +312,10 @@ BufferAlloc(Relation reln,
 {
    BufferTag   newTag;         /* identity of requested block */
    uint32      newHash;        /* hash value for newTag */
-   LWLockId    newPartitionLock;   /* buffer partition lock for it */
+   LWLockId    newPartitionLock;       /* buffer partition lock for it */
    BufferTag   oldTag;         /* previous identity of selected buffer */
    uint32      oldHash;        /* hash value for oldTag */
-   LWLockId    oldPartitionLock;   /* buffer partition lock for it */
+   LWLockId    oldPartitionLock;       /* buffer partition lock for it */
    BufFlags    oldFlags;
    int         buf_id;
    volatile BufferDesc *buf;
@@ -620,7 +621,7 @@ InvalidateBuffer(volatile BufferDesc *buf)
 {
    BufferTag   oldTag;
    uint32      oldHash;        /* hash value for oldTag */
-   LWLockId    oldPartitionLock;   /* buffer partition lock for it */
+   LWLockId    oldPartitionLock;       /* buffer partition lock for it */
    BufFlags    oldFlags;
 
    /* Save the original buffer tag before dropping the spinlock */
@@ -629,9 +630,9 @@ InvalidateBuffer(volatile BufferDesc *buf)
    UnlockBufHdr(buf);
 
    /*
-    * Need to compute the old tag's hashcode and partition lock ID.
-    * XXX is it worth storing the hashcode in BufferDesc so we need
-    * not recompute it here?  Probably not.
+    * Need to compute the old tag's hashcode and partition lock ID. XXX is it
+    * worth storing the hashcode in BufferDesc so we need not recompute it
+    * here?  Probably not.
     */
    oldHash = BufTableHashCode(&oldTag);
    oldPartitionLock = BufMappingPartitionLock(oldHash);
@@ -715,7 +716,7 @@ retry:
  *
  *     Marks buffer contents as dirty (actual write happens later).
  *
- * Buffer must be pinned and exclusive-locked.  (If caller does not hold
+ * Buffer must be pinned and exclusive-locked. (If caller does not hold
  * exclusive lock, then somebody could be in process of writing the buffer,
  * leading to risk of bad data written to disk.)
  */
@@ -972,9 +973,9 @@ BufferSync(void)
        {
            /*
             * If in bgwriter, absorb pending fsync requests after each
-            * WRITES_PER_ABSORB write operations, to prevent overflow of
-            * the fsync request queue.  If not in bgwriter process, this is
-            * no-op.
+            * WRITES_PER_ABSORB write operations, to prevent overflow of the
+            * fsync request queue.  If not in bgwriter process, this is a
+            * no-op.
             */
            if (--absorb_counter <= 0)
            {
@@ -1770,9 +1771,9 @@ SetBufferCommitInfoNeedsSave(Buffer buffer)
    /*
     * This routine might get called many times on the same page, if we are
     * making the first scan after commit of an xact that added/deleted many
-    * tuples.  So, be as quick as we can if the buffer is already dirty.  We
+    * tuples.  So, be as quick as we can if the buffer is already dirty.  We
     * do this by not acquiring spinlock if it looks like the status bits are
-    * already OK.  (Note it is okay if someone else clears BM_JUST_DIRTIED
+    * already OK.  (Note it is okay if someone else clears BM_JUST_DIRTIED
     * immediately after we look, because the buffer content update is already
     * done and will be reflected in the I/O.)
     */
index 333053c1c93f360c8bcbca46fd1131864aae9177..92c2cfce620833fd416450086ba2e039e5706c5a 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.56 2006/07/23 18:34:45 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.57 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -237,12 +237,12 @@ StrategyInitialize(bool init)
    /*
     * Initialize the shared buffer lookup hashtable.
     *
-    * Since we can't tolerate running out of lookup table entries, we
-    * must be sure to specify an adequate table size here.  The maximum
-    * steady-state usage is of course NBuffers entries, but BufferAlloc()
-    * tries to insert a new entry before deleting the old.  In principle
-    * this could be happening in each partition concurrently, so we
-    * could need as many as NBuffers + NUM_BUFFER_PARTITIONS entries.
+    * Since we can't tolerate running out of lookup table entries, we must be
+    * sure to specify an adequate table size here.  The maximum steady-state
+    * usage is of course NBuffers entries, but BufferAlloc() tries to insert
+    * a new entry before deleting the old.  In principle this could be
+    * happening in each partition concurrently, so we could need as many as
+    * NBuffers + NUM_BUFFER_PARTITIONS entries.
     */
    InitBufTable(NBuffers + NUM_BUFFER_PARTITIONS);
 
index 04cdd95a699f78fc4cb71b5ade8997929c75f6d3..a594b16edf35f12e15e04d7772f190eda54165b0 100644 (file)
@@ -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.129 2006/08/24 03:15:43 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/file/fd.c,v 1.130 2006/10/04 00:29:57 momjian Exp $
  *
  * NOTES:
  *
@@ -1026,7 +1026,7 @@ retry:
         * in which case immediate retry is indicated.
         */
 #ifdef WIN32
-       DWORD error = GetLastError();
+       DWORD       error = GetLastError();
 
        switch (error)
        {
@@ -1081,7 +1081,7 @@ retry:
         * See comments in FileRead()
         */
 #ifdef WIN32
-       DWORD error = GetLastError();
+       DWORD       error = GetLastError();
 
        switch (error)
        {
@@ -1279,8 +1279,8 @@ TryAgain:
    }
 
    /*
-    * TEMPORARY hack to log the Windows error code on fopen failures,
-    * in hopes of diagnosing some hard-to-reproduce problems.
+    * TEMPORARY hack to log the Windows error code on fopen failures, in
+    * hopes of diagnosing some hard-to-reproduce problems.
     */
 #ifdef WIN32
    {
index 3309ba11dac98d3636da6b94925632bf21eed0a9..7c85b44221e50918dcf558d9ad14dab6d7bb72cd 100644 (file)
@@ -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.55 2006/09/21 20:31:22 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/freespace/freespace.c,v 1.56 2006/10/04 00:29:57 momjian Exp $
  *
  *
  * NOTES:
@@ -111,7 +111,7 @@ typedef struct FsmCacheRelHeader
    RelFileNode key;            /* hash key (must be first) */
    bool        isIndex;        /* if true, we store only page numbers */
    uint32      avgRequest;     /* moving average of space requests */
-   BlockNumber interestingPages;   /* # of pages with useful free space */
+   BlockNumber interestingPages;       /* # of pages with useful free space */
    int32       storedPages;    /* # of pages stored in arena */
 } FsmCacheRelHeader;
 
@@ -128,8 +128,8 @@ static void CheckFreeSpaceMapStatistics(int elevel, int numRels,
 static FSMRelation *lookup_fsm_rel(RelFileNode *rel);
 static FSMRelation *create_fsm_rel(RelFileNode *rel);
 static void delete_fsm_rel(FSMRelation *fsmrel);
-static int realloc_fsm_rel(FSMRelation *fsmrel, BlockNumber interestingPages,
-                           bool isIndex);
+static int realloc_fsm_rel(FSMRelation *fsmrel, BlockNumber interestingPages,
+               bool isIndex);
 static void link_fsm_rel_usage(FSMRelation *fsmrel);
 static void unlink_fsm_rel_usage(FSMRelation *fsmrel);
 static void link_fsm_rel_storage(FSMRelation *fsmrel);
@@ -601,6 +601,7 @@ PrintFreeSpaceMapStatistics(int elevel)
    double      needed;
 
    LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
+
    /*
     * Count total space actually used, as well as the unclamped request total
     */
@@ -1688,9 +1689,9 @@ fsm_calc_request(FSMRelation *fsmrel)
    }
 
    /*
-    * We clamp the per-relation requests to at most half the arena size;
-    * this is intended to prevent a single bloated relation from crowding
-    * out FSM service for every other rel.
+    * We clamp the per-relation requests to at most half the arena size; this
+    * is intended to prevent a single bloated relation from crowding out FSM
+    * service for every other rel.
     */
    req = Min(req, FreeSpaceMap->totalChunks / 2);
 
index a4d36d157beccb2f8acfff0929e26b7dfa27cdcb..716963f448112ce0ec0546cdf6b6f03da49fc127 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.87 2006/08/01 19:03:11 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.88 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -95,8 +95,8 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port)
        size = add_size(size, 8192 - (size % 8192));
 
        /*
-        * The shared memory for add-ins is treated as a separate
-        * segment, but in reality it is not.
+        * The shared memory for add-ins is treated as a separate segment, but
+        * in reality it is not.
         */
        size_b4addins = size;
        size = add_size(size, AddinShmemSize());
@@ -115,8 +115,8 @@ CreateSharedMemoryAndSemaphores(bool makePrivate, int port)
         * Modify hdr to show segment size before add-ins
         */
        seghdr->totalsize = size_b4addins;
-       
-       /* 
+
+       /*
         * Set up segment header sections in each Addin context
         */
        InitAddinContexts((void *) ((char *) seghdr + size_b4addins));
index 7b4ea9077efeac83a6fe8086a1d093fdfcb419c3..39de167fe561d510f99ca5e349dd86bb6cb8c9b0 100644 (file)
@@ -23,7 +23,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.17 2006/09/03 15:59:38 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.18 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -393,7 +393,7 @@ TransactionIdIsActive(TransactionId xid)
  * This is used by VACUUM to decide which deleted tuples must be preserved
  * in a table. allDbs = TRUE is needed for shared relations, but allDbs =
  * FALSE is sufficient for non-shared relations, since only backends in my
- * own database could ever see the tuples in them.  Also, we can ignore
+ * own database could ever see the tuples in them. Also, we can ignore
  * concurrently running lazy VACUUMs because (a) they must be working on other
  * tables, and (b) they don't need to do snapshot-based lookups.
  *
@@ -545,13 +545,13 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
    globalxmin = xmin = GetTopTransactionId();
 
    /*
-    * It is sufficient to get shared lock on ProcArrayLock, even if we
-    * are computing a serializable snapshot and therefore will be setting
+    * It is sufficient to get shared lock on ProcArrayLock, even if we are
+    * computing a serializable snapshot and therefore will be setting
     * MyProc->xmin.  This is because any two backends that have overlapping
     * shared holds on ProcArrayLock will certainly compute the same xmin
     * (since no xact, in particular not the oldest, can exit the set of
     * running transactions while we hold ProcArrayLock --- see further
-    * discussion just below).  So it doesn't matter whether another backend
+    * discussion just below).  So it doesn't matter whether another backend
     * concurrently doing GetSnapshotData or GetOldestXmin sees our xmin as
     * set or not; he'd compute the same xmin for himself either way.
     */
@@ -595,8 +595,8 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
 
        /*
         * Ignore my own proc (dealt with my xid above), procs not running a
-        * transaction, xacts started since we read the next transaction
-        * ID, and xacts executing LAZY VACUUM. There's no need to store XIDs
+        * transaction, xacts started since we read the next transaction ID,
+        * and xacts executing LAZY VACUUM. 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
@@ -625,18 +625,17 @@ GetSnapshotData(Snapshot snapshot, bool serializable)
         * their parent, so no need to check them against xmin.
         *
         * The other backend can add more subxids concurrently, but cannot
-        * remove any.  Hence it's important to fetch nxids just once.
-        * Should be safe to use memcpy, though.  (We needn't worry about
-        * missing any xids added concurrently, because they must postdate
-        * xmax.)
+        * remove any.  Hence it's important to fetch nxids just once. Should
+        * be safe to use memcpy, though.  (We needn't worry about missing any
+        * xids added concurrently, because they must postdate xmax.)
         */
        if (subcount >= 0)
        {
            if (proc->subxids.overflowed)
-               subcount = -1;                  /* overflowed */
+               subcount = -1;  /* overflowed */
            else
            {
-               int     nxids = proc->subxids.nxids;
+               int         nxids = proc->subxids.nxids;
 
                if (nxids > 0)
                {
index 4cff4c19f336d96adb2f5ce3b8854c484ce4c7a9..685912e157a145e2ff7978f986ee01ff500a1230 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.96 2006/09/27 18:40:09 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/ipc/shmem.c,v 1.97 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
  * hash bucket garbage collector if need be.  Right now, it seems
  * unnecessary.
  *
- *      (e) Add-ins can request their own logical shared memory segments
- *  by calling RegisterAddinContext() from the preload-libraries hook.
- *  Each call establishes a uniquely named add-in shared memopry
- *  context which will be set up as part of postgres intialisation.
- *  Memory can be allocated from these contexts using
- *  ShmemAllocFromContext(), and can be reset to its initial condition
- *  using ShmemResetContext().  Also, RegisterAddinLWLock(LWLockid *lock_ptr)
- *  can be used to request that a LWLock be allocated, placed into *lock_ptr.
+ *     (e) Add-ins can request their own logical shared memory segments
+ * by calling RegisterAddinContext() from the preload-libraries hook.
+ * Each call establishes a uniquely named add-in shared memopry
+ * context which will be set up as part of postgres intialisation.
+ * Memory can be allocated from these contexts using
+ * ShmemAllocFromContext(), and can be reset to its initial condition
+ * using ShmemResetContext().  Also, RegisterAddinLWLock(LWLockid *lock_ptr)
+ * can be used to request that a LWLock be allocated, placed into *lock_ptr.
  */
 
 #include "postgres.h"
@@ -98,9 +98,9 @@ static HTAB *ShmemIndex = NULL; /* primary index hashtable for shmem */
 /* Structures and globals for managing add-in shared memory contexts */
 typedef struct context
 {
-   char           *name;
-   Size            size;
-   PGShmemHeader  *seg_hdr;
+   char       *name;
+   Size        size;
+   PGShmemHeader *seg_hdr;
    struct context *next;
 } ContextNode;
 
@@ -138,9 +138,9 @@ InitShmemAllocation(void)
    Assert(shmhdr != NULL);
 
    /*
-    * Initialize the spinlock used by ShmemAlloc.  We have to do the
-    * space allocation the hard way, since obviously ShmemAlloc can't
-    * be called yet.
+    * Initialize the spinlock used by ShmemAlloc.  We have to do the space
+    * allocation the hard way, since obviously ShmemAlloc can't be called
+    * yet.
     */
    ShmemLock = (slock_t *) (((char *) shmhdr) + shmhdr->freeoffset);
    shmhdr->freeoffset += MAXALIGN(sizeof(slock_t));
@@ -153,22 +153,22 @@ InitShmemAllocation(void)
    ShmemIndex = (HTAB *) NULL;
 
    /*
-    * Initialize ShmemVariableCache for transaction manager.
-    * (This doesn't really belong here, but not worth moving.)
+    * Initialize ShmemVariableCache for transaction manager. (This doesn't
+    * really belong here, but not worth moving.)
     */
    ShmemVariableCache = (VariableCache)
-   ShmemAlloc(sizeof(*ShmemVariableCache));
+       ShmemAlloc(sizeof(*ShmemVariableCache));
    memset(ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
 }
 
 /*
  * RegisterAddinContext -- Register the requirement for a named shared
- *                         memory context.
+ *                        memory context.
  */
 void
 RegisterAddinContext(const char *name, Size size)
 {
-   char *newstr = malloc(strlen(name) + 1);
+   char       *newstr = malloc(strlen(name) + 1);
    ContextNode *node = malloc(sizeof(ContextNode));
 
    strcpy(newstr, name);
@@ -185,7 +185,7 @@ RegisterAddinContext(const char *name, Size size)
 
 /*
  * ContextFromName -- Return the ContextNode for the given named
- *                    context, or NULL if not found.
+ *                   context, or NULL if not found.
  */
 static ContextNode *
 ContextFromName(const char *name)
@@ -203,7 +203,7 @@ ContextFromName(const char *name)
 
 /*
  * InitAddinContexts -- Initialise the registered addin shared memory
- *                      contexts. 
+ *                     contexts.
  */
 void
 InitAddinContexts(void *start)
@@ -218,7 +218,7 @@ InitAddinContexts(void *start)
        next_segment->totalsize = context->size;
        next_segment->freeoffset = MAXALIGN(sizeof(PGShmemHeader));
 
-       next_segment = (PGShmemHeader *) 
+       next_segment = (PGShmemHeader *)
            ((char *) next_segment + context->size);
        context = context->next;
    }
@@ -245,7 +245,7 @@ ShmemResetContext(const char *name)
 
 /*
  * AddinShmemSize -- Report how much shared memory has been registered
- *  for add-ins.
+ * for add-ins.
  */
 Size
 AddinShmemSize(void)
@@ -265,15 +265,15 @@ AddinShmemSize(void)
 void *
 ShmemAllocFromContext(Size size, const char *context_name)
 {
-   Size          newStart;
-   Size          newFree;
-   void         *newSpace;
-   ContextNode  *context;
+   Size        newStart;
+   Size        newFree;
+   void       *newSpace;
+   ContextNode *context;
 
    /* use volatile pointer to prevent code rearrangement */
    volatile PGShmemHeader *shmemseghdr = ShmemSegHdr;
 
-   /* 
+   /*
     * if context_name is provided, allocate from the named context
     */
    if (context_name)
@@ -480,8 +480,8 @@ ShmemInitStruct(const char *name, Size size, bool *foundPtr)
             * be trying to init the shmem index itself.
             *
             * Notice that the ShmemIndexLock is released before the shmem
-            * index has been initialized.  This should be OK because no
-            * other process can be accessing shared memory yet.
+            * index has been initialized.  This should be OK because no other
+            * process can be accessing shared memory yet.
             */
            Assert(shmemseghdr->indexoffset == 0);
            structPtr = ShmemAlloc(size);
index 28e862533dffd3afb96c422831886fb5b24babf2..4a4c0990ad26329a123f53ba92381f35b1777736 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.88 2006/09/22 23:20:13 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.89 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,7 +54,7 @@ RelationInitLockInfo(Relation relation)
 static inline void
 SetLocktagRelationOid(LOCKTAG *tag, Oid relid)
 {
-   Oid     dbid;
+   Oid         dbid;
 
    if (IsSharedRelation(relid))
        dbid = InvalidOid;
@@ -67,7 +67,7 @@ SetLocktagRelationOid(LOCKTAG *tag, Oid relid)
 /*
  *     LockRelationOid
  *
- * Lock a relation given only its OID.  This should generally be used
+ * Lock a relation given only its OID. This should generally be used
  * before attempting to open the relation's relcache entry.
  */
 void
@@ -81,13 +81,13 @@ LockRelationOid(Oid relid, LOCKMODE lockmode)
    res = LockAcquire(&tag, lockmode, false, false);
 
    /*
-    * Now that we have the lock, check for invalidation messages, so that
-    * we will update or flush any stale relcache entry before we try to use
-    * it.  We can skip this in the not-uncommon case that we already had
-    * the same type of lock being requested, since then no one else could
-    * have modified the relcache entry in an undesirable way.  (In the
-    * case where our own xact modifies the rel, the relcache update happens
-    * via CommandCounterIncrement, not here.)
+    * Now that we have the lock, check for invalidation messages, so that we
+    * will update or flush any stale relcache entry before we try to use it.
+    * We can skip this in the not-uncommon case that we already had the same
+    * type of lock being requested, since then no one else could have
+    * modified the relcache entry in an undesirable way.  (In the case where
+    * our own xact modifies the rel, the relcache update happens via
+    * CommandCounterIncrement, not here.)
     */
    if (res != LOCKACQUIRE_ALREADY_HELD)
        AcceptInvalidationMessages();
@@ -116,8 +116,8 @@ ConditionalLockRelationOid(Oid relid, LOCKMODE lockmode)
        return false;
 
    /*
-    * Now that we have the lock, check for invalidation messages; see
-    * notes in LockRelationOid.
+    * Now that we have the lock, check for invalidation messages; see notes
+    * in LockRelationOid.
     */
    if (res != LOCKACQUIRE_ALREADY_HELD)
        AcceptInvalidationMessages();
@@ -176,8 +176,8 @@ LockRelation(Relation relation, LOCKMODE lockmode)
    res = LockAcquire(&tag, lockmode, false, false);
 
    /*
-    * Now that we have the lock, check for invalidation messages; see
-    * notes in LockRelationOid.
+    * Now that we have the lock, check for invalidation messages; see notes
+    * in LockRelationOid.
     */
    if (res != LOCKACQUIRE_ALREADY_HELD)
        AcceptInvalidationMessages();
@@ -206,8 +206,8 @@ ConditionalLockRelation(Relation relation, LOCKMODE lockmode)
        return false;
 
    /*
-    * Now that we have the lock, check for invalidation messages; see
-    * notes in LockRelationOid.
+    * Now that we have the lock, check for invalidation messages; see notes
+    * in LockRelationOid.
     */
    if (res != LOCKACQUIRE_ALREADY_HELD)
        AcceptInvalidationMessages();
index 6300dc2eeb48af82bd7d28e755a005ae52468d12..939528e754844714ff2172faf992b83228bfd53b 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.173 2006/09/18 22:40:36 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.174 2006/10/04 00:29:57 momjian Exp $
  *
  * NOTES
  *   A lock table is a shared memory hash table.  When
@@ -112,7 +112,7 @@ static const char *const lock_mode_names[] =
 };
 
 #ifndef LOCK_DEBUG
-static bool        Dummy_trace = false;
+static bool Dummy_trace = false;
 #endif
 
 static const LockMethodData default_lockmethod = {
@@ -290,8 +290,8 @@ InitLocks(void)
    init_table_size = max_table_size / 2;
 
    /*
-    * Allocate hash table for LOCK structs.  This stores
-    * per-locked-object information.
+    * Allocate hash table for LOCK structs.  This stores per-locked-object
+    * information.
     */
    MemSet(&info, 0, sizeof(info));
    info.keysize = sizeof(LOCKTAG);
@@ -331,8 +331,8 @@ InitLocks(void)
        elog(FATAL, "could not initialize proclock hash table");
 
    /*
-    * Allocate non-shared hash table for LOCALLOCK structs.  This stores
-    * lock counts and resource owner information.
+    * Allocate non-shared hash table for LOCALLOCK structs.  This stores 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).
@@ -396,8 +396,8 @@ static uint32
 proclock_hash(const void *key, Size keysize)
 {
    const PROCLOCKTAG *proclocktag = (const PROCLOCKTAG *) key;
-   uint32  lockhash;
-   Datum   procptr;
+   uint32      lockhash;
+   Datum       procptr;
 
    Assert(keysize == sizeof(PROCLOCKTAG));
 
@@ -407,9 +407,9 @@ proclock_hash(const void *key, Size keysize)
    /*
     * To make the hash code also depend on the PGPROC, we xor the proc
     * struct's address into the hash code, left-shifted so that the
-    * partition-number bits don't change.  Since this is only a hash,
-    * we don't care if we lose high-order bits of the address; use
-    * an intermediate variable to suppress cast-pointer-to-int warnings.
+    * partition-number bits don't change.  Since this is only a hash, we
+    * don't care if we lose high-order bits of the address; use an
+    * intermediate variable to suppress cast-pointer-to-int warnings.
     */
    procptr = PointerGetDatum(proclocktag->myProc);
    lockhash ^= ((uint32) procptr) << LOG2_NUM_LOCK_PARTITIONS;
@@ -426,8 +426,8 @@ proclock_hash(const void *key, Size keysize)
 static inline uint32
 ProcLockHashCode(const PROCLOCKTAG *proclocktag, uint32 hashcode)
 {
-   uint32  lockhash = hashcode;
-   Datum   procptr;
+   uint32      lockhash = hashcode;
+   Datum       procptr;
 
    /*
     * This must match proclock_hash()!
@@ -1117,7 +1117,7 @@ WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner)
        memcpy(new_status, old_status, len);
        strcpy(new_status + len, " waiting");
        set_ps_display(new_status, false);
-       new_status[len] = '\0';     /* truncate off " waiting" */
+       new_status[len] = '\0'; /* truncate off " waiting" */
    }
    pgstat_report_waiting(true);
 
@@ -1549,12 +1549,12 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks)
                        LockTagHashCode(&lock->tag),
                        wakeupNeeded);
 
-       next_item:
+   next_item:
            proclock = nextplock;
-       } /* loop over PROCLOCKs within this partition */
+       }                       /* loop over PROCLOCKs within this partition */
 
        LWLockRelease(partitionLock);
-   } /* loop over partitions */
+   }                           /* loop over partitions */
 
 #ifdef LOCK_DEBUG
    if (*(lockMethodTable->trace_flag))
@@ -1726,8 +1726,8 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
    if (!lock)
    {
        /*
-        * If the lock object doesn't exist, there is nothing holding a
-        * lock on this lockable object.
+        * If the lock object doesn't exist, there is nothing holding a lock
+        * on this lockable object.
         */
        LWLockRelease(partitionLock);
        return NIL;
@@ -1747,7 +1747,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode)
    {
        if (conflictMask & proclock->holdMask)
        {
-           PGPROC *proc = proclock->tag.myProc;
+           PGPROC     *proc = proclock->tag.myProc;
 
            /* A backend never blocks itself */
            if (proc != MyProc)
@@ -1963,7 +1963,7 @@ PostPrepare_Locks(TransactionId xid)
            /*
             * We cannot simply modify proclock->tag.myProc 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
+            * 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
@@ -1987,7 +1987,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.")));
@@ -2017,12 +2017,12 @@ PostPrepare_Locks(TransactionId xid)
            Assert((newproclock->holdMask & holdMask) == 0);
            newproclock->holdMask |= holdMask;
 
-       next_item:
+   next_item:
            proclock = nextplock;
-       } /* loop over PROCLOCKs within this partition */
+       }                       /* loop over PROCLOCKs within this partition */
 
        LWLockRelease(partitionLock);
-   } /* loop over partitions */
+   }                           /* loop over partitions */
 
    END_CRIT_SECTION();
 }
@@ -2084,10 +2084,11 @@ GetLockStatusData(void)
     * operate one partition at a time if we want to deliver a self-consistent
     * view of the state.
     *
-    * Since this is a read-only operation, we take shared instead of exclusive
-    * lock.  There's not a whole lot of point to this, because all the normal
-    * operations require exclusive lock, but it doesn't hurt anything either.
-    * It will at least allow two backends to do GetLockStatusData in parallel.
+    * Since this is a read-only operation, we take shared instead of
+    * exclusive lock.  There's not a whole lot of point to this, because all
+    * the normal operations require exclusive lock, but it doesn't hurt
+    * anything either. It will at least allow two backends to do
+    * GetLockStatusData in parallel.
     *
     * Must grab LWLocks in partition-number order to avoid LWLock deadlock.
     */
@@ -2119,7 +2120,7 @@ GetLockStatusData(void)
    }
 
    /* And release locks */
-   for (i = NUM_LOCK_PARTITIONS; --i >= 0; )
+   for (i = NUM_LOCK_PARTITIONS; --i >= 0;)
        LWLockRelease(FirstLockMgrLock + i);
 
    Assert(el == data->nelements);
index 28c73a8a9b67a9339d21a16b0dcee0938fbdd122..c5b0d2af4d20159ede732e201a46d33f81f24086 100644 (file)
@@ -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.45 2006/08/07 21:56:25 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.46 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -30,7 +30,7 @@
 #include "storage/spin.h"
 
 
-static int NumAddinLWLocks(void);
+static int NumAddinLWLocks(void);
 static void AssignAddinLWLocks(void);
 
 
@@ -95,23 +95,23 @@ static int *ex_acquire_counts;
 static int *block_counts;
 #endif
 
-/* 
+/*
  * Structures and globals to allow add-ins to register for their own
  * lwlocks from the preload-libraries hook.
  */
 typedef struct LWLockNode
 {
-   LWLockId *lock;
+   LWLockId   *lock;
    struct LWLockNode *next;
 } LWLockNode;
 
 static LWLockNode *addin_locks = NULL;
-static int num_addin_locks = 0;
+static int num_addin_locks = 0;
 
 
 /*
  * RegisterAddinLWLock() --- Allow an andd-in to request a LWLock
- *                           from the preload-libraries hook.
+ *                           from the preload-libraries hook.
  */
 void
 RegisterAddinLWLock(LWLockId *lock)
@@ -198,8 +198,7 @@ print_lwlock_stats(int code, Datum arg)
 
    LWLockRelease(0);
 }
-
-#endif /* LWLOCK_STATS */
+#endif   /* LWLOCK_STATS */
 
 
 /*
@@ -306,9 +305,8 @@ CreateLWLocks(void)
    LWLockCounter[0] = (int) NumFixedLWLocks;
    LWLockCounter[1] = numLocks;
 
-   /* 
-    * Allocate LWLocks for those add-ins that have explicitly requested
-    * them.
+   /*
+    * Allocate LWLocks for those add-ins that have explicitly requested them.
     */
    AssignAddinLWLocks();
 }
@@ -364,8 +362,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
    /* Set up local count state first time through in a given process */
    if (counts_for_pid != MyProcPid)
    {
-       int    *LWLockCounter = (int *) ((char *) LWLockArray - 2 * sizeof(int));
-       int     numLocks = LWLockCounter[1];
+       int        *LWLockCounter = (int *) ((char *) LWLockArray - 2 * sizeof(int));
+       int         numLocks = LWLockCounter[1];
 
        sh_acquire_counts = calloc(numLocks, sizeof(int));
        ex_acquire_counts = calloc(numLocks, sizeof(int));
@@ -378,7 +376,7 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
        ex_acquire_counts[lockid]++;
    else
        sh_acquire_counts[lockid]++;
-#endif /* LWLOCK_STATS */
+#endif   /* LWLOCK_STATS */
 
    /*
     * We can't wait if we haven't got a PGPROC.  This should only occur
index 07fc3e3d2555b25f7979dcdd510f2ea0be56f605..cf71b83eab525127d1ba379ef037c90ce30b7bf2 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.179 2006/07/30 02:07:18 alvherre Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.180 2006/10/04 00:29:57 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -149,8 +149,8 @@ InitProcGlobal(void)
    Assert(!found);
 
    /*
-    * Create the PGPROC structures for dummy (bgwriter) processes, too.
-    * These do not get linked into the freeProcs list.
+    * Create the PGPROC structures for dummy (bgwriter) processes, too. These
+    * do not get linked into the freeProcs list.
     */
    DummyProcs = (PGPROC *)
        ShmemInitStruct("DummyProcs", NUM_DUMMY_PROCS * sizeof(PGPROC),
@@ -183,7 +183,7 @@ InitProcGlobal(void)
    MemSet(DummyProcs, 0, NUM_DUMMY_PROCS * sizeof(PGPROC));
    for (i = 0; i < NUM_DUMMY_PROCS; i++)
    {
-       DummyProcs[i].pid = 0;      /* marks dummy proc as not in use */
+       DummyProcs[i].pid = 0;  /* marks dummy proc as not in use */
        PGSemaphoreCreate(&(DummyProcs[i].sem));
    }
 
@@ -268,7 +268,7 @@ InitProcess(void)
 
    /*
     * We might be reusing a semaphore that belonged to a failed process. So
-    * be careful and reinitialize its value here.  (This is not strictly
+    * be careful and reinitialize its value here.  (This is not strictly
     * necessary anymore, but seems like a good idea for cleanliness.)
     */
    PGSemaphoreReset(&MyProc->sem);
@@ -298,9 +298,9 @@ InitProcessPhase2(void)
    Assert(MyProc != NULL);
 
    /*
-    * We should now know what database we're in, so advertise that.  (We
-    * need not do any locking here, since no other backend can yet see
-    * our PGPROC.)
+    * We should now know what database we're in, so advertise that.  (We need
+    * not do any locking here, since no other backend can yet see our
+    * PGPROC.)
     */
    Assert(OidIsValid(MyDatabaseId));
    MyProc->databaseId = MyDatabaseId;
@@ -400,7 +400,7 @@ InitDummyProcess(void)
 
    /*
     * We might be reusing a semaphore that belonged to a failed process. So
-    * be careful and reinitialize its value here.  (This is not strictly
+    * be careful and reinitialize its value here.  (This is not strictly
     * necessary anymore, but seems like a good idea for cleanliness.)
     */
    PGSemaphoreReset(&MyProc->sem);
@@ -489,12 +489,12 @@ LockWaitCancel(void)
 
    /*
     * We used to do PGSemaphoreReset() here to ensure that our proc's wait
-    * semaphore is reset to zero.  This prevented a leftover wakeup signal
-    * from remaining in the semaphore if someone else had granted us the
-    * lock we wanted before we were able to remove ourselves from the
-    * wait-list.  However, now that ProcSleep loops until waitStatus changes,
-    * a leftover wakeup signal isn't harmful, and it seems not worth
-    * expending cycles to get rid of a signal that most likely isn't there.
+    * semaphore is reset to zero.  This prevented a leftover wakeup signal
+    * from remaining in the semaphore if someone else had granted us the lock
+    * we wanted before we were able to remove ourselves from the wait-list.
+    * However, now that ProcSleep loops until waitStatus changes, a leftover
+    * wakeup signal isn't harmful, and it seems not worth expending cycles to
+    * get rid of a signal that most likely isn't there.
     */
 
    /*
@@ -810,11 +810,11 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
    /*
     * If someone wakes us between LWLockRelease and PGSemaphoreLock,
     * PGSemaphoreLock will not block.  The wakeup is "saved" by the semaphore
-    * implementation.  While this is normally good, there are cases where
-    * a saved wakeup might be leftover from a previous operation (for
-    * example, we aborted ProcWaitForSignal just before someone did
-    * ProcSendSignal).  So, loop to wait again if the waitStatus shows
-    * we haven't been granted nor denied the lock yet.
+    * implementation.  While this is normally good, there are cases where a
+    * saved wakeup might be leftover from a previous operation (for example,
+    * we aborted ProcWaitForSignal just before someone did ProcSendSignal).
+    * So, loop to wait again if the waitStatus shows we haven't been granted
+    * nor denied the lock yet.
     *
     * We pass interruptOK = true, which eliminates a window in which
     * cancel/die interrupts would be held off undesirably.  This is a promise
@@ -824,7 +824,8 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
     * updating the locallock table, but if we lose control to an error,
     * LockWaitCancel will fix that up.
     */
-   do {
+   do
+   {
        PGSemaphoreLock(&MyProc->sem, true);
    } while (MyProc->waitStatus == STATUS_WAITING);
 
@@ -835,9 +836,9 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
        elog(FATAL, "could not disable timer for process wakeup");
 
    /*
-    * Re-acquire the lock table's partition lock.  We have to do this to
-    * hold off cancel/die interrupts before we can mess with lockAwaited
-    * (else we might have a missed or duplicated locallock update).
+    * Re-acquire the lock table's partition lock.  We have to do this to hold
+    * off cancel/die interrupts before we can mess with lockAwaited (else we
+    * might have a missed or duplicated locallock update).
     */
    LWLockAcquire(partitionLock, LW_EXCLUSIVE);
 
@@ -977,8 +978,8 @@ CheckDeadLock(void)
    int         i;
 
    /*
-    * Acquire exclusive lock on the entire shared lock data structures.
-    * Must grab LWLocks in partition-number order to avoid LWLock deadlock.
+    * Acquire exclusive lock on the entire shared lock data structures. Must
+    * grab LWLocks in partition-number order to avoid LWLock deadlock.
     *
     * Note that the deadlock check interrupt had better not be enabled
     * anywhere that this process itself holds lock partition locks, else this
@@ -1018,7 +1019,7 @@ CheckDeadLock(void)
    /*
     * Oops.  We have a deadlock.
     *
-    * Get this process out of wait state.  (Note: we could do this more
+    * Get this process out of wait state.  (Note: we could do this more
     * efficiently by relying on lockAwaited, but use this coding to preserve
     * the flexibility to kill some other transaction than the one detecting
     * the deadlock.)
@@ -1047,12 +1048,12 @@ CheckDeadLock(void)
     */
 
    /*
-    * Release locks acquired at head of routine.  Order is not critical,
-    * so do it back-to-front to avoid waking another CheckDeadLock instance
+    * Release locks acquired at head of routine.  Order is not critical, so
+    * do it back-to-front to avoid waking another CheckDeadLock instance
     * before it can get all the locks.
     */
 check_done:
-   for (i = NUM_LOCK_PARTITIONS; --i >= 0; )
+   for (i = NUM_LOCK_PARTITIONS; --i >= 0;)
        LWLockRelease(FirstLockMgrLock + i);
 }
 
@@ -1063,10 +1064,10 @@ check_done:
  * This can share the semaphore normally used for waiting for locks,
  * since a backend could never be waiting for a lock and a signal at
  * the same time.  As with locks, it's OK if the signal arrives just
- * before we actually reach the waiting state.  Also as with locks,
+ * before we actually reach the waiting state. Also as with locks,
  * it's necessary that the caller be robust against bogus wakeups:
  * always check that the desired state has occurred, and wait again
- * if not.  This copes with possible "leftover" wakeups.
+ * if not. This copes with possible "leftover" wakeups.
  */
 void
 ProcWaitForSignal(void)
@@ -1122,10 +1123,10 @@ enable_sig_alarm(int delayms, bool is_statement_timeout)
         * interval will have elapsed and so this doesn't matter, but there
         * are corner cases (involving multi-statement query strings with
         * embedded COMMIT or ROLLBACK) where we might re-initialize the
-        * statement timeout long after initial receipt of the message.
-        * In such cases the enforcement of the statement timeout will be
-        * a bit inconsistent.  This annoyance is judged not worth the cost
-        * of performing an additional gettimeofday() here.
+        * statement timeout long after initial receipt of the message. In
+        * such cases the enforcement of the statement timeout will be a bit
+        * inconsistent.  This annoyance is judged not worth the cost of
+        * performing an additional gettimeofday() here.
         */
        Assert(!deadlock_timeout_active);
        fin_time = GetCurrentStatementStartTimestamp();
@@ -1253,6 +1254,7 @@ CheckStatementTimeout(void)
 
        TimestampDifference(now, statement_fin_time,
                            &secs, &usecs);
+
        /*
         * It's possible that the difference is less than a microsecond;
         * ensure we don't cancel, rather than set, the interrupt.
index 8c4be2364f1c867c896cb34bf13ba310474a20a6..c90545e105566184d4e7f81f8e0d95999dc928e8 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.46 2006/07/14 14:52:23 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.47 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -119,7 +119,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;
@@ -280,7 +280,6 @@ tas_dummy()                     /* really means: extern int tas(slock_t
    asm("   .data");
 }
 #endif   /* sun3 */
-
 #endif   /* not __GNUC__ */
 #endif   /* HAVE_SPINLOCKS */
 
index 08f2273ab91f9b4c58c9d2691d0e4daa6766ab99..d693ded4a2531a31591fc2bd557f6402d571bc07 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/page/itemptr.c,v 1.18 2006/08/25 04:06:53 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/page/itemptr.c,v 1.19 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,7 +51,7 @@ ItemPointerCompare(ItemPointer arg1, ItemPointer arg2)
     */
    BlockNumber b1 = BlockIdGetBlockNumber(&(arg1->ip_blkid));
    BlockNumber b2 = BlockIdGetBlockNumber(&(arg2->ip_blkid));
-   
+
    if (b1 < b2)
        return -1;
    else if (b1 > b2)
index 928b64410ef51ea852da313d1a54074d92158cd3..ca1c34fecf369b4be9722cdccd718986ae80ddd7 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.121 2006/07/14 05:28:28 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.122 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -735,8 +735,8 @@ mdsync(void)
             * If in bgwriter, absorb pending requests every so often to
             * prevent overflow of the fsync request queue.  The hashtable
             * code does not specify whether entries added by this will be
-            * visited by our search, but we don't really care: it's OK if
-            * we do, and OK if we don't.
+            * visited by our search, but we don't really care: it's OK if we
+            * do, and OK if we don't.
             */
            if (--absorb_counter <= 0)
            {
index 28aaca716bb04ae7b3a3824276eaf91ddcbdae51..0ceb800b363eae6329ddd809a1ab943f2e13739b 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.100 2006/07/14 14:52:23 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.101 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -471,10 +471,10 @@ smgr_internal_unlink(RelFileNode rnode, int which, bool isTemp, bool isRedo)
    FreeSpaceMapForgetRel(&rnode);
 
    /*
-    * Tell the stats collector to forget it immediately, too.  Skip this
-    * in recovery mode, since the stats collector likely isn't running
-    * (and if it is, pgstat.c will get confused because we aren't a real
-    * backend process).
+    * Tell the stats collector to forget it immediately, too.  Skip this in
+    * recovery mode, since the stats collector likely isn't running (and if
+    * it is, pgstat.c will get confused because we aren't a real backend
+    * process).
     */
    if (!InRecovery)
        pgstat_drop_relation(rnode.relNode);
@@ -960,16 +960,16 @@ smgr_desc(StringInfo buf, uint8 xl_info, char *rec)
        xl_smgr_create *xlrec = (xl_smgr_create *) rec;
 
        appendStringInfo(buf, "file create: %u/%u/%u",
-               xlrec->rnode.spcNode, xlrec->rnode.dbNode,
-               xlrec->rnode.relNode);
+                        xlrec->rnode.spcNode, xlrec->rnode.dbNode,
+                        xlrec->rnode.relNode);
    }
    else if (info == XLOG_SMGR_TRUNCATE)
    {
        xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
 
        appendStringInfo(buf, "file truncate: %u/%u/%u to %u blocks",
-               xlrec->rnode.spcNode, xlrec->rnode.dbNode,
-               xlrec->rnode.relNode, xlrec->blkno);
+                        xlrec->rnode.spcNode, xlrec->rnode.dbNode,
+                        xlrec->rnode.relNode, xlrec->blkno);
    }
    else
        appendStringInfo(buf, "UNKNOWN");
index 26931e0a6d791d3016a634f8ecde5fb76402297e..8a9d51a5516c8946ea91bee79a12a5349570e73f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.92 2006/09/08 15:55:53 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.93 2006/10/04 00:29:58 momjian Exp $
  *
  * NOTES
  *   This cruft is the server side of PQfn.
@@ -303,8 +303,8 @@ HandleFunctionRequest(StringInfo msgBuf)
                        "commands ignored until end of transaction block")));
 
    /*
-    * Now that we know we are in a valid transaction, set snapshot in
-    * case needed by function itself or one of the datatype I/O routines.
+    * Now that we know we are in a valid transaction, set snapshot in case
+    * needed by function itself or one of the datatype I/O routines.
     */
    ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
 
@@ -312,7 +312,7 @@ HandleFunctionRequest(StringInfo msgBuf)
     * Begin parsing the buffer contents.
     */
    if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
-       (void) pq_getmsgstring(msgBuf);         /* dummy string */
+       (void) pq_getmsgstring(msgBuf); /* dummy string */
 
    fid = (Oid) pq_getmsgint(msgBuf, 4);        /* function oid */
 
@@ -474,8 +474,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;
@@ -607,8 +607,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;
index 6e83a23293d77a6266d1c03b56dacbd78251ed6c..835b5ab36ea2a2675aac2a1eca238563ed9bedb3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.509 2006/09/13 21:59:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.510 2006/10/04 00:29:58 momjian Exp $
  *
  * NOTES
  *   this is the "main" module of the postgres backend and
@@ -1340,8 +1340,8 @@ exec_bind_message(StringInfo input_message)
    numPFormats = pq_getmsgint(input_message, 2);
    if (numPFormats > 0)
    {
-       int i;
-       
+       int         i;
+
        pformats = (int16 *) palloc(numPFormats * sizeof(int16));
        for (i = 0; i < numPFormats; i++)
            pformats[i] = pq_getmsgint(input_message, 2);
@@ -1400,7 +1400,7 @@ exec_bind_message(StringInfo input_message)
 
        /* sizeof(ParamListInfoData) includes the first array element */
        params = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
-                               (numParams - 1) * sizeof(ParamExternData));
+                                  (numParams - 1) *sizeof(ParamExternData));
        params->numParams = numParams;
 
        paramno = 0;
@@ -1473,7 +1473,7 @@ exec_bind_message(StringInfo input_message)
                if (pstring && pstring != pbuf.data)
                    pfree(pstring);
            }
-           else if (pformat == 1)  /* binary mode */
+           else if (pformat == 1)      /* binary mode */
            {
                Oid         typreceive;
                Oid         typioparam;
@@ -1513,6 +1513,7 @@ exec_bind_message(StringInfo input_message)
 
            params->params[paramno].value = pval;
            params->params[paramno].isnull = isNull;
+
            /*
             * We mark the params as CONST.  This has no effect if we already
             * did planning, but if we didn't, it licenses the planner to
@@ -1534,7 +1535,7 @@ exec_bind_message(StringInfo input_message)
    numRFormats = pq_getmsgint(input_message, 2);
    if (numRFormats > 0)
    {
-       int i;
+       int         i;
 
        rformats = (int16 *) palloc(numRFormats * sizeof(int16));
        for (i = 0; i < numRFormats; i++)
@@ -1548,14 +1549,14 @@ exec_bind_message(StringInfo input_message)
     * to make use of the concrete parameter values we now have.  Because we
     * use PARAM_FLAG_CONST, the plan is good only for this set of param
     * values, and so we generate the plan in the portal's own memory context
-    * where it will be thrown away after use.  As in exec_parse_message,
-    * we make no attempt to recover planner temporary memory until the end
-    * of the operation.
+    * where it will be thrown away after use.  As in exec_parse_message, we
+    * make no attempt to recover planner temporary memory until the end of
+    * the operation.
     *
-    * XXX because the planner has a bad habit of scribbling on its input,
-    * we have to make a copy of the parse trees, just in case someone binds
-    * and executes an unnamed statement multiple times; this also means that
-    * the portal's queryContext becomes its own heap context rather than the
+    * XXX because the planner has a bad habit of scribbling on its input, we
+    * have to make a copy of the parse trees, just in case someone binds and
+    * executes an unnamed statement multiple times; this also means that the
+    * portal's queryContext becomes its own heap context rather than the
     * prepared statement's context.  FIXME someday
     */
    if (pstmt->plan_list == NIL && pstmt->query_list != NIL)
@@ -1694,9 +1695,9 @@ exec_execute_message(const char *portal_name, long max_rows)
    execute_is_fetch = !portal->atStart;
 
    /*
-    * We must copy the sourceText and prepStmtName into MessageContext
-    * in case the portal is destroyed during finish_xact_command.
-    * Can avoid the copy if it's not an xact command, though.
+    * We must copy the sourceText and prepStmtName into MessageContext in
+    * case the portal is destroyed during finish_xact_command. Can avoid the
+    * copy if it's not an xact command, though.
     */
    if (is_xact_command)
    {
@@ -1705,6 +1706,7 @@ exec_execute_message(const char *portal_name, long max_rows)
            prepStmtName = pstrdup(portal->prepStmtName);
        else
            prepStmtName = "";
+
        /*
         * An xact command shouldn't have any parameters, which is a good
         * thing because they wouldn't be around after finish_xact_command.
@@ -1925,10 +1927,9 @@ check_log_duration(char *msec_str, bool was_logged)
        msecs = usecs / 1000;
 
        /*
-        * This odd-looking test for log_min_duration_statement being
-        * exceeded is designed to avoid integer overflow with very
-        * long durations: don't compute secs * 1000 until we've
-        * verified it will fit in int.
+        * This odd-looking test for log_min_duration_statement being exceeded
+        * is designed to avoid integer overflow with very long durations:
+        * don't compute secs * 1000 until we've verified it will fit in int.
         */
        exceeded = (log_min_duration_statement == 0 ||
                    (log_min_duration_statement > 0 &&
@@ -2026,7 +2027,7 @@ errdetail_params(ParamListInfo params)
            appendStringInfoCharMacro(¶m_str, '\'');
            for (p = pstring; *p; p++)
            {
-               if (*p == '\'')             /* double single quotes */
+               if (*p == '\'') /* double single quotes */
                    appendStringInfoCharMacro(¶m_str, *p);
                appendStringInfoCharMacro(¶m_str, *p);
            }
@@ -2082,7 +2083,7 @@ exec_describe_statement_message(const char *stmt_name)
 
    /*
     * If we are in aborted transaction state, we can't safely create a result
-    * tupledesc, because that needs catalog accesses.  Hence, refuse to
+    * tupledesc, because that needs catalog accesses.  Hence, refuse to
     * Describe statements that return data.  (We shouldn't just refuse all
     * Describes, since that might break the ability of some clients to issue
     * COMMIT or ROLLBACK commands, if they use code that blindly Describes
@@ -2154,7 +2155,7 @@ exec_describe_portal_message(const char *portal_name)
    /*
     * If we are in aborted transaction state, we can't run
     * SendRowDescriptionMessage(), because that needs catalog accesses.
-    * Hence, refuse to Describe portals that return data.  (We shouldn't just
+    * Hence, refuse to Describe portals that return data.  (We shouldn't just
     * refuse all Describes, since that might break the ability of some
     * clients to issue COMMIT or ROLLBACK commands, if they use code that
     * blindly Describes whatever it does.)
@@ -2581,29 +2582,29 @@ set_debug_options(int debug_flag, GucContext context, GucSource source)
 bool
 set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
 {
-   char *tmp = NULL;
+   char       *tmp = NULL;
 
    switch (arg[0])
    {
-       case 's':   /* seqscan */
+       case 's':               /* seqscan */
            tmp = "enable_seqscan";
            break;
-       case 'i':   /* indexscan */
+       case 'i':               /* indexscan */
            tmp = "enable_indexscan";
            break;
-       case 'b':   /* bitmapscan */
+       case 'b':               /* bitmapscan */
            tmp = "enable_bitmapscan";
            break;
-       case 't':   /* tidscan */
+       case 't':               /* tidscan */
            tmp = "enable_tidscan";
            break;
-       case 'n':   /* nestloop */
+       case 'n':               /* nestloop */
            tmp = "enable_nestloop";
            break;
-       case 'm':   /* mergejoin */
+       case 'm':               /* mergejoin */
            tmp = "enable_mergejoin";
            break;
-       case 'h':   /* hashjoin */
+       case 'h':               /* hashjoin */
            tmp = "enable_hashjoin";
            break;
    }
@@ -2623,13 +2624,13 @@ get_stats_option_name(const char *arg)
    switch (arg[0])
    {
        case 'p':
-           if (optarg[1] == 'a') /* "parser" */
+           if (optarg[1] == 'a')       /* "parser" */
                return "log_parser_stats";
-           else if (optarg[1] == 'l') /* "planner" */
+           else if (optarg[1] == 'l')  /* "planner" */
                return "log_planner_stats";
            break;
 
-       case 'e':   /* "executor" */
+       case 'e':               /* "executor" */
            return "log_executor_stats";
            break;
    }
@@ -2834,6 +2835,7 @@ PostgresMain(int argc, char *argv[], const char *username)
                break;
 
            case 's':
+
                /*
                 * Since log options are SUSET, we need to postpone unless
                 * still in secure context
@@ -2850,19 +2852,20 @@ PostgresMain(int argc, char *argv[], const char *username)
                break;
 
            case 't':
-           {
-               const char *tmp = get_stats_option_name(optarg);
-               if (tmp)
                {
-                   if (ctx == PGC_BACKEND)
-                       PendingConfigOption(tmp, "true");
+                   const char *tmp = get_stats_option_name(optarg);
+
+                   if (tmp)
+                   {
+                       if (ctx == PGC_BACKEND)
+                           PendingConfigOption(tmp, "true");
+                       else
+                           SetConfigOption(tmp, "true", ctx, gucsource);
+                   }
                    else
-                       SetConfigOption(tmp, "true", ctx, gucsource);
+                       errs++;
+                   break;
                }
-               else
-                   errs++;
-               break;
-           }
 
            case 'v':
                if (secure)
@@ -2875,6 +2878,7 @@ PostgresMain(int argc, char *argv[], const char *username)
 
 
            case 'y':
+
                /*
                 * y - special flag passed if backend was forked by a
                 * postmaster.
@@ -3090,10 +3094,10 @@ PostgresMain(int argc, char *argv[], const char *username)
    }
 
    /*
-    * Create a per-backend PGPROC struct in shared memory, except in
-    * the EXEC_BACKEND case where this was done in SubPostmasterMain.
-    * We must do this before we can use LWLocks (and in the EXEC_BACKEND
-    * case we already had to do some stuff with LWLocks).
+    * Create a per-backend PGPROC struct in shared memory, except in the
+    * EXEC_BACKEND case where this was done in SubPostmasterMain. We must do
+    * this before we can use LWLocks (and in the EXEC_BACKEND case we already
+    * had to do some stuff with LWLocks).
     */
 #ifdef EXEC_BACKEND
    if (!IsUnderPostmaster)
@@ -3154,8 +3158,8 @@ PostgresMain(int argc, char *argv[], const char *username)
        on_proc_exit(log_disconnections, 0);
 
    /*
-    * process any libraries that should be preloaded at backend start
-    * (this likewise can't be done until GUC settings are complete)
+    * process any libraries that should be preloaded at backend start (this
+    * likewise can't be done until GUC settings are complete)
     */
    process_local_preload_libraries();
 
@@ -3290,7 +3294,7 @@ PostgresMain(int argc, char *argv[], const char *username)
    PG_SETMASK(&UnBlockSig);
 
    if (!ignore_till_sync)
-       send_ready_for_query = true;        /* initially, or after error */
+       send_ready_for_query = true;    /* initially, or after error */
 
    /*
     * Non-error queries loop here.
@@ -3465,8 +3469,8 @@ PostgresMain(int argc, char *argv[], const char *username)
 
                /*
                 * Note: we may at this point be inside an aborted
-                * transaction.  We can't throw error for that until
-                * we've finished reading the function-call message, so
+                * transaction.  We can't throw error for that until we've
+                * finished reading the function-call message, so
                 * HandleFunctionRequest() must check for it after doing so.
                 * Be careful not to do anything that assumes we're inside a
                 * valid transaction here.
@@ -3778,5 +3782,5 @@ log_disconnections(int code, Datum arg)
                    "user=%s database=%s host=%s%s%s",
                    hours, minutes, seconds, msecs,
                    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)));
 }
index 8738d91abdfc09af7af46c926d338ebb4bd2c05d..62310f7c0cd8a2292a407afe6b8f6345459b36ed 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.110 2006/09/03 03:19:45 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.111 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -218,8 +218,8 @@ ChoosePortalStrategy(List *parseTrees)
 
    /*
     * PORTAL_ONE_SELECT and PORTAL_UTIL_SELECT need only consider the
-    * single-Query-struct case, since there are no rewrite rules that
-    * can add auxiliary queries to a SELECT or a utility command.
+    * single-Query-struct case, since there are no rewrite rules that can add
+    * auxiliary queries to a SELECT or a utility command.
     */
    if (list_length(parseTrees) == 1)
    {
@@ -244,8 +244,8 @@ ChoosePortalStrategy(List *parseTrees)
 
    /*
     * PORTAL_ONE_RETURNING has to allow auxiliary queries added by rewrite.
-    * Choose PORTAL_ONE_RETURNING if there is exactly one canSetTag query
-    * and it has a RETURNING list.
+    * Choose PORTAL_ONE_RETURNING if there is exactly one canSetTag query and
+    * it has a RETURNING list.
     */
    nSetTag = 0;
    foreach(lc, parseTrees)
@@ -256,9 +256,9 @@ ChoosePortalStrategy(List *parseTrees)
        if (query->canSetTag)
        {
            if (++nSetTag > 1)
-               return PORTAL_MULTI_QUERY;  /* no need to look further */
+               return PORTAL_MULTI_QUERY;      /* no need to look further */
            if (query->returningList == NIL)
-               return PORTAL_MULTI_QUERY;  /* no need to look further */
+               return PORTAL_MULTI_QUERY;      /* no need to look further */
        }
    }
    if (nSetTag == 1)
@@ -418,7 +418,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
                if (portal->cursorOptions & CURSOR_OPT_SCROLL)
                    eflags = EXEC_FLAG_REWIND | EXEC_FLAG_BACKWARD;
                else
-                   eflags = 0;     /* default run-to-completion flags */
+                   eflags = 0; /* default run-to-completion flags */
 
                /*
                 * Call ExecutorStart to prepare the plan for execution
@@ -447,8 +447,8 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
            case PORTAL_ONE_RETURNING:
 
                /*
-                * We don't start the executor until we are told to run
-                * the portal.  We do need to set up the result tupdesc.
+                * We don't start the executor until we are told to run the
+                * portal.  We do need to set up the result tupdesc.
                 */
                portal->tupDesc =
                    ExecCleanTypeFromTL((PortalGetPrimaryQuery(portal))->returningList, false);
@@ -672,8 +672,8 @@ PortalRun(Portal portal, long count,
            case PORTAL_UTIL_SELECT:
 
                /*
-                * If we have not yet run the command, do so,
-                * storing its results in the portal's tuplestore.
+                * If we have not yet run the command, do so, storing its
+                * results in the portal's tuplestore.
                 */
                if (!portal->holdStore)
                    FillPortalStore(portal);
@@ -922,10 +922,11 @@ FillPortalStore(Portal portal)
    switch (portal->strategy)
    {
        case PORTAL_ONE_RETURNING:
+
            /*
-            * Run the portal to completion just as for the default MULTI_QUERY
-            * case, but send the primary query's output to the tuplestore.
-            * Auxiliary query outputs are discarded.
+            * Run the portal to completion just as for the default
+            * MULTI_QUERY case, but send the primary query's output to the
+            * tuplestore. Auxiliary query outputs are discarded.
             */
            PortalRunMulti(portal, treceiver, None_Receiver, completionTag);
            /* Override default completion tag with actual command result */
@@ -1253,8 +1254,8 @@ PortalRunFetch(Portal portal,
            case PORTAL_UTIL_SELECT:
 
                /*
-                * If we have not yet run the command, do so,
-                * storing its results in the portal's tuplestore.
+                * If we have not yet run the command, do so, storing its
+                * results in the portal's tuplestore.
                 */
                if (!portal->holdStore)
                    FillPortalStore(portal);
index 868da2d5ff45c239ea62246413fff523bc9ea2e4..448b0fba02e509877368d24b753826e56f25b995 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.268 2006/09/07 22:52:01 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.269 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -632,7 +632,7 @@ ProcessUtility(Node *parsetree,
 
        case T_CopyStmt:
            {
-               uint64  processed = DoCopy((CopyStmt *) parsetree);
+               uint64      processed = DoCopy((CopyStmt *) parsetree);
 
                if (completionTag)
                    snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
@@ -798,10 +798,10 @@ ProcessUtility(Node *parsetree,
                            stmt->unique,
                            stmt->primary,
                            stmt->isconstraint,
-                           false,              /* is_alter_table */
-                           true,               /* check_rights */
-                           false,              /* skip_build */
-                           false,              /* quiet */
+                           false,      /* is_alter_table */
+                           true,       /* check_rights */
+                           false,      /* skip_build */
+                           false,      /* quiet */
                            stmt->concurrent);  /* concurrent */
            }
            break;
@@ -1883,7 +1883,7 @@ GetCommandLogLevel(Node *parsetree)
 
        case T_SelectStmt:
            if (((SelectStmt *) parsetree)->into)
-               lev = LOGSTMT_DDL;          /* CREATE AS, SELECT INTO */
+               lev = LOGSTMT_DDL;      /* CREATE AS, SELECT INTO */
            else
                lev = LOGSTMT_ALL;
            break;
@@ -2053,7 +2053,7 @@ GetCommandLogLevel(Node *parsetree)
 
        case T_ExplainStmt:
            {
-               ExplainStmt  *stmt = (ExplainStmt *) parsetree;
+               ExplainStmt *stmt = (ExplainStmt *) parsetree;
 
                /* Look through an EXPLAIN ANALYZE to the contained stmt */
                if (stmt->analyze)
@@ -2128,7 +2128,7 @@ GetCommandLogLevel(Node *parsetree)
            break;
 
        case T_ReindexStmt:
-           lev = LOGSTMT_ALL;              /* should this be DDL? */
+           lev = LOGSTMT_ALL;  /* should this be DDL? */
            break;
 
        case T_CreateConversionStmt:
@@ -2153,7 +2153,7 @@ GetCommandLogLevel(Node *parsetree)
 
        case T_PrepareStmt:
            {
-               PrepareStmt  *stmt = (PrepareStmt *) parsetree;
+               PrepareStmt *stmt = (PrepareStmt *) parsetree;
 
                /* Look through a PREPARE to the contained stmt */
                return GetCommandLogLevel((Node *) stmt->query);
@@ -2162,9 +2162,9 @@ GetCommandLogLevel(Node *parsetree)
 
        case T_ExecuteStmt:
            {
-               ExecuteStmt  *stmt = (ExecuteStmt *) parsetree;
+               ExecuteStmt *stmt = (ExecuteStmt *) parsetree;
                PreparedStatement *pstmt;
-               ListCell *l;
+               ListCell   *l;
 
                /* Look through an EXECUTE to the referenced stmt(s) */
                lev = LOGSTMT_ALL;
@@ -2173,7 +2173,7 @@ GetCommandLogLevel(Node *parsetree)
                {
                    foreach(l, pstmt->query_list)
                    {
-                       Query   *query = (Query *) lfirst(l);
+                       Query      *query = (Query *) lfirst(l);
                        LogStmtLevel stmt_lev;
 
                        stmt_lev = GetQueryLogLevel(query);
@@ -2188,10 +2188,11 @@ GetCommandLogLevel(Node *parsetree)
            break;
 
        case T_Query:
+
            /*
             * In complicated situations (eg, EXPLAIN ANALYZE in an extended
-            * Query protocol), we might find an already-analyzed query
-            * within a utility statement.  Cope.
+            * Query protocol), we might find an already-analyzed query within
+            * a utility statement.  Cope.
             */
            lev = GetQueryLogLevel((Query *) parsetree);
            break;
@@ -2224,7 +2225,7 @@ GetQueryLogLevel(Query *parsetree)
    {
        case CMD_SELECT:
            if (parsetree->into != NULL)
-               lev = LOGSTMT_DDL;          /* CREATE AS, SELECT INTO */
+               lev = LOGSTMT_DDL;      /* CREATE AS, SELECT INTO */
            else
                lev = LOGSTMT_ALL;
            break;
index dd1f1649fad01ac3d4ac7b69f02d83266ba9f660..a29d31bd6ebf214526bc2bf6fd4a6af5c25537dc 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.132 2006/09/29 21:22:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.133 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2050,21 +2050,21 @@ array_set(ArrayType *array,
            dim[0] += addedbefore;
            lb[0] = indx[0];
            if (addedbefore > 1)
-               newhasnulls = true;             /* will insert nulls */
+               newhasnulls = true;     /* will insert nulls */
        }
        if (indx[0] >= (dim[0] + lb[0]))
        {
            addedafter = indx[0] - (dim[0] + lb[0]) + 1;
            dim[0] += addedafter;
            if (addedafter > 1)
-               newhasnulls = true;             /* will insert nulls */
+               newhasnulls = true;     /* will insert nulls */
        }
    }
    else
    {
        /*
-        * XXX currently we do not support extending multi-dimensional
-        * arrays during assignment
+        * XXX currently we do not support extending multi-dimensional arrays
+        * during assignment
         */
        for (i = 0; i < ndim; i++)
        {
@@ -2338,7 +2338,7 @@ array_set_slice(ArrayType *array,
        if (lowerIndx[0] < lb[0])
        {
            if (upperIndx[0] < lb[0] - 1)
-               newhasnulls = true;             /* will insert nulls */
+               newhasnulls = true;     /* will insert nulls */
            addedbefore = lb[0] - lowerIndx[0];
            dim[0] += addedbefore;
            lb[0] = lowerIndx[0];
@@ -2346,7 +2346,7 @@ array_set_slice(ArrayType *array,
        if (upperIndx[0] >= (dim[0] + lb[0]))
        {
            if (lowerIndx[0] > (dim[0] + lb[0]))
-               newhasnulls = true;             /* will insert nulls */
+               newhasnulls = true;     /* will insert nulls */
            addedafter = upperIndx[0] - (dim[0] + lb[0]) + 1;
            dim[0] += addedafter;
        }
@@ -2354,15 +2354,15 @@ array_set_slice(ArrayType *array,
    else
    {
        /*
-        * XXX currently we do not support extending multi-dimensional
-        * arrays during assignment
+        * XXX currently we do not support extending multi-dimensional arrays
+        * during assignment
         */
        for (i = 0; i < nSubscripts; i++)
        {
            if (lowerIndx[i] > upperIndx[i])
                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")));
            if (lowerIndx[i] < lb[i] ||
                upperIndx[i] >= (dim[i] + lb[i]))
                ereport(ERROR,
@@ -2377,7 +2377,7 @@ array_set_slice(ArrayType *array,
            if (lowerIndx[i] > upperIndx[i])
                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")));
        }
    }
 
@@ -3417,8 +3417,8 @@ array_contain_compare(ArrayType *array1, ArrayType *array2, bool matchall,
    /*
     * 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.
+    * typcache is used so that we have no memory leakage when being used as
+    * an index support function.
     */
    typentry = (TypeCacheEntry *) *fn_extra;
    if (typentry == NULL ||
@@ -3429,8 +3429,8 @@ array_contain_compare(ArrayType *array1, ArrayType *array2, bool matchall,
        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))));
        *fn_extra = (void *) typentry;
    }
    typlen = typentry->typlen;
@@ -3486,9 +3486,9 @@ array_contain_compare(ArrayType *array1, ArrayType *array2, bool matchall,
        }
 
        /*
-        * We assume that the comparison operator is strict, so a NULL
-        * can't match anything.  XXX this diverges from the "NULL=NULL"
-        * behavior of array_eq, should we act like that?
+        * We assume that the comparison operator is strict, so a NULL can't
+        * match anything.  XXX this diverges from the "NULL=NULL" behavior of
+        * array_eq, should we act like that?
         */
        if (isnull1)
        {
index 81f7e63650c878773479d79cf24afece51b3c662..fac642ddc97935f93de303a08f6ede9b423a0d99 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.171 2006/09/16 20:14:33 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.172 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -97,7 +97,7 @@ char     *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
  */
 static datetkn *timezonetktbl = NULL;
 
-static int sztimezonetktbl = 0;
+static int sztimezonetktbl = 0;
 
 static const datetkn datetktbl[] = {
 /* text, token, lexval */
@@ -176,7 +176,7 @@ static const datetkn datetktbl[] = {
    {YESTERDAY, RESERV, DTK_YESTERDAY}, /* yesterday midnight */
 };
 
-static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
+static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
 
 static datetkn deltatktbl[] = {
    /* text, token, lexval */
@@ -246,7 +246,7 @@ static datetkn deltatktbl[] = {
    {"yrs", UNITS, DTK_YEAR},   /* "years" relative */
 };
 
-static int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0];
+static int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0];
 
 static const datetkn *datecache[MAXDATEFIELDS] = {NULL};
 
@@ -562,12 +562,19 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen,
                if (*cp == '/')
                {
                    ftype[nf] = DTK_TZ;
-                   /* set the first character of the region to upper case
-                    * again*/
+
+                   /*
+                    * set the first character of the region to upper case
+                    * again
+                    */
                    field[nf][0] = pg_toupper((unsigned char) field[nf][0]);
-                   /* we have seen "Region/" of a POSIX timezone, continue to
-                    * read the City part */
-                   do {
+
+                   /*
+                    * we have seen "Region/" of a POSIX timezone, continue to
+                    * read the City part
+                    */
+                   do
+                   {
                        APPEND_CHAR(bufp, bufend, *cp++);
                        /* there is for example America/New_York */
                    } while (isalpha((unsigned char) *cp) || *cp == '_');
@@ -1303,13 +1310,14 @@ DecodeDateTime(char **field, int *ftype, int nf,
 
        if (zicTzFnum != -1)
        {
-           Datum tsTz;
-           Timestamp timestamp;
+           Datum       tsTz;
+           Timestamp   timestamp;
+
            tm2timestamp(tm, *fsec, NULL, ×tamp);
            tsTz = DirectFunctionCall2(timestamp_zone,
-                           DirectFunctionCall1(textin,
-                                           CStringGetDatum(field[zicTzFnum])),
-                           TimestampGetDatum(timestamp));
+                                      DirectFunctionCall1(textin,
+                                         CStringGetDatum(field[zicTzFnum])),
+                                      TimestampGetDatum(timestamp));
            timestamp2tm(DatumGetTimestampTz(tsTz), tzp, tm, fsec, NULL, NULL);
            fmask &= ~DTK_M(TZ);
        }
@@ -2920,7 +2928,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
                        tm->tm_mday += val * 7;
                        if (fval != 0)
                        {
-                           int extra_days;
+                           int         extra_days;
+
                            fval *= 7;
                            extra_days = (int32) fval;
                            tm->tm_mday += extra_days;
@@ -2928,6 +2937,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
                            if (fval != 0)
                            {
                                int         sec;
+
                                fval *= SECS_PER_DAY;
                                sec = fval;
                                tm->tm_sec += sec;
@@ -2945,7 +2955,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
                        tm->tm_mon += val;
                        if (fval != 0)
                        {
-                           int         day;
+                           int         day;
+
                            fval *= DAYS_PER_MONTH;
                            day = fval;
                            tm->tm_mday += day;
@@ -2953,6 +2964,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct pg_tm * tm,
                            if (fval != 0)
                            {
                                int         sec;
+
                                fval *= SECS_PER_DAY;
                                sec = fval;
                                tm->tm_sec += sec;
@@ -3808,7 +3820,7 @@ CheckDateTokenTables(void)
 void
 InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n)
 {
-   datetkn    *newtbl;
+   datetkn    *newtbl;
    int         i;
 
    /*
@@ -3844,29 +3856,28 @@ InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n)
 Datum
 pg_timezone_abbrevs(PG_FUNCTION_ARGS)
 {
-   FuncCallContext    *funcctx;
-   int                *pindex;
-   Datum               result;
-   HeapTuple           tuple;
-   Datum               values[3];
-   bool                nulls[3];
-   char                buffer[TOKMAXLEN + 1];
-   unsigned char      *p;
-   struct pg_tm        tm;
-   Interval           *resInterval;
+   FuncCallContext *funcctx;
+   int        *pindex;
+   Datum       result;
+   HeapTuple   tuple;
+   Datum       values[3];
+   bool        nulls[3];
+   char        buffer[TOKMAXLEN + 1];
+   unsigned char *p;
+   struct pg_tm tm;
+   Interval   *resInterval;
 
    /* stuff done only on the first call of the function */
    if (SRF_IS_FIRSTCALL())
    {
-       TupleDesc       tupdesc;
-       MemoryContext   oldcontext;
+       TupleDesc   tupdesc;
+       MemoryContext oldcontext;
 
        /* create a function context for cross-call persistence */
        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);
 
@@ -3901,8 +3912,8 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
    MemSet(nulls, 0, sizeof(nulls));
 
    /*
-    * Convert name to text, using upcasing conversion that is the inverse
-    * of what ParseDateTime() uses.
+    * Convert name to text, using upcasing conversion that is the inverse of
+    * what ParseDateTime() uses.
     */
    strncpy(buffer, timezonetktbl[*pindex].token, TOKMAXLEN);
    buffer[TOKMAXLEN] = '\0';   /* may not be null-terminated */
@@ -3936,32 +3947,31 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
 Datum
 pg_timezone_names(PG_FUNCTION_ARGS)
 {
-   MemoryContext   oldcontext;
-   FuncCallContext    *funcctx;
-   pg_tzenum          *tzenum;
-   pg_tz              *tz;
-   Datum               result;
-   HeapTuple           tuple;
-   Datum               values[4];
-   bool                nulls[4];
+   MemoryContext oldcontext;
+   FuncCallContext *funcctx;
+   pg_tzenum  *tzenum;
+   pg_tz      *tz;
+   Datum       result;
+   HeapTuple   tuple;
+   Datum       values[4];
+   bool        nulls[4];
    int         tzoff;
-   struct pg_tm        tm;
+   struct pg_tm tm;
    fsec_t      fsec;
    char       *tzn;
-   Interval           *resInterval;
-   struct pg_tm        itm;
+   Interval   *resInterval;
+   struct pg_tm itm;
 
    /* stuff done only on the first call of the function */
    if (SRF_IS_FIRSTCALL())
    {
-       TupleDesc       tupdesc;
+       TupleDesc   tupdesc;
 
        /* create a function context for cross-call persistence */
        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);
 
@@ -4021,7 +4031,7 @@ pg_timezone_names(PG_FUNCTION_ARGS)
    MemSet(nulls, 0, sizeof(nulls));
 
    values[0] = DirectFunctionCall1(textin,
-                                   CStringGetDatum(pg_get_timezone_name(tz)));
+                                 CStringGetDatum(pg_get_timezone_name(tz)));
 
    values[1] = DirectFunctionCall1(textin,
                                    CStringGetDatum(tzn ? tzn : ""));
index 2126c6b87b2ede32c3e4bfff75749fd4a47a58ea..590c561589db426f39e7c89a09fbbff0d0c8f049 100644 (file)
@@ -25,7 +25,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/domains.c,v 1.3 2006/08/04 21:33:36 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/domains.c,v 1.4 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -146,8 +146,8 @@ domain_check_input(Datum value, bool isnull, DomainIOData *my_extra)
                    /*
                     * Set up value to be returned by CoerceToDomainValue
                     * nodes.  Unlike ExecEvalCoerceToDomain, this econtext
-                    * couldn't be shared with anything else, so no need
-                    * to save and restore fields.
+                    * couldn't be shared with anything else, so no need to
+                    * save and restore fields.
                     */
                    econtext->domainValue_datum = value;
                    econtext->domainValue_isNull = isnull;
@@ -174,8 +174,8 @@ domain_check_input(Datum value, bool isnull, DomainIOData *my_extra)
 
    /*
     * Before exiting, call any shutdown callbacks and reset econtext's
-    * per-tuple memory.  This avoids leaking non-memory resources,
-    * if anything in the expression(s) has any.
+    * per-tuple memory.  This avoids leaking non-memory resources, if
+    * anything in the expression(s) has any.
     */
    if (econtext)
        ReScanExprContext(econtext);
@@ -194,9 +194,9 @@ domain_in(PG_FUNCTION_ARGS)
    Datum       value;
 
    /*
-    * Since domain_in is not strict, we have to check for null inputs.
-    * The typioparam argument should never be null in normal system usage,
-    * but it could be null in a manual invocation --- if so, just return null.
+    * Since domain_in is not strict, we have to check for null inputs. The
+    * typioparam argument should never be null in normal system usage, but it
+    * could be null in a manual invocation --- if so, just return null.
     */
    if (PG_ARGISNULL(0))
        string = NULL;
@@ -207,8 +207,8 @@ domain_in(PG_FUNCTION_ARGS)
    domainType = PG_GETARG_OID(1);
 
    /*
-    * We arrange to look up the needed info just once per series of
-    * calls, assuming the domain type doesn't change underneath us.
+    * We arrange to look up the needed info just once per series of calls,
+    * assuming the domain type doesn't change underneath us.
     */
    my_extra = (DomainIOData *) fcinfo->flinfo->fn_extra;
    if (my_extra == NULL)
@@ -254,9 +254,9 @@ domain_recv(PG_FUNCTION_ARGS)
    Datum       value;
 
    /*
-    * Since domain_recv is not strict, we have to check for null inputs.
-    * The typioparam argument should never be null in normal system usage,
-    * but it could be null in a manual invocation --- if so, just return null.
+    * Since domain_recv is not strict, we have to check for null inputs. The
+    * typioparam argument should never be null in normal system usage, but it
+    * could be null in a manual invocation --- if so, just return null.
     */
    if (PG_ARGISNULL(0))
        buf = NULL;
@@ -267,8 +267,8 @@ domain_recv(PG_FUNCTION_ARGS)
    domainType = PG_GETARG_OID(1);
 
    /*
-    * We arrange to look up the needed info just once per series of
-    * calls, assuming the domain type doesn't change underneath us.
+    * We arrange to look up the needed info just once per series of calls,
+    * assuming the domain type doesn't change underneath us.
     */
    my_extra = (DomainIOData *) fcinfo->flinfo->fn_extra;
    if (my_extra == NULL)
index 1f8d081c8bf31b443210ed13bac8bc125046191c..c4fbe89455ca82d9baa58fa0e6f0dd29cc844e72 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.128 2006/07/28 18:33:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.129 2006/10/04 00:29:58 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #define HAVE_FINITE 1
 #endif
 
-/* Visual C++ etc lacks NAN, and won't accept 0.0/0.0.  NAN definition from 
+/* Visual C++ etc lacks NAN, and won't accept 0.0/0.0.  NAN definition from
  * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrfNotNumberNANItems.asp
  */
 #if defined(WIN32) && !defined(NAN)
 static const uint32 nan[2] = {0xffffffff, 0x7fffffff};
+
 #define NAN (*(const double *) nan)
 #endif
 
@@ -2137,7 +2138,7 @@ float8_stddev_samp(PG_FUNCTION_ARGS)
  * in that order.  Note that Y is the first argument to the aggregates!
  *
  * It might seem attractive to optimize this by having multiple accumulator
- * functions that only calculate the sums actually needed.  But on most
+ * functions that only calculate the sums actually needed. But on most
  * modern machines, a couple of extra floating-point multiplies will be
  * insignificant compared to the other per-tuple overhead, so I've chosen
  * to minimize code space instead.
@@ -2150,7 +2151,12 @@ float8_regr_accum(PG_FUNCTION_ARGS)
    float8      newvalY = PG_GETARG_FLOAT8(1);
    float8      newvalX = PG_GETARG_FLOAT8(2);
    float8     *transvalues;
-   float8      N, sumX, sumX2, sumY, sumY2, sumXY;
+   float8      N,
+               sumX,
+               sumX2,
+               sumY,
+               sumY2,
+               sumXY;
 
    transvalues = check_float8_array(transarray, "float8_regr_accum", 6);
    N = transvalues[0];
@@ -2265,7 +2271,11 @@ float8_regr_sxy(PG_FUNCTION_ARGS)
 {
    ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
    float8     *transvalues;
-   float8      N, sumX, sumY, sumXY, numerator;
+   float8      N,
+               sumX,
+               sumY,
+               sumXY,
+               numerator;
 
    transvalues = check_float8_array(transarray, "float8_regr_sxy", 6);
    N = transvalues[0];
@@ -2327,7 +2337,11 @@ float8_covar_pop(PG_FUNCTION_ARGS)
 {
    ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
    float8     *transvalues;
-   float8      N, sumX, sumY, sumXY, numerator;
+   float8      N,
+               sumX,
+               sumY,
+               sumXY,
+               numerator;
 
    transvalues = check_float8_array(transarray, "float8_covar_pop", 6);
    N = transvalues[0];
@@ -2349,7 +2363,11 @@ float8_covar_samp(PG_FUNCTION_ARGS)
 {
    ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
    float8     *transvalues;
-   float8      N, sumX, sumY, sumXY, numerator;
+   float8      N,
+               sumX,
+               sumY,
+               sumXY,
+               numerator;
 
    transvalues = check_float8_array(transarray, "float8_covar_samp", 6);
    N = transvalues[0];
@@ -2371,8 +2389,15 @@ float8_corr(PG_FUNCTION_ARGS)
 {
    ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
    float8     *transvalues;
-   float8      N, sumX, sumX2, sumY, sumY2, sumXY, numeratorX,
-       numeratorY, numeratorXY;
+   float8      N,
+               sumX,
+               sumX2,
+               sumY,
+               sumY2,
+               sumXY,
+               numeratorX,
+               numeratorY,
+               numeratorXY;
 
    transvalues = check_float8_array(transarray, "float8_corr", 6);
    N = transvalues[0];
@@ -2391,7 +2416,7 @@ float8_corr(PG_FUNCTION_ARGS)
    numeratorXY = N * sumXY - sumX * sumY;
    if (numeratorX <= 0 || numeratorY <= 0)
        PG_RETURN_NULL();
-   
+
    PG_RETURN_FLOAT8(sqrt((numeratorXY * numeratorXY) /
                          (numeratorX * numeratorY)));
 }
@@ -2401,8 +2426,15 @@ float8_regr_r2(PG_FUNCTION_ARGS)
 {
    ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
    float8     *transvalues;
-   float8      N, sumX, sumX2, sumY, sumY2, sumXY, numeratorX,
-       numeratorY, numeratorXY;
+   float8      N,
+               sumX,
+               sumX2,
+               sumY,
+               sumY2,
+               sumXY,
+               numeratorX,
+               numeratorY,
+               numeratorXY;
 
    transvalues = check_float8_array(transarray, "float8_regr_r2", 6);
    N = transvalues[0];
@@ -2434,8 +2466,13 @@ float8_regr_slope(PG_FUNCTION_ARGS)
 {
    ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
    float8     *transvalues;
-   float8      N, sumX, sumX2, sumY, sumXY, numeratorX,
-       numeratorXY;
+   float8      N,
+               sumX,
+               sumX2,
+               sumY,
+               sumXY,
+               numeratorX,
+               numeratorXY;
 
    transvalues = check_float8_array(transarray, "float8_regr_slope", 6);
    N = transvalues[0];
@@ -2452,7 +2489,7 @@ float8_regr_slope(PG_FUNCTION_ARGS)
    numeratorXY = N * sumXY - sumX * sumY;
    if (numeratorX <= 0)
        PG_RETURN_NULL();
-   
+
    PG_RETURN_FLOAT8(numeratorXY / numeratorX);
 }
 
@@ -2461,8 +2498,13 @@ float8_regr_intercept(PG_FUNCTION_ARGS)
 {
    ArrayType  *transarray = PG_GETARG_ARRAYTYPE_P(0);
    float8     *transvalues;
-   float8      N, sumX, sumX2, sumY, sumXY, numeratorX,
-       numeratorXXY;
+   float8      N,
+               sumX,
+               sumX2,
+               sumY,
+               sumXY,
+               numeratorX,
+               numeratorXXY;
 
    transvalues = check_float8_array(transarray, "float8_regr_intercept", 6);
    N = transvalues[0];
@@ -2479,7 +2521,7 @@ float8_regr_intercept(PG_FUNCTION_ARGS)
    numeratorXXY = sumY * sumX2 - sumX * sumXY;
    if (numeratorX <= 0)
        PG_RETURN_NULL();
-   
+
    PG_RETURN_FLOAT8(numeratorXXY / numeratorX);
 }
 
@@ -2744,13 +2786,13 @@ cbrt(double x)
    double      tmpres = pow(absx, (double) 1.0 / (double) 3.0);
 
    /*
-    * The result is somewhat inaccurate --- not really pow()'s fault,
-    * as the exponent it's handed contains roundoff error.  We can improve
-    * the accuracy by doing one iteration of Newton's formula.  Beware of
-    * zero input however.
+    * The result is somewhat inaccurate --- not really pow()'s fault, as the
+    * exponent it's handed contains roundoff error.  We can improve the
+    * accuracy by doing one iteration of Newton's formula.  Beware of zero
+    * input however.
     */
    if (tmpres > 0.0)
-       tmpres -= (tmpres - absx/(tmpres*tmpres)) / (double) 3.0;
+       tmpres -= (tmpres - absx / (tmpres * tmpres)) / (double) 3.0;
 
    return isneg ? -tmpres : tmpres;
 }
index 53cf15319d4ee2533b5db3bc81132efaf7a3cb03..d97c1bf405a6b23dd2be497f9945da082b8f2cd8 100644 (file)
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
  * formatting.c
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.112 2006/09/10 22:54:47 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.113 2006/10/04 00:29:59 momjian Exp $
  *
  *
  *  Portions Copyright (c) 1999-2006, PostgreSQL Global Development Group
@@ -83,7 +83,7 @@
 #include "utils/numeric.h"
 #include "utils/pg_locale.h"
 
-#define    _(x)    gettext((x))
+#define _(x)   gettext((x))
 
 /* ----------
  * Routines type
@@ -1708,7 +1708,7 @@ strdigits_len(char *str)
 
    len = strspace_len(str);
    p += len;
-   
+
    while (*p && isdigit((unsigned char) *p) && len <= DCH_MAX_ITEM_SIZ)
    {
        len++;
@@ -1828,7 +1828,7 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval,
            {
                sprintf(inout, "%0*d", S_FM(suf) ? 0 : 2,
                        tm->tm_hour % (HOURS_PER_DAY / 2) == 0 ? 12 :
-                       tm->tm_hour % (HOURS_PER_DAY / 2));
+                       tm->tm_hour % (HOURS_PER_DAY / 2));
                if (S_THth(suf))
                    str_numth(p_inout, inout, 0);
                return strlen(p_inout);
@@ -2084,8 +2084,8 @@ dch_date(int arg, char *inout, int suf, bool is_to_char, bool is_interval,
        tmfc = (TmFromChar *) data;
 
    /*
-    * In the FROM-char there is no difference between "January" or "JANUARY" or
-    * "january", all is before search convert to "first-upper". This
+    * In the FROM-char there is no 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)
@@ -2863,7 +2863,7 @@ datetime_to_char_body(TmToChar *tmtc, text *fmt, bool is_interval)
 static char *
 localize_month_full(int index)
 {
-   char    *m  = NULL;
+   char       *m = NULL;
 
    switch (index)
    {
@@ -2911,7 +2911,7 @@ localize_month_full(int index)
 static char *
 localize_month(int index)
 {
-   char    *m  = NULL;
+   char       *m = NULL;
 
    switch (index)
    {
@@ -2959,7 +2959,7 @@ localize_month(int index)
 static char *
 localize_day_full(int index)
 {
-   char    *d  = NULL;
+   char       *d = NULL;
 
    switch (index)
    {
@@ -2992,7 +2992,7 @@ localize_day_full(int index)
 static char *
 localize_day(int index)
 {
-   char    *d  = NULL;
+   char       *d = NULL;
 
    switch (index)
    {
index 0a93354697c6bdb1d550dbab632df48ea141917f..3970bda83d2c2c0600073dd07a867e6a1a469e12 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.74 2006/06/12 16:28:52 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.75 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -209,10 +209,10 @@ int2vectorrecv(PG_FUNCTION_ARGS)
    int2vector *result;
 
    /*
-    * Normally one would call array_recv() using DirectFunctionCall3,
-    * but that does not work since array_recv wants to cache some data
-    * using fcinfo->flinfo->fn_extra.  So we need to pass it our own
-    * flinfo parameter.
+    * Normally one would call array_recv() using DirectFunctionCall3, but
+    * that does not work since array_recv wants to cache some data using
+    * fcinfo->flinfo->fn_extra.  So we need to pass it our own flinfo
+    * parameter.
     */
    InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL);
 
@@ -736,9 +736,10 @@ int4mul(PG_FUNCTION_ARGS)
    int32       result;
 
 #ifdef WIN32
+
    /*
-    *  Win32 doesn't throw a catchable exception for
-    *  SELECT -2147483648 * (-1);  -- INT_MIN
+    * Win32 doesn't throw a catchable exception for SELECT -2147483648 *
+    * (-1);  -- INT_MIN
     */
    if (arg2 == -1 && arg1 == INT_MIN)
        ereport(ERROR,
@@ -782,9 +783,10 @@ int4div(PG_FUNCTION_ARGS)
                 errmsg("division by zero")));
 
 #ifdef WIN32
+
    /*
-    *  Win32 doesn't throw a catchable exception for
-    *  SELECT -2147483648 / (-1); -- INT_MIN
+    * Win32 doesn't throw a catchable exception for SELECT -2147483648 /
+    * (-1); -- INT_MIN
     */
    if (arg2 == -1 && arg1 == INT_MIN)
        ereport(ERROR,
index 00432994c5b0b070ce4d9a725fa70128a88a94c1..903d415327fc8629c2e9cf57cab0fac3254b9cda 100644 (file)
@@ -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.61 2006/07/28 18:33:04 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.62 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -696,7 +696,7 @@ int8inc(PG_FUNCTION_ARGS)
 
 /*
  * These functions are exactly like int8inc but are used for aggregates that
- * count only non-null values.  Since the functions are declared strict,
+ * count only non-null values. Since the functions are declared strict,
  * the null checks happen before we ever get here, and all we need do is
  * increment the state value.  We could actually make these pg_proc entries
  * point right at int8inc, but then the opr_sanity regression test would
index e2026218bf523c1fa754e1be0b2ba46e51d9ddc9..4223bffb1883af2531f18fcc5fe667be3cc8c1ac 100644 (file)
@@ -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.65 2006/09/04 18:32:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/like.c,v 1.66 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,12 +66,12 @@ wchareq(char *p1, char *p2)
 
 /*
  * Formerly we had a routine iwchareq() here that tried to do case-insensitive
- * comparison of multibyte characters.  It did not work at all, however,
+ * comparison of multibyte characters. It did not work at all, however,
  * because it relied on tolower() which has a single-byte API ... and
  * towlower() wouldn't be much better since we have no suitably cheap way
  * of getting a single character transformed to the system's wchar_t format.
  * So now, we just downcase the strings using lower() and apply regular LIKE
- * comparison.  This should be revisited when we install better locale support.
+ * comparison. This should be revisited when we install better locale support.
  *
  * Note that MBMatchText and MBMatchTextIC do exactly the same thing now.
  * Is it worth refactoring to avoid duplicated code?  They might become
@@ -286,12 +286,12 @@ nameiclike(PG_FUNCTION_ARGS)
    else
    {
        /* Force inputs to lower case to achieve case insensitivity */
-       text   *strtext;
+       text       *strtext;
 
        strtext = DatumGetTextP(DirectFunctionCall1(name_text,
                                                    NameGetDatum(str)));
        strtext = DatumGetTextP(DirectFunctionCall1(lower,
-                                                   PointerGetDatum(strtext)));
+                                                 PointerGetDatum(strtext)));
        pat = DatumGetTextP(DirectFunctionCall1(lower,
                                                PointerGetDatum(pat)));
 
@@ -327,12 +327,12 @@ nameicnlike(PG_FUNCTION_ARGS)
    else
    {
        /* Force inputs to lower case to achieve case insensitivity */
-       text   *strtext;
+       text       *strtext;
 
        strtext = DatumGetTextP(DirectFunctionCall1(name_text,
                                                    NameGetDatum(str)));
        strtext = DatumGetTextP(DirectFunctionCall1(lower,
-                                                   PointerGetDatum(strtext)));
+                                                 PointerGetDatum(strtext)));
        pat = DatumGetTextP(DirectFunctionCall1(lower,
                                                PointerGetDatum(pat)));
 
index a9d8b8b88f470c755525c4f0ed0c21236bdacdcb..8e0a7bcf98d336d4a4d911ac9c80e7cf4ba1b15d 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 2002-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.26 2006/09/22 23:20:14 tgl Exp $
+ *     $PostgreSQL: pgsql/src/backend/utils/adt/lockfuncs.c,v 1.27 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -258,8 +258,8 @@ pg_lock_status(PG_FUNCTION_ARGS)
        else
            nulls[10] = 'n';
        values[11] = DirectFunctionCall1(textin,
-                                    CStringGetDatum(GetLockmodeName(LOCK_LOCKMETHOD(*lock),
-                                                                    mode)));
+                     CStringGetDatum(GetLockmodeName(LOCK_LOCKMETHOD(*lock),
+                                                     mode)));
        values[12] = BoolGetDatum(granted);
 
        tuple = heap_formtuple(funcctx->tuple_desc, values, nulls);
@@ -361,7 +361,7 @@ pg_try_advisory_lock_shared_int8(PG_FUNCTION_ARGS)
 }
 
 /*
- * pg_advisory_unlock(int8) - release exclusive lock on an int8 key 
+ * pg_advisory_unlock(int8) - release exclusive lock on an int8 key
  *
  * Returns true if successful, false if lock was not held
 */
@@ -473,7 +473,7 @@ pg_try_advisory_lock_shared_int4(PG_FUNCTION_ARGS)
 }
 
 /*
- * pg_advisory_unlock(int4, int4) - release exclusive lock on 2 int4 keys 
+ * pg_advisory_unlock(int4, int4) - release exclusive lock on 2 int4 keys
  *
  * Returns true if successful, false if lock was not held
 */
index 22c8af482c1874deede13ba63e1883e5a3fa1a3f..014d2c8bf6dbaf84506c0e663a8885713bae136c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.53 2006/07/14 14:52:24 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.54 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -272,16 +272,16 @@ pg_sleep(PG_FUNCTION_ARGS)
    float8      endtime;
 
    /*
-    * We break the requested sleep into segments of no more than 1 second,
-    * to put an upper bound on how long it will take us to respond to a
-    * cancel or die interrupt.  (Note that pg_usleep is interruptible by
-    * signals on some platforms but not others.)  Also, this method avoids
-    * exposing pg_usleep's upper bound on allowed delays.
+    * We break the requested sleep into segments of no more than 1 second, to
+    * put an upper bound on how long it will take us to respond to a cancel
+    * or die interrupt.  (Note that pg_usleep is interruptible by signals on
+    * some platforms but not others.)  Also, this method avoids exposing
+    * pg_usleep's upper bound on allowed delays.
     *
-    * By computing the intended stop time initially, we avoid accumulation
-    * of extra delay across multiple sleeps.  This also ensures we won't
-    * delay less than the specified time if pg_usleep is interrupted
-    * by other signals such as SIGHUP.
+    * By computing the intended stop time initially, we avoid accumulation of
+    * extra delay across multiple sleeps.  This also ensures we won't delay
+    * less than the specified time if pg_usleep is interrupted by other
+    * signals such as SIGHUP.
     */
 
 #ifdef HAVE_INT64_TIMESTAMP
index 2624c203f7c46c44fe093596d4aeca6158dafda0..bd7406bc2b5dece6877a0ac6fdbf4ee0b62f7d7b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * PostgreSQL type definitions for the INET and CIDR types.
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.65 2006/02/11 20:39:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.66 2006/10/04 00:29:59 momjian Exp $
  *
  * Jon Postel RIP 16 Oct 1998
  */
@@ -181,7 +181,7 @@ cidr_out(PG_FUNCTION_ARGS)
  * family, bits, is_cidr, address length, address in network byte order.
  *
  * Presence of is_cidr is largely for historical reasons, though it might
- * allow some code-sharing on the client side.  We send it correctly on
+ * allow some code-sharing on the client side. We send it correctly on
  * output, but ignore the value on input.
  */
 static inet *
@@ -201,14 +201,14 @@ network_recv(StringInfo buf, bool is_cidr)
        ip_family(addr) != PGSQL_AF_INET6)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
-                /* translator: %s is inet or cidr */
+       /* translator: %s is inet or cidr */
                 errmsg("invalid address family in external \"%s\" value",
                        is_cidr ? "cidr" : "inet")));
    bits = pq_getmsgbyte(buf);
    if (bits < 0 || bits > ip_maxbits(addr))
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
-                /* translator: %s is inet or cidr */
+       /* translator: %s is inet or cidr */
                 errmsg("invalid bits in external \"%s\" value",
                        is_cidr ? "cidr" : "inet")));
    ip_bits(addr) = bits;
@@ -217,7 +217,7 @@ network_recv(StringInfo buf, bool is_cidr)
    if (nb != ip_addrsize(addr))
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
-                /* translator: %s is inet or cidr */
+       /* translator: %s is inet or cidr */
                 errmsg("invalid length in external \"%s\" value",
                        is_cidr ? "cidr" : "inet")));
    VARATT_SIZEP(addr) = VARHDRSZ +
@@ -1262,9 +1262,9 @@ inetnot(PG_FUNCTION_ARGS)
    dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct));
 
    {
-       int nb = ip_addrsize(ip);
-       unsigned char   *pip = ip_addr(ip);
-       unsigned char   *pdst = ip_addr(dst);
+       int         nb = ip_addrsize(ip);
+       unsigned char *pip = ip_addr(ip);
+       unsigned char *pdst = ip_addr(dst);
 
        while (nb-- > 0)
            pdst[nb] = ~pip[nb];
@@ -1295,10 +1295,10 @@ inetand(PG_FUNCTION_ARGS)
                 errmsg("cannot AND inet values of different sizes")));
    else
    {
-       int nb = ip_addrsize(ip);
-       unsigned char   *pip = ip_addr(ip);
-       unsigned char   *pip2 = ip_addr(ip2);
-       unsigned char   *pdst = ip_addr(dst);
+       int         nb = ip_addrsize(ip);
+       unsigned char *pip = ip_addr(ip);
+       unsigned char *pip2 = ip_addr(ip2);
+       unsigned char *pdst = ip_addr(dst);
 
        while (nb-- > 0)
            pdst[nb] = pip[nb] & pip2[nb];
@@ -1329,10 +1329,10 @@ inetor(PG_FUNCTION_ARGS)
                 errmsg("cannot OR inet values of different sizes")));
    else
    {
-       int nb = ip_addrsize(ip);
-       unsigned char   *pip = ip_addr(ip);
-       unsigned char   *pip2 = ip_addr(ip2);
-       unsigned char   *pdst = ip_addr(dst);
+       int         nb = ip_addrsize(ip);
+       unsigned char *pip = ip_addr(ip);
+       unsigned char *pip2 = ip_addr(ip2);
+       unsigned char *pdst = ip_addr(dst);
 
        while (nb-- > 0)
            pdst[nb] = pip[nb] | pip2[nb];
@@ -1356,32 +1356,34 @@ internal_inetpl(inet *ip, int64 addend)
    dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct));
 
    {
-       int nb = ip_addrsize(ip);
-       unsigned char   *pip = ip_addr(ip);
-       unsigned char   *pdst = ip_addr(dst);
-       int carry = 0;
+       int         nb = ip_addrsize(ip);
+       unsigned char *pip = ip_addr(ip);
+       unsigned char *pdst = ip_addr(dst);
+       int         carry = 0;
 
        while (nb-- > 0)
        {
            carry = pip[nb] + (int) (addend & 0xFF) + carry;
            pdst[nb] = (unsigned char) (carry & 0xFF);
            carry >>= 8;
+
            /*
             * We have to be careful about right-shifting addend because
-            * right-shift isn't portable for negative values, while
-            * simply dividing by 256 doesn't work (the standard rounding
-            * is in the wrong direction, besides which there may be machines
-            * out there that round the wrong way).  So, explicitly clear
-            * the low-order byte to remove any doubt about the correct
-            * result of the division, and then divide rather than shift.
+            * right-shift isn't portable for negative values, while simply
+            * dividing by 256 doesn't work (the standard rounding is in the
+            * wrong direction, besides which there may be machines out there
+            * that round the wrong way).  So, explicitly clear the low-order
+            * byte to remove any doubt about the correct result of the
+            * division, and then divide rather than shift.
             */
            addend &= ~((int64) 0xFF);
            addend /= 0x100;
        }
+
        /*
-        * At this point we should have addend and carry both zero if
-        * original addend was >= 0, or addend -1 and carry 1 if original
-        * addend was < 0.  Anything else means overflow.
+        * At this point we should have addend and carry both zero if original
+        * addend was >= 0, or addend -1 and carry 1 if original addend was <
+        * 0.  Anything else means overflow.
         */
        if (!((addend == 0 && carry == 0) ||
              (addend == -1 && carry == 1)))
@@ -1403,8 +1405,8 @@ internal_inetpl(inet *ip, int64 addend)
 Datum
 inetpl(PG_FUNCTION_ARGS)
 {
-   inet   *ip = PG_GETARG_INET_P(0);
-   int64   addend = PG_GETARG_INT64(1);
+   inet       *ip = PG_GETARG_INET_P(0);
+   int64       addend = PG_GETARG_INT64(1);
 
    PG_RETURN_INET_P(internal_inetpl(ip, addend));
 }
@@ -1413,8 +1415,8 @@ inetpl(PG_FUNCTION_ARGS)
 Datum
 inetmi_int8(PG_FUNCTION_ARGS)
 {
-   inet   *ip = PG_GETARG_INET_P(0);
-   int64   addend = PG_GETARG_INT64(1);
+   inet       *ip = PG_GETARG_INET_P(0);
+   int64       addend = PG_GETARG_INT64(1);
 
    PG_RETURN_INET_P(internal_inetpl(ip, -addend));
 }
@@ -1434,20 +1436,20 @@ inetmi(PG_FUNCTION_ARGS)
    else
    {
        /*
-        * We form the difference using the traditional complement,
-        * increment, and add rule, with the increment part being handled
-        * by starting the carry off at 1.  If you don't think integer
-        * arithmetic is done in two's complement, too bad.
+        * We form the difference using the traditional complement, increment,
+        * and add rule, with the increment part being handled by starting the
+        * carry off at 1.  If you don't think integer arithmetic is done in
+        * two's complement, too bad.
         */
-       int nb = ip_addrsize(ip);
-       int byte = 0;
-       unsigned char   *pip = ip_addr(ip);
-       unsigned char   *pip2 = ip_addr(ip2);
-       int carry = 1;
+       int         nb = ip_addrsize(ip);
+       int         byte = 0;
+       unsigned char *pip = ip_addr(ip);
+       unsigned char *pip2 = ip_addr(ip2);
+       int         carry = 1;
 
        while (nb-- > 0)
        {
-           int     lobyte;
+           int         lobyte;
 
            carry = pip[nb] + (~pip2[nb] & 0xFF) + carry;
            lobyte = carry & 0xFF;
@@ -1458,9 +1460,9 @@ inetmi(PG_FUNCTION_ARGS)
            else
            {
                /*
-                * Input wider than int64: check for overflow.  All bytes
-                * to the left of what will fit should be 0 or 0xFF,
-                * depending on sign of the now-complete result.
+                * Input wider than int64: check for overflow.  All bytes to
+                * the left of what will fit should be 0 or 0xFF, depending on
+                * sign of the now-complete result.
                 */
                if ((res < 0) ? (lobyte != 0xFF) : (lobyte != 0))
                    ereport(ERROR,
@@ -1472,8 +1474,8 @@ inetmi(PG_FUNCTION_ARGS)
        }
 
        /*
-        * If input is narrower than int64, overflow is not possible, but
-        * we have to do proper sign extension.
+        * If input is narrower than int64, overflow is not possible, but we
+        * have to do proper sign extension.
         */
        if (carry == 0 && byte < sizeof(int64))
            res |= ((int64) -1) << (byte * 8);
index 6d77c49c12374b41d8e0903a9aef52a70dc96a39..35b0221b85dc61677b8513bbd0f06d4e8c7da615 100644 (file)
@@ -14,7 +14,7 @@
  * Copyright (c) 1998-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.95 2006/10/03 21:25:55 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.96 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -253,10 +253,10 @@ static double numericvar_to_double_no_overflow(NumericVar *var);
 
 static int cmp_numerics(Numeric num1, Numeric num2);
 static int cmp_var(NumericVar *var1, NumericVar *var2);
-static int cmp_var_common(const NumericDigit *var1digits, int var1ndigits,
-                          int var1weight, int var1sign,
-                          const NumericDigit *var2digits, int var2ndigits,
-                          int var2weight, int var2sign);
+static int cmp_var_common(const NumericDigit *var1digits, int var1ndigits,
+              int var1weight, int var1sign,
+              const NumericDigit *var2digits, int var2ndigits,
+              int var2weight, int var2sign);
 static void add_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
 static void sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result);
 static void mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result,
@@ -278,10 +278,10 @@ static void power_var_int(NumericVar *base, int exp, NumericVar *result,
              int rscale);
 
 static int cmp_abs(NumericVar *var1, NumericVar *var2);
-static int cmp_abs_common(const NumericDigit *var1digits, int var1ndigits,
-                          int var1weight,
-                          const NumericDigit *var2digits, int var2ndigits,
-                          int var2weight);
+static int cmp_abs_common(const NumericDigit *var1digits, int var1ndigits,
+              int var1weight,
+              const NumericDigit *var2digits, int var2ndigits,
+              int var2weight);
 static void add_abs(NumericVar *var1, NumericVar *var2, NumericVar *result);
 static void sub_abs(NumericVar *var1, NumericVar *var2, NumericVar *result);
 static void round_var(NumericVar *var, int rscale);
@@ -2228,9 +2228,8 @@ numeric_stddev_internal(ArrayType *transarray,
    set_var_from_num(N, &vN);
 
    /*
-    * Sample stddev and variance are undefined when N <= 1;
-    * population stddev is undefined when N == 0. Return NULL in
-    * either case.
+    * Sample stddev and variance are undefined when N <= 1; population stddev
+    * is undefined when N == 0. Return NULL in either case.
     */
    if (sample)
        comp = &const_one;
@@ -2257,7 +2256,7 @@ numeric_stddev_internal(ArrayType *transarray,
 
    mul_var(&vsumX, &vsumX, &vsumX, rscale);    /* vsumX = sumX * sumX */
    mul_var(&vN, &vsumX2, &vsumX2, rscale);     /* vsumX2 = N * sumX2 */
-   sub_var(&vsumX2, &vsumX, &vsumX2);          /* N * sumX2 - sumX * sumX */
+   sub_var(&vsumX2, &vsumX, &vsumX2);  /* N * sumX2 - sumX * sumX */
 
    if (cmp_var(&vsumX2, &const_zero) <= 0)
    {
@@ -2266,11 +2265,11 @@ numeric_stddev_internal(ArrayType *transarray,
    }
    else
    {
-       mul_var(&vN, &vNminus1, &vNminus1, 0);              /* N * (N - 1) */
+       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 */
        if (!variance)
-           sqrt_var(&vsumX, &vsumX, rscale);               /* stddev */
+           sqrt_var(&vsumX, &vsumX, rscale);   /* stddev */
 
        res = make_result(&vsumX);
    }
@@ -2286,8 +2285,8 @@ numeric_stddev_internal(ArrayType *transarray,
 Datum
 numeric_var_samp(PG_FUNCTION_ARGS)
 {
-   Numeric res;
-   bool is_null;
+   Numeric     res;
+   bool        is_null;
 
    res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0),
                                  true, true, &is_null);
@@ -2301,8 +2300,8 @@ numeric_var_samp(PG_FUNCTION_ARGS)
 Datum
 numeric_stddev_samp(PG_FUNCTION_ARGS)
 {
-   Numeric res;
-   bool is_null;
+   Numeric     res;
+   bool        is_null;
 
    res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0),
                                  false, true, &is_null);
@@ -2316,8 +2315,8 @@ numeric_stddev_samp(PG_FUNCTION_ARGS)
 Datum
 numeric_var_pop(PG_FUNCTION_ARGS)
 {
-   Numeric res;
-   bool is_null;
+   Numeric     res;
+   bool        is_null;
 
    res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0),
                                  true, false, &is_null);
@@ -2331,8 +2330,8 @@ numeric_var_pop(PG_FUNCTION_ARGS)
 Datum
 numeric_stddev_pop(PG_FUNCTION_ARGS)
 {
-   Numeric res;
-   bool is_null;
+   Numeric     res;
+   bool        is_null;
 
    res = numeric_stddev_internal(PG_GETARG_ARRAYTYPE_P(0),
                                  false, false, &is_null);
@@ -3219,7 +3218,7 @@ apply_typmod(NumericVar *var, int32 typmod)
                             errmsg("numeric field overflow"),
                             errdetail("A field with precision %d, scale %d must round to an absolute value less than %s%d.",
                                       precision, scale,
-                                      /* Display 10^0 as 1 */
+                   /* Display 10^0 as 1 */
                                       maxdigits ? "10^" : "",
                                       maxdigits ? maxdigits : 1
                                       )));
@@ -3415,8 +3414,8 @@ cmp_var(NumericVar *var1, NumericVar *var2)
 /*
  * cmp_var_common() -
  *
- *  Main routine of cmp_var(). This function can be used by both
- *  NumericVar and Numeric. 
+ * Main routine of cmp_var(). This function can be used by both
+ * NumericVar and Numeric.
  */
 static int
 cmp_var_common(const NumericDigit *var1digits, int var1ndigits,
@@ -4853,13 +4852,13 @@ cmp_abs(NumericVar *var1, NumericVar *var2)
 /* ----------
  * cmp_abs_common() -
  *
- *  Main routine of cmp_abs(). This function can be used by both
- *  NumericVar and Numeric. 
+ * Main routine of cmp_abs(). This function can be used by both
+ * NumericVar and Numeric.
  * ----------
  */
 static int
 cmp_abs_common(const NumericDigit *var1digits, int var1ndigits, int var1weight,
-              const NumericDigit *var2digits, int var2ndigits, int var2weight)
+            const NumericDigit *var2digits, int var2ndigits, int var2weight)
 {
    int         i1 = 0;
    int         i2 = 0;
index 8ba769fafa3ee680d68b4a2349f9324601f8f53b..20142cb771a256b2ede1f45b5b6d315ae5de8f9b 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.68 2006/03/05 15:58:43 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.69 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -258,10 +258,10 @@ oidvectorrecv(PG_FUNCTION_ARGS)
    oidvector  *result;
 
    /*
-    * Normally one would call array_recv() using DirectFunctionCall3,
-    * but that does not work since array_recv wants to cache some data
-    * using fcinfo->flinfo->fn_extra.  So we need to pass it our own
-    * flinfo parameter.
+    * Normally one would call array_recv() using DirectFunctionCall3, but
+    * that does not work since array_recv wants to cache some data using
+    * fcinfo->flinfo->fn_extra.  So we need to pass it our own flinfo
+    * parameter.
     */
    InitFunctionCallInfoData(locfcinfo, fcinfo->flinfo, 3, NULL, NULL);
 
index aa08c7bc8d01ba69fc7320021fec595c2f57d8aa..da81d79f392576a4bba5ecbb64ae6ba9fd533603 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Portions Copyright (c) 2002-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.36 2006/06/03 17:36:10 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/pg_locale.c,v 1.37 2006/10/04 00:29:59 momjian Exp $
  *
  *-----------------------------------------------------------------------
  */
@@ -70,6 +70,7 @@ static bool CurrentLocaleConvValid = false;
 
 static char lc_collate_envbuf[LC_ENV_BUFSIZE];
 static char lc_ctype_envbuf[LC_ENV_BUFSIZE];
+
 #ifdef LC_MESSAGES
 static char lc_messages_envbuf[LC_ENV_BUFSIZE];
 #endif
@@ -93,18 +94,19 @@ static char lc_time_envbuf[LC_ENV_BUFSIZE];
 char *
 pg_perm_setlocale(int category, const char *locale)
 {
-   char   *result;
+   char       *result;
    const char *envvar;
-   char   *envbuf;
+   char       *envbuf;
 
 #ifndef WIN32
    result = setlocale(category, locale);
 #else
+
    /*
-    * On Windows, setlocale(LC_MESSAGES) does not work, so just assume
-    * that the given value is good and set it in the environment variables.
-    * We must ignore attempts to set to "", which means "keep using the
-    * old environment value".
+    * On Windows, setlocale(LC_MESSAGES) does not work, so just assume that
+    * the given value is good and set it in the environment variables. We
+    * must ignore attempts to set to "", which means "keep using the old
+    * environment value".
     */
 #ifdef LC_MESSAGES
    if (category == LC_MESSAGES)
@@ -116,7 +118,7 @@ pg_perm_setlocale(int category, const char *locale)
    else
 #endif
        result = setlocale(category, locale);
-#endif /* WIN32 */
+#endif   /* WIN32 */
 
    if (result == NULL)
        return result;          /* fall out immediately on failure */
@@ -156,12 +158,13 @@ pg_perm_setlocale(int category, const char *locale)
            break;
    }
 
-   snprintf(envbuf, LC_ENV_BUFSIZE-1, "%s=%s", envvar, result);
+   snprintf(envbuf, LC_ENV_BUFSIZE - 1, "%s=%s", envvar, result);
 
 #ifndef WIN32
    if (putenv(envbuf))
        return NULL;
 #else
+
    /*
     * On Windows, we need to modify both the process environment and the
     * cached version in msvcrt
@@ -251,8 +254,8 @@ locale_messages_assign(const char *value, bool doit, GucSource source)
    /*
     * LC_MESSAGES category does not exist everywhere, but accept it anyway
     *
-    * On Windows, we can't even check the value, so the non-doit case
-    * is a no-op
+    * On Windows, we can't even check the value, so the non-doit case is a
+    * no-op
     */
 #ifdef LC_MESSAGES
    if (doit)
index d14a4c8e2f6628f754720b867a67c8176a78528d..e2d302b5a64c9144c58111711a7e3a6ef9e6a2ba 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.33 2006/08/19 01:36:29 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.34 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -186,7 +186,7 @@ Datum
 pg_stat_get_last_vacuum_time(PG_FUNCTION_ARGS)
 {
    Oid         relid = PG_GETARG_OID(0);
-   TimestampTz result;
+   TimestampTz result;
    PgStat_StatTabEntry *tabentry;
 
    if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
@@ -204,7 +204,7 @@ Datum
 pg_stat_get_last_autovacuum_time(PG_FUNCTION_ARGS)
 {
    Oid         relid = PG_GETARG_OID(0);
-   TimestampTz result;
+   TimestampTz result;
    PgStat_StatTabEntry *tabentry;
 
    if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
@@ -222,7 +222,7 @@ Datum
 pg_stat_get_last_analyze_time(PG_FUNCTION_ARGS)
 {
    Oid         relid = PG_GETARG_OID(0);
-   TimestampTz result;
+   TimestampTz result;
    PgStat_StatTabEntry *tabentry;
 
    if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
@@ -240,7 +240,7 @@ Datum
 pg_stat_get_last_autoanalyze_time(PG_FUNCTION_ARGS)
 {
    Oid         relid = PG_GETARG_OID(0);
-   TimestampTz result;
+   TimestampTz result;
    PgStat_StatTabEntry *tabentry;
 
    if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
index a7d11eaa6d5ab034b130d5da6edcec30b98a452c..d249772064b9b2553236d883538c30393008b7c4 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.65 2006/07/14 14:52:24 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.66 2006/10/04 00:29:59 momjian Exp $
  *
  *     Alistair Crooks added the code for the regex caching
  *     agc - cached the regular expressions used - there's a good chance
@@ -554,7 +554,7 @@ similar_escape(PG_FUNCTION_ARGS)
     * which is bizarre enough to require some explanation.  "***:" is a
     * director prefix to force the regex to be treated as an ARE regardless
     * of the current regex_flavor setting.  We need "^" and "$" to force
-    * the pattern to match the entire input string as per SQL99 spec.  The
+    * the pattern to match the entire input string as per SQL99 spec.  The
     * "(?:" and ")" are a non-capturing set of parens; we have to have
     * parens in case the string contains "|", else the "^" and "$" will
     * be bound into the first and last alternatives which is not what we
index b58b99d2c8bd3aeb467e0e3306ceef31b55f905b..747ef66bf77454c06ceba04dbfcb575f4fef5d60 100644 (file)
@@ -17,7 +17,7 @@
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.88 2006/08/27 21:41:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.89 2006/10/04 00:29:59 momjian Exp $
  *
  * ----------
  */
@@ -214,17 +214,17 @@ 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 (so the deferred check should be skipped)
-    * or updated (in which case only the latest version of the row should
-    * be checked).  Test its liveness with HeapTupleSatisfiesItself.
+    * or updated (in which case only the latest version of the row should be
+    * checked).  Test its liveness with HeapTupleSatisfiesItself.
     *
     * NOTE: The normal coding rule is that one must acquire the buffer
-    * content lock to call HeapTupleSatisfiesFOO.  We can skip that here
+    * content lock to call HeapTupleSatisfiesFOO.  We can skip that here
     * because we know that AfterTriggerExecute just fetched the tuple
-    * successfully, so there cannot be a VACUUM compaction in progress
-    * on the page (either heap_fetch would have waited for the VACUUM,
-    * or the VACUUM's LockBufferForCleanup would be waiting for us to drop
-    * pin).  And since this is a row inserted by our open transaction,
-    * no one else can be entitled to change its xmin/xmax.
+    * successfully, so there cannot be a VACUUM compaction in progress on the
+    * page (either heap_fetch would have waited for the VACUUM, or the
+    * VACUUM's LockBufferForCleanup would be waiting for us to drop pin).
+    * And since this is a row inserted by our open transaction, no one else
+    * can be entitled to change its xmin/xmax.
     */
    Assert(new_row_buf != InvalidBuffer);
    if (!HeapTupleSatisfiesItself(new_row->t_data, new_row_buf))
index 821cc99e9f268afe7f974487bb295dd7443239dc..f5b42524be7810e89a280a28bc018b2445ad8a2b 100644 (file)
@@ -2,7 +2,7 @@
  * ruleutils.c - Functions to convert stored expressions/querytrees
  *             back to source text
  *
- *   $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.233 2006/10/01 17:23:38 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.234 2006/10/04 00:29:59 momjian Exp $
  **********************************************************************/
 
 #include "postgres.h"
@@ -141,7 +141,7 @@ static void get_utility_query_def(Query *query, deparse_context *context);
 static void get_basic_select_query(Query *query, deparse_context *context,
                       TupleDesc resultDesc);
 static void get_target_list(List *targetList, deparse_context *context,
-                           TupleDesc resultDesc);
+               TupleDesc resultDesc);
 static void get_setop_query(Node *setOp, Query *query,
                deparse_context *context,
                TupleDesc resultDesc);
@@ -176,7 +176,7 @@ static void get_from_clause_coldeflist(List *names, List *types, List *typmods,
 static void get_opclass_name(Oid opclass, Oid actual_datatype,
                 StringInfo buf);
 static Node *processIndirection(Node *node, deparse_context *context,
-                               bool printit);
+                  bool printit);
 static void printSubscripts(ArrayRef *aref, deparse_context *context);
 static char *generate_relation_name(Oid relid);
 static char *generate_function_name(Oid funcid, int nargs, Oid *argtypes);
@@ -530,10 +530,11 @@ pg_get_triggerdef(PG_FUNCTION_ARGS)
        {
            if (i > 0)
                appendStringInfo(&buf, ", ");
+
            /*
             * We form the string literal according to the prevailing setting
-            * of standard_conforming_strings; we never use E''.
-            * User is responsible for making sure result is used correctly.
+            * of standard_conforming_strings; we never use E''. User is
+            * responsible for making sure result is used correctly.
             */
            appendStringInfoChar(&buf, '\'');
            while (*p)
@@ -1017,7 +1018,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
 
                if (fullCommand && OidIsValid(conForm->conrelid))
                {
-                   char   *options = flatten_reloptions(conForm->conrelid);
+                   char       *options = flatten_reloptions(conForm->conrelid);
 
                    if (options)
                    {
@@ -1467,9 +1468,9 @@ deparse_context_for_subplan(const char *name, Node *subplan)
    RangeTblEntry *rte = makeNode(RangeTblEntry);
 
    /*
-    * We create an RTE_SPECIAL RangeTblEntry, and store the subplan in
-    * its funcexpr field.  RTE_SPECIAL nodes shouldn't appear in
-    * deparse contexts otherwise.
+    * We create an RTE_SPECIAL RangeTblEntry, and store the subplan in its
+    * funcexpr field.  RTE_SPECIAL nodes shouldn't appear in deparse contexts
+    * otherwise.
     */
    rte->rtekind = RTE_SPECIAL;
    rte->relid = InvalidOid;
@@ -1831,7 +1832,7 @@ get_values_def(List *values_lists, deparse_context *context)
        appendStringInfoChar(buf, '(');
        foreach(lc, sublist)
        {
-           Node   *col = (Node *) lfirst(lc);
+           Node       *col = (Node *) lfirst(lc);
 
            if (first_col)
                first_col = false;
@@ -1964,10 +1965,10 @@ get_basic_select_query(Query *query, deparse_context *context,
    }
 
    /*
-    * If the query looks like SELECT * FROM (VALUES ...), then print just
-    * the VALUES part.  This reverses what transformValuesClause() did at
-    * parse time.  If the jointree contains just a single VALUES RTE,
-    * we assume this case applies (without looking at the targetlist...)
+    * If the query looks like SELECT * FROM (VALUES ...), then print just the
+    * VALUES part.  This reverses what transformValuesClause() did at parse
+    * time.  If the jointree contains just a single VALUES RTE, we assume
+    * this case applies (without looking at the targetlist...)
     */
    if (list_length(query->jointree->fromlist) == 1)
    {
@@ -2083,10 +2084,10 @@ get_target_list(List *targetList, deparse_context *context,
        colno++;
 
        /*
-        * We special-case Var nodes rather than using get_rule_expr.
-        * This is needed because get_rule_expr will display a whole-row Var
-        * as "foo.*", which is the preferred notation in most contexts, but
-        * at the top level of a SELECT list it's not right (the parser will
+        * We special-case Var nodes rather than using get_rule_expr. This is
+        * needed because get_rule_expr will display a whole-row Var as
+        * "foo.*", which is the preferred notation in most contexts, but at
+        * the top level of a SELECT list it's not right (the parser will
         * expand that notation into multiple columns, yielding behavior
         * different from a whole-row Var).  We want just "foo", instead.
         */
@@ -2287,8 +2288,8 @@ get_insert_query_def(Query *query, deparse_context *context)
    List       *strippedexprs;
 
    /*
-    * If it's an INSERT ... SELECT or VALUES (...), (...), ...
-    * there will be a single RTE for the SELECT or VALUES.
+    * If it's an INSERT ... SELECT or VALUES (...), (...), ... there will be
+    * a single RTE for the SELECT or VALUES.
     */
    foreach(l, query->rtable)
    {
@@ -2300,7 +2301,7 @@ get_insert_query_def(Query *query, deparse_context *context)
                elog(ERROR, "too many subquery RTEs in INSERT");
            select_rte = rte;
        }
-       
+
        if (rte->rtekind == RTE_VALUES)
        {
            if (values_rte)
@@ -2326,12 +2327,12 @@ get_insert_query_def(Query *query, deparse_context *context)
                     generate_relation_name(rte->relid));
 
    /*
-    * Add the insert-column-names list.  To handle indirection properly,
-    * we need to look for indirection nodes in the top targetlist (if it's
+    * Add the insert-column-names list.  To handle indirection properly, we
+    * need to look for indirection nodes in the top targetlist (if it's
     * INSERT ... SELECT or INSERT ... single VALUES), or in the first
-    * expression list of the VALUES RTE (if it's INSERT ... multi VALUES).
-    * We assume that all the expression lists will have similar indirection
-    * in the latter case.
+    * expression list of the VALUES RTE (if it's INSERT ... multi VALUES). We
+    * assume that all the expression lists will have similar indirection in
+    * the latter case.
     */
    if (values_rte)
        values_cell = list_head((List *) linitial(values_rte->values_lists));
@@ -2589,10 +2590,10 @@ get_rte_for_var(Var *var, int levelsup, deparse_context *context,
 
    /*
     * Try to find the relevant RTE in this rtable.  In a plan tree, it's
-    * likely that varno is OUTER, INNER, or 0, in which case we try to
-    * use varnoold instead.  If the Var references an expression computed
-    * by a subplan, varnoold will be 0, and we fall back to looking at the
-    * special subplan RTEs.
+    * likely that varno is OUTER, INNER, or 0, in which case we try to use
+    * varnoold instead.  If the Var references an expression computed by a
+    * subplan, varnoold will be 0, and we fall back to looking at the special
+    * subplan RTEs.
     */
    if (var->varno >= 1 && var->varno <= list_length(dpns->rtable))
        rte = rt_fetch(var->varno, dpns->rtable);
@@ -2692,10 +2693,10 @@ get_names_for_var(Var *var, int levelsup, deparse_context *context,
            /*
             * This case occurs during EXPLAIN when we are looking at a
             * deparse context node set up by deparse_context_for_subplan().
-            * If the subplan tlist provides a name, use it, but usually
-            * we'll end up with "?columnN?".
+            * If the subplan tlist provides a name, use it, but usually we'll
+            * end up with "?columnN?".
             */
-           List   *tlist = ((Plan *) rte->funcexpr)->targetlist;
+           List       *tlist = ((Plan *) rte->funcexpr)->targetlist;
            TargetEntry *tle = get_tle_by_resno(tlist, attnum);
 
            if (tle && tle->resname)
@@ -2704,7 +2705,7 @@ get_names_for_var(Var *var, int levelsup, deparse_context *context,
            }
            else
            {
-               char    buf[32];
+               char        buf[32];
 
                snprintf(buf, sizeof(buf), "?column%d?", attnum);
                *attname = pstrdup(buf);
@@ -2767,8 +2768,8 @@ get_name_for_var_field(Var *var, int fieldno,
 
            /*
             * This case should not occur: a column of a table or values list
-            * shouldn't have type RECORD.  Fall through and fail
-            * (most likely) at the bottom.
+            * shouldn't have type RECORD.  Fall through and fail (most
+            * likely) at the bottom.
             */
            break;
        case RTE_SUBQUERY:
@@ -2836,7 +2837,7 @@ get_name_for_var_field(Var *var, int fieldno,
                 * that's not a Var, and then pass it to
                 * get_expr_result_type().
                 */
-               Plan *subplan = (Plan *) rte->funcexpr;
+               Plan       *subplan = (Plan *) rte->funcexpr;
 
                for (;;)
                {
@@ -3484,7 +3485,7 @@ get_rule_expr(Node *node, deparse_context *context,
 
                    if (get_expr_result_type(arg, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
                        tupdesc = lookup_rowtype_tupdesc_copy(exprType(arg),
-                                                             exprTypmod(arg));
+                                                           exprTypmod(arg));
                    Assert(tupdesc);
                    /* Got the tupdesc, so we can extract the field name */
                    Assert(fno >= 1 && fno <= tupdesc->natts);
@@ -3577,16 +3578,16 @@ get_rule_expr(Node *node, deparse_context *context,
                    if (caseexpr->arg)
                    {
                        /*
-                        * The parser should have produced WHEN clauses of
-                        * the form "CaseTestExpr = RHS"; we want to show
-                        * just the RHS.  If the user wrote something silly
-                        * like "CASE boolexpr WHEN TRUE THEN ...", then
-                        * the optimizer's simplify_boolean_equality() may
-                        * have reduced this to just "CaseTestExpr" or
-                        * "NOT CaseTestExpr", for which we have to show
-                        * "TRUE" or "FALSE".  Also, depending on context
-                        * the original CaseTestExpr might have been reduced
-                        * to a Const (but we won't see "WHEN Const").
+                        * The parser should have produced WHEN clauses of the
+                        * form "CaseTestExpr = RHS"; we want to show just the
+                        * RHS.  If the user wrote something silly like "CASE
+                        * boolexpr WHEN TRUE THEN ...", then the optimizer's
+                        * simplify_boolean_equality() may have reduced this
+                        * to just "CaseTestExpr" or "NOT CaseTestExpr", for
+                        * which we have to show "TRUE" or "FALSE".  Also,
+                        * depending on context the original CaseTestExpr
+                        * might have been reduced to a Const (but we won't
+                        * see "WHEN Const").
                         */
                        if (IsA(w, OpExpr))
                        {
@@ -3719,17 +3720,18 @@ get_rule_expr(Node *node, deparse_context *context,
                    get_rule_expr(e, context, true);
                    sep = ", ";
                }
+
                /*
-                * We assume that the name of the first-column operator
-                * will do for all the rest too.  This is definitely
-                * open to failure, eg if some but not all operators
-                * were renamed since the construct was parsed, but there
-                * seems no way to be perfect.
+                * We assume that the name of the first-column operator will
+                * do for all the rest too.  This is definitely open to
+                * failure, eg if some but not all operators were renamed
+                * since the construct was parsed, but there seems no way to
+                * be perfect.
                 */
                appendStringInfo(buf, ") %s ROW(",
-                        generate_operator_name(linitial_oid(rcexpr->opnos),
-                                       exprType(linitial(rcexpr->largs)),
-                                       exprType(linitial(rcexpr->rargs))));
+                         generate_operator_name(linitial_oid(rcexpr->opnos),
+                                          exprType(linitial(rcexpr->largs)),
+                                        exprType(linitial(rcexpr->rargs))));
                sep = "";
                foreach(arg, rcexpr->rargs)
                {
@@ -4052,7 +4054,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context)
    }
 
    appendStringInfo(buf, "%s(%s",
-                    generate_function_name(aggref->aggfnoid, nargs, argtypes),
+                  generate_function_name(aggref->aggfnoid, nargs, argtypes),
                     aggref->aggdistinct ? "DISTINCT " : "");
    /* aggstar can be set only in zero-argument aggregates */
    if (aggref->aggstar)
@@ -4142,8 +4144,8 @@ get_const_expr(Const *constval, deparse_context *context)
 
            /*
             * We form the string literal according to the prevailing setting
-            * of standard_conforming_strings; we never use E''.
-            * User is responsible for making sure result is used correctly.
+            * of standard_conforming_strings; we never use E''. User is
+            * responsible for making sure result is used correctly.
             */
            appendStringInfoChar(buf, '\'');
            for (valptr = extval; *valptr; valptr++)
@@ -4205,18 +4207,18 @@ get_sublink_expr(SubLink *sublink, deparse_context *context)
        appendStringInfoChar(buf, '(');
 
    /*
-    * Note that we print the name of only the first operator, when there
-    * are multiple combining operators.  This is an approximation that
-    * could go wrong in various scenarios (operators in different schemas,
-    * renamed operators, etc) but there is not a whole lot we can do about
-    * it, since the syntax allows only one operator to be shown.
+    * Note that we print the name of only the first operator, when there are
+    * multiple combining operators.  This is an approximation that could go
+    * wrong in various scenarios (operators in different schemas, renamed
+    * operators, etc) but there is not a whole lot we can do about it, since
+    * the syntax allows only one operator to be shown.
     */
    if (sublink->testexpr)
    {
        if (IsA(sublink->testexpr, OpExpr))
        {
            /* single combining operator */
-           OpExpr   *opexpr = (OpExpr *) sublink->testexpr;
+           OpExpr     *opexpr = (OpExpr *) sublink->testexpr;
 
            get_rule_expr(linitial(opexpr->args), context, true);
            opname = generate_operator_name(opexpr->opno,
@@ -4233,7 +4235,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context)
            sep = "";
            foreach(l, ((BoolExpr *) sublink->testexpr)->args)
            {
-               OpExpr   *opexpr = (OpExpr *) lfirst(l);
+               OpExpr     *opexpr = (OpExpr *) lfirst(l);
 
                Assert(IsA(opexpr, OpExpr));
                appendStringInfoString(buf, sep);
@@ -4255,7 +4257,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context)
            get_rule_expr((Node *) rcexpr->largs, context, true);
            opname = generate_operator_name(linitial_oid(rcexpr->opnos),
                                            exprType(linitial(rcexpr->largs)),
-                                           exprType(linitial(rcexpr->rargs)));
+                                         exprType(linitial(rcexpr->rargs)));
            appendStringInfoChar(buf, ')');
        }
        else
@@ -5129,8 +5131,8 @@ flatten_reloptions(Oid relid)
                                 Anum_pg_class_reloptions, &isnull);
    if (!isnull)
    {
-       Datum   sep,
-               txt;
+       Datum       sep,
+                   txt;
 
        /*
         * We want to use array_to_text(reloptions, ', ') --- but
index 44879d20a2854517f622c4d703017ef8e30792b5..4eed9619b70ae6861dc36a5f4432a52b44483a92 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.213 2006/09/20 19:50:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.214 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 
 static double ineq_histogram_selectivity(VariableStatData *vardata,
-                                        FmgrInfo *opproc, bool isgt,
-                                        Datum constval, Oid consttype);
+                          FmgrInfo *opproc, bool isgt,
+                          Datum constval, Oid consttype);
 static bool convert_to_scalar(Datum value, Oid valuetypid, double *scaledvalue,
                  Datum lobound, Datum hibound, Oid boundstypid,
                  double *scaledlobound, double *scaledhibound);
@@ -128,7 +128,7 @@ static double convert_timevalue_to_scalar(Datum value, Oid typid);
 static bool get_variable_maximum(PlannerInfo *root, VariableStatData *vardata,
                     Oid sortop, Datum *max);
 static Selectivity prefix_selectivity(VariableStatData *vardata,
-                                     Oid opclass, Const *prefixcon);
+                  Oid opclass, Const *prefixcon);
 static Selectivity pattern_selectivity(Const *patt, Pattern_Type ptype);
 static Datum string_to_datum(const char *str, Oid datatype);
 static Const *string_to_const(const char *str, Oid datatype);
@@ -315,10 +315,9 @@ eqsel(PG_FUNCTION_ARGS)
    else
    {
        /*
-        * No 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 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);
    }
@@ -523,7 +522,7 @@ mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc,
  *
  * Note that the result disregards both the most-common-values (if any) and
  * null entries.  The caller is expected to combine this result with
- * statistics for those portions of the column population.  It may also be
+ * statistics for those portions of the column population. It may also be
  * prudent to clamp the result range, ie, disbelieve exact 0 or 1 outputs.
  */
 double
@@ -618,20 +617,20 @@ ineq_histogram_selectivity(VariableStatData *vardata,
        if (nvalues > 1)
        {
            /*
-            * Use binary search to find proper location, ie, the first
-            * slot at which the comparison fails.  (If the given operator
-            * isn't actually sort-compatible with the histogram, you'll
-            * get garbage results ... but probably not any more garbage-y
-            * than you would from the old linear search.)
+            * Use binary search to find proper location, ie, the first slot
+            * at which the comparison fails.  (If the given operator isn't
+            * actually sort-compatible with the histogram, you'll get garbage
+            * results ... but probably not any more garbage-y than you would
+            * from the old linear search.)
             */
-           double  histfrac;
-           int     lobound = 0;        /* first possible slot to search */
-           int     hibound = nvalues;  /* last+1 slot to search */
+           double      histfrac;
+           int         lobound = 0;    /* first possible slot to search */
+           int         hibound = nvalues;      /* last+1 slot to search */
 
            while (lobound < hibound)
            {
-               int     probe = (lobound + hibound) / 2;
-               bool    ltcmp;
+               int         probe = (lobound + hibound) / 2;
+               bool        ltcmp;
 
                ltcmp = DatumGetBool(FunctionCall2(opproc,
                                                   values[probe],
@@ -688,10 +687,10 @@ ineq_histogram_selectivity(VariableStatData *vardata,
                        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)
@@ -701,20 +700,20 @@ ineq_histogram_selectivity(VariableStatData *vardata,
                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.
+                * 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);
@@ -1093,7 +1092,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
        /*
         * If we have most-common-values info, add up the fractions of the MCV
         * entries that satisfy MCV OP PATTERN.  These fractions contribute
-        * directly to the result selectivity.  Also add up the total fraction
+        * directly to the result selectivity.  Also add up the total fraction
         * represented by MCV entries.
         */
        mcv_selec = mcv_selectivity(&vardata, &opproc, constval, true,
@@ -1467,11 +1466,11 @@ scalararraysel(PlannerInfo *root,
    RegProcedure oprsel;
    FmgrInfo    oprselproc;
    Datum       selarg4;
-   Selectivity s1;
+   Selectivity s1;
 
    /*
-    * First, look up the underlying operator's selectivity estimator.
-    * Punt if it hasn't got one.
+    * First, look up the underlying operator's selectivity estimator. Punt if
+    * it hasn't got one.
     */
    if (is_join_clause)
    {
@@ -1491,9 +1490,8 @@ scalararraysel(PlannerInfo *root,
     * We consider three cases:
     *
     * 1. rightop is an Array constant: deconstruct the array, apply the
-    * operator's selectivity function for each array element, and merge
-    * the results in the same way that clausesel.c does for AND/OR
-    * combinations.
+    * operator's selectivity function for each array element, and merge the
+    * results in the same way that clausesel.c does for AND/OR combinations.
     *
     * 2. rightop is an ARRAY[] construct: apply the operator's selectivity
     * function for each element of the ARRAY[] construct, and merge.
@@ -1529,7 +1527,7 @@ scalararraysel(PlannerInfo *root,
        s1 = useOr ? 0.0 : 1.0;
        for (i = 0; i < num_elems; i++)
        {
-           List    *args;
+           List       *args;
            Selectivity s2;
 
            args = list_make2(leftop,
@@ -1562,7 +1560,7 @@ scalararraysel(PlannerInfo *root,
        s1 = useOr ? 0.0 : 1.0;
        foreach(l, arrayexpr->elements)
        {
-           List    *args;
+           List       *args;
            Selectivity s2;
 
            args = list_make2(leftop, lfirst(l));
@@ -1580,14 +1578,14 @@ scalararraysel(PlannerInfo *root,
    else
    {
        CaseTestExpr *dummyexpr;
-       List    *args;
+       List       *args;
        Selectivity s2;
-       int     i;
+       int         i;
 
        /*
         * We need a dummy rightop to pass to the operator selectivity
-        * routine.  It can be pretty much anything that doesn't look like
-        * constant; CaseTestExpr is a convenient choice.
+        * routine.  It can be pretty much anything that doesn't look like a
+        * constant; CaseTestExpr is a convenient choice.
         */
        dummyexpr = makeNode(CaseTestExpr);
        dummyexpr->typeId = get_element_type(exprType(rightop));
@@ -1599,9 +1597,10 @@ scalararraysel(PlannerInfo *root,
                                          PointerGetDatum(args),
                                          selarg4));
        s1 = useOr ? 0.0 : 1.0;
+
        /*
-        * Arbitrarily assume 10 elements in the eventual array value
-        * (see also estimate_array_length)
+        * Arbitrarily assume 10 elements in the eventual array value (see
+        * also estimate_array_length)
         */
        for (i = 0; i < 10; i++)
        {
@@ -3050,14 +3049,19 @@ convert_string_datum(Datum value, Oid typid)
         * == as you'd expect.  Can't any of these people program their way
         * out of a paper bag?
         */
-#if _MSC_VER == 1400   /* VS.Net 2005 */
-       /* http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99694 */
+#if _MSC_VER == 1400           /* VS.Net 2005 */
+
+       /*
+        * http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx
+        * ?FeedbackID=99694
+        */
        {
-           char x[1];
+           char        x[1];
+
            xfrmlen = strxfrm(x, val, 0);
        }
 #else
-       xfrmlen = strxfrm(NULL, val, 0);
+       xfrmlen = strxfrm(NULL, val, 0);
 #endif
        xfrmstr = (char *) palloc(xfrmlen + 1);
        xfrmlen2 = strxfrm(xfrmstr, val, xfrmlen + 1);
@@ -3399,9 +3403,9 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
        if (rte->inh)
        {
            /*
-            * XXX This means the Var represents a column of an append relation.
-            * Later add code to look at the member relations and try to derive
-            * some kind of combined statistics?
+            * XXX This means the Var represents a column of an append
+            * relation. Later add code to look at the member relations and
+            * try to derive some kind of combined statistics?
             */
        }
        else if (rte->rtekind == RTE_RELATION)
@@ -4154,7 +4158,7 @@ prefix_selectivity(VariableStatData *vardata, Oid opclass, Const *prefixcon)
 
        /*
         * Merge the two selectivities in the same way as for a range query
-        * (see clauselist_selectivity()).  Note that we don't need to worry
+        * (see clauselist_selectivity()).  Note that we don't need to worry
         * about double-exclusion of nulls, since ineq_histogram_selectivity
         * doesn't count those anyway.
         */
@@ -4162,8 +4166,8 @@ prefix_selectivity(VariableStatData *vardata, Oid opclass, Const *prefixcon)
 
        /*
         * A zero or 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.
+        * positive value; we probably are dealing with a very tight range and
+        * got a bogus result due to roundoff errors.
         */
        if (prefixsel <= 0.0)
            prefixsel = 1.0e-10;
@@ -4640,8 +4644,8 @@ genericcostestimate(PlannerInfo *root,
        selectivityQuals = indexQuals;
 
    /*
-    * Check for ScalarArrayOpExpr index quals, and estimate the number
-    * of index scans that will be performed.
+    * Check for ScalarArrayOpExpr index quals, and estimate the number of
+    * index scans that will be performed.
     */
    num_sa_scans = 1;
    foreach(l, indexQuals)
@@ -4651,7 +4655,7 @@ genericcostestimate(PlannerInfo *root,
        if (IsA(rinfo->clause, ScalarArrayOpExpr))
        {
            ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) rinfo->clause;
-           int     alength = estimate_array_length(lsecond(saop->args));
+           int         alength = estimate_array_length(lsecond(saop->args));
 
            if (alength > 1)
                num_sa_scans *= alength;
@@ -4679,8 +4683,8 @@ genericcostestimate(PlannerInfo *root,
    numIndexTuples = rint(numIndexTuples / num_sa_scans);
 
    /*
-    * 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)
@@ -4691,12 +4695,11 @@ genericcostestimate(PlannerInfo *root,
    /*
     * Estimate the number of index pages that will be retrieved.
     *
-    * We use the simplistic method of taking a pro-rata fraction of the
-    * total number of index pages.  In effect, this counts only leaf pages
-    * and not any overhead such as index metapage or upper tree levels.
-    * In practice this seems a better approximation than charging for
-    * access to the upper levels, perhaps because those tend to stay in
-    * cache under load.
+    * We use the simplistic method of taking a pro-rata fraction of the total
+    * number of index pages.  In effect, this counts only leaf pages and not
+    * any overhead such as index metapage or upper tree levels. In practice
+    * this seems a better approximation than charging for access to the upper
+    * levels, perhaps because those tend to stay in cache under load.
     */
    if (index->pages > 1 && index->tuples > 1)
        numIndexPages = ceil(numIndexTuples * index->pages / index->tuples);
@@ -4706,19 +4709,19 @@ genericcostestimate(PlannerInfo *root,
    /*
     * Now compute the disk access costs.
     *
-    * The above calculations are all per-index-scan.  However, if we are
-    * in a nestloop inner scan, we can expect the scan to be repeated (with
+    * The above calculations are all per-index-scan.  However, if we are in a
+    * nestloop inner scan, we can expect the scan to be repeated (with
     * different search keys) for each row of the outer relation.  Likewise,
-    * ScalarArrayOpExpr quals result in multiple index scans.  This
-    * creates the potential for cache effects to reduce the number of
-    * disk page fetches needed.  We want to estimate the average per-scan
-    * I/O cost in the presence of caching.
+    * ScalarArrayOpExpr quals result in multiple index scans.  This creates
+    * the potential for cache effects to reduce the number of disk page
+    * fetches needed.  We want to estimate the average per-scan I/O cost in
+    * the presence of caching.
     *
     * We use the Mackert-Lohman formula (see costsize.c for details) to
     * estimate the total number of page fetches that occur.  While this
     * wasn't what it was designed for, it seems a reasonable model anyway.
-    * Note that we are counting pages not tuples anymore, so we take
-    * N = T = index size, as if there were one "tuple" per page.
+    * Note that we are counting pages not tuples anymore, so we take N = T =
+    * index size, as if there were one "tuple" per page.
     */
    if (outer_rel != NULL && outer_rel->rows > 1)
    {
@@ -4745,9 +4748,9 @@ genericcostestimate(PlannerInfo *root,
                                            root);
 
        /*
-        * Now compute the total disk access cost, and then report a
-        * pro-rated share for each outer scan.  (Don't pro-rate for
-        * ScalarArrayOpExpr, since that's internal to the indexscan.)
+        * Now compute the total disk access cost, and then report a pro-rated
+        * share for each outer scan.  (Don't pro-rate for ScalarArrayOpExpr,
+        * since that's internal to the indexscan.)
         */
        *indexTotalCost = (pages_fetched * random_page_cost) / num_outer_scans;
    }
@@ -4761,20 +4764,20 @@ genericcostestimate(PlannerInfo *root,
    }
 
    /*
-    * A difficulty with the leaf-pages-only cost approach is that for
-    * small selectivities (eg, single index tuple fetched) all indexes
-    * will look equally attractive because we will estimate exactly 1
-    * leaf page to be fetched.  All else being equal, we should prefer
-    * physically smaller indexes over larger ones.  (An index might be
-    * smaller because it is partial or because it contains fewer columns;
-    * presumably the other columns in the larger index aren't useful to
-    * the query, or the larger index would have better selectivity.)
+    * A difficulty with the leaf-pages-only cost approach is that for small
+    * selectivities (eg, single index tuple fetched) all indexes will look
+    * equally attractive because we will estimate exactly 1 leaf page to be
+    * fetched.  All else being equal, we should prefer physically smaller
+    * indexes over larger ones.  (An index might be smaller because it is
+    * partial or because it contains fewer columns; presumably the other
+    * columns in the larger index aren't useful to the query, or the larger
+    * index would have better selectivity.)
     *
     * We can deal with this by adding a very small "fudge factor" that
     * depends on the index size.  The fudge factor used here is one
-    * random_page_cost per 100000 index pages, which should be small
-    * enough to not alter index-vs-seqscan decisions, but will prevent
-    * indexes of different sizes from looking exactly equally attractive.
+    * random_page_cost per 100000 index pages, which should be small enough
+    * to not alter index-vs-seqscan decisions, but will prevent indexes of
+    * different sizes from looking exactly equally attractive.
     */
    *indexTotalCost += index->pages * random_page_cost / 100000.0;
 
@@ -4841,8 +4844,8 @@ btcostestimate(PG_FUNCTION_ARGS)
     * For a RowCompareExpr, we consider only the first column, just as
     * rowcomparesel() does.
     *
-    * If there's a ScalarArrayOpExpr in the quals, we'll actually perform
-    * index scans not one, but the ScalarArrayOpExpr's operator can be
+    * If there's a ScalarArrayOpExpr in the quals, we'll actually perform N
+    * index scans not one, but the ScalarArrayOpExpr's operator can be
     * considered to act the same as it normally does.
     */
    indexBoundQuals = NIL;
@@ -4960,9 +4963,9 @@ btcostestimate(PG_FUNCTION_ARGS)
     * ordering, but don't negate it entirely.  Before 8.0 we divided the
     * correlation by the number of columns, but that seems too strong.)
     *
-    * We can skip all this if we found a ScalarArrayOpExpr, because then
-    * the call must be for a bitmap index scan, and the caller isn't going
-    * to care what the index correlation is.
+    * We can skip all this if we found a ScalarArrayOpExpr, because then the
+    * call must be for a bitmap index scan, and the caller isn't going to
+    * care what the index correlation is.
     */
    if (found_saop)
        PG_RETURN_VOID();
index 1362d0a3f87196f835af6dc21ca1c0f803307ddc..33b551aed8888947f56ec709398bd6bcb07b9de6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.55 2006/08/25 04:06:53 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.56 2006/10/04 00:29:59 momjian Exp $
  *
  * NOTES
  *   input routine largely stolen from boxin().
@@ -164,7 +164,7 @@ tideq(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) == 0);
+   PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) == 0);
 }
 
 Datum
@@ -173,7 +173,7 @@ tidne(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) != 0);
+   PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) != 0);
 }
 
 Datum
@@ -182,7 +182,7 @@ tidlt(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) < 0);
+   PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) < 0);
 }
 
 Datum
@@ -191,7 +191,7 @@ tidle(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) <= 0);
+   PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) <= 0);
 }
 
 Datum
@@ -200,7 +200,7 @@ tidgt(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) > 0);
+   PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) > 0);
 }
 
 Datum
@@ -209,7 +209,7 @@ tidge(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_BOOL(ItemPointerCompare(arg1,arg2) >= 0);
+   PG_RETURN_BOOL(ItemPointerCompare(arg1, arg2) >= 0);
 }
 
 Datum
@@ -227,7 +227,7 @@ tidlarger(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1,arg2) >= 0 ? arg1 : arg2);
+   PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1, arg2) >= 0 ? arg1 : arg2);
 }
 
 Datum
@@ -236,7 +236,7 @@ tidsmaller(PG_FUNCTION_ARGS)
    ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
    ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-   PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1,arg2) <= 0 ? arg1 : arg2);
+   PG_RETURN_ITEMPOINTER(ItemPointerCompare(arg1, arg2) <= 0 ? arg1 : arg2);
 }
 
 
index fcd90432af965ebddeb7c3111356788a975fdd82..e06fa99dc178ec75f9f8d9337aa4e94f373d8011 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.167 2006/09/05 01:13:39 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.168 2006/10/04 00:29:59 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1029,10 +1029,10 @@ timestamptz_to_time_t(TimestampTz t)
 
 #ifdef HAVE_INT64_TIMESTAMP
    result = (time_t) (t / USECS_PER_SEC +
-       ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY));
+                ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY));
 #else
    result = (time_t) (t +
-       ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY));
+                ((POSTGRES_EPOCH_JDATE - UNIX_EPOCH_JDATE) * SECS_PER_DAY));
 #endif
 
    return result;
@@ -2015,7 +2015,7 @@ timestamp_mi(PG_FUNCTION_ARGS)
     *  test=> SET timezone = 'EST5EDT';
     *  test=> SELECT
     *  test-> ('2005-10-30 13:22:00-05'::timestamptz -
-    *  test(>  '2005-10-29 13:22:00-04'::timestamptz);
+    *  test(>  '2005-10-29 13:22:00-04'::timestamptz);
     *  ?column?
     *  ----------------
     *   1 day 01:00:00
@@ -2027,7 +2027,7 @@ timestamp_mi(PG_FUNCTION_ARGS)
     *   test-> ('2005-10-29 13:22:00-04'::timestamptz +
     *   test(> ('2005-10-30 13:22:00-05'::timestamptz -
     *   test(>  '2005-10-29 13:22:00-04'::timestamptz)) at time zone 'EST';
-    *      timezone
+    *      timezone
     *  --------------------
     *  2005-10-30 14:22:00
     *  (1 row)
@@ -2040,23 +2040,23 @@ timestamp_mi(PG_FUNCTION_ARGS)
 }
 
 /*
- *  interval_justify_interval()
+ * interval_justify_interval()
  *
- *  Adjust interval so 'month', 'day', and 'time' portions are within
- *  customary bounds.  Specifically:
+ * Adjust interval so 'month', 'day', and 'time' portions are within
+ * customary bounds.  Specifically:
  *
- *     0 <= abs(time) < 24 hours
- *     0 <= abs(day)  < 30 days
+ *     0 <= abs(time) < 24 hours
+ *     0 <= abs(day)  < 30 days
  *
- *  Also, the sign bit on all three fields is made equal, so either
- *  all three fields are negative or all are positive.
+ * Also, the sign bit on all three fields is made equal, so either
+ * all three fields are negative or all are positive.
  */
 Datum
 interval_justify_interval(PG_FUNCTION_ARGS)
 {
    Interval   *span = PG_GETARG_INTERVAL_P(0);
    Interval   *result;
-   
+
 #ifdef HAVE_INT64_TIMESTAMP
    int64       wholeday;
 #else
@@ -2087,7 +2087,7 @@ interval_justify_interval(PG_FUNCTION_ARGS)
        result->month--;
    }
    else if (result->month < 0 &&
-       (result->day > 0 || (result->day == 0 && result->time > 0)))
+            (result->day > 0 || (result->day == 0 && result->time > 0)))
    {
        result->day -= DAYS_PER_MONTH;
        result->month++;
@@ -2103,7 +2103,7 @@ interval_justify_interval(PG_FUNCTION_ARGS)
        result->day--;
    }
    else if (result->day < 0 && result->time > 0)
-   {
+   {
 #ifdef HAVE_INT64_TIMESTAMP
        result->time -= USECS_PER_DAY;
 #else
@@ -2492,8 +2492,10 @@ interval_mul(PG_FUNCTION_ARGS)
 {
    Interval   *span = PG_GETARG_INTERVAL_P(0);
    float8      factor = PG_GETARG_FLOAT8(1);
-   double      month_remainder_days, sec_remainder;
-   int32       orig_month = span->month, orig_day = span->day;
+   double      month_remainder_days,
+               sec_remainder;
+   int32       orig_month = span->month,
+               orig_day = span->day;
    Interval   *result;
 
    result = (Interval *) palloc(sizeof(Interval));
@@ -2512,28 +2514,28 @@ interval_mul(PG_FUNCTION_ARGS)
     */
 
    /*
-    *  Fractional months full days into days.
+    * Fractional months full days into days.
     *
-    *  Floating point calculation are inherently inprecise, so these
-    *  calculations are crafted to produce the most reliable result
-    *  possible.  TSROUND() is needed to more accurately produce whole
-    *  numbers where appropriate.
+    * Floating point calculation are inherently inprecise, so these
+    * calculations are crafted to produce the most reliable result possible.
+    * TSROUND() is needed to more accurately produce whole numbers where
+    * appropriate.
     */
    month_remainder_days = (orig_month * factor - result->month) * DAYS_PER_MONTH;
    month_remainder_days = TSROUND(month_remainder_days);
    sec_remainder = (orig_day * factor - result->day +
-           month_remainder_days - (int)month_remainder_days) * SECS_PER_DAY;
+          month_remainder_days - (int) month_remainder_days) * SECS_PER_DAY;
    sec_remainder = TSROUND(sec_remainder);
 
    /*
-    *  Might have 24:00:00 hours due to rounding, or >24 hours because of
-    *  time cascade from months and days.  It might still be >24 if the
-    *  combination of cascade and the seconds factor operation itself.
+    * Might have 24:00:00 hours due to rounding, or >24 hours because of time
+    * cascade from months and days.  It might still be >24 if the combination
+    * of cascade and the seconds factor operation itself.
     */
    if (Abs(sec_remainder) >= SECS_PER_DAY)
    {
-       result->day += (int)(sec_remainder / SECS_PER_DAY);
-       sec_remainder -= (int)(sec_remainder / SECS_PER_DAY) * SECS_PER_DAY;
+       result->day += (int) (sec_remainder / SECS_PER_DAY);
+       sec_remainder -= (int) (sec_remainder / SECS_PER_DAY) * SECS_PER_DAY;
    }
 
    /* cascade units down */
@@ -2562,10 +2564,12 @@ interval_div(PG_FUNCTION_ARGS)
 {
    Interval   *span = PG_GETARG_INTERVAL_P(0);
    float8      factor = PG_GETARG_FLOAT8(1);
-   double      month_remainder_days, sec_remainder;
-   int32       orig_month = span->month, orig_day = span->day;
+   double      month_remainder_days,
+               sec_remainder;
+   int32       orig_month = span->month,
+               orig_day = span->day;
    Interval   *result;
-   
+
    result = (Interval *) palloc(sizeof(Interval));
 
    if (factor == 0.0)
@@ -2577,18 +2581,17 @@ interval_div(PG_FUNCTION_ARGS)
    result->day = (int32) (span->day / factor);
 
    /*
-    *  Fractional months full days into days.  See comment in 
-    *  interval_mul().
+    * Fractional months full days into days.  See comment in interval_mul().
     */
    month_remainder_days = (orig_month / factor - result->month) * DAYS_PER_MONTH;
    month_remainder_days = TSROUND(month_remainder_days);
    sec_remainder = (orig_day / factor - result->day +
-           month_remainder_days - (int)month_remainder_days) * SECS_PER_DAY;
+          month_remainder_days - (int) month_remainder_days) * SECS_PER_DAY;
    sec_remainder = TSROUND(sec_remainder);
    if (Abs(sec_remainder) >= SECS_PER_DAY)
    {
-       result->day += (int)(sec_remainder / SECS_PER_DAY);
-       sec_remainder -= (int)(sec_remainder / SECS_PER_DAY) * SECS_PER_DAY;
+       result->day += (int) (sec_remainder / SECS_PER_DAY);
+       sec_remainder -= (int) (sec_remainder / SECS_PER_DAY) * SECS_PER_DAY;
    }
 
    /* cascade units down */
index 5124bee765c09bda4ef3a3775834e58c09c8876b..937cf96ebef0d018756509a6a5edee0f77ab4d7d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.118 2006/07/14 14:52:24 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/varchar.c,v 1.119 2006/10/04 00:30:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -604,8 +604,8 @@ bpchareq(PG_FUNCTION_ARGS)
    len2 = bcTruelen(arg2);
 
    /*
-    * Since we only care about equality or not-equality, we can avoid all
-    * the expense of strcoll() here, and just do bitwise comparison.
+    * Since we only care about equality or not-equality, we can avoid all the
+    * expense of strcoll() here, and just do bitwise comparison.
     */
    if (len1 != len2)
        result = false;
@@ -631,8 +631,8 @@ bpcharne(PG_FUNCTION_ARGS)
    len2 = bcTruelen(arg2);
 
    /*
-    * Since we only care about equality or not-equality, we can avoid all
-    * the expense of strcoll() here, and just do bitwise comparison.
+    * Since we only care about equality or not-equality, we can avoid all the
+    * expense of strcoll() here, and just do bitwise comparison.
     */
    if (len1 != len2)
        result = true;
index 6215e3eda5a79ac81522846b6db93db1fe24f61c..33f40b685c76bbaa87e05476229e47793b01e227 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.150 2006/07/14 14:52:24 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.151 2006/10/04 00:30:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -985,8 +985,8 @@ texteq(PG_FUNCTION_ARGS)
    bool        result;
 
    /*
-    * Since we only care about equality or not-equality, we can avoid all
-    * the expense of strcoll() here, and just do bitwise comparison.
+    * Since we only care about equality or not-equality, we can avoid all the
+    * expense of strcoll() here, and just do bitwise comparison.
     */
    if (VARSIZE(arg1) != VARSIZE(arg2))
        result = false;
@@ -1008,8 +1008,8 @@ textne(PG_FUNCTION_ARGS)
    bool        result;
 
    /*
-    * Since we only care about equality or not-equality, we can avoid all
-    * the expense of strcoll() here, and just do bitwise comparison.
+    * Since we only care about equality or not-equality, we can avoid all the
+    * expense of strcoll() here, and just do bitwise comparison.
     */
    if (VARSIZE(arg1) != VARSIZE(arg2))
        result = true;
@@ -2217,7 +2217,7 @@ replace_text_regexp(text *src_text, void *regexp,
    text       *ret_text;
    regex_t    *re = (regex_t *) regexp;
    int         src_text_len = VARSIZE(src_text) - VARHDRSZ;
-   StringInfoData  buf;
+   StringInfoData buf;
    regmatch_t  pmatch[REGEXP_REPLACE_BACKREF_CNT];
    pg_wchar   *data;
    size_t      data_len;
@@ -2236,7 +2236,7 @@ replace_text_regexp(text *src_text, void *regexp,
 
    for (search_start = data_pos = 0; search_start <= data_len;)
    {
-       int regexec_result;
+       int         regexec_result;
 
        regexec_result = pg_regexec(re,
                                    data,
@@ -2503,7 +2503,7 @@ array_to_text(PG_FUNCTION_ARGS)
    int         typlen;
    bool        typbyval;
    char        typalign;
-   StringInfoData  buf;
+   StringInfoData buf;
    bool        printed = false;
    char       *p;
    bits8      *bitmap;
index 20b83e196a342dee107ef281d33cc066299e6ddf..0d1ae15b39ce1e94d115b91292780ffa29fc2c78 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.132 2006/07/31 20:09:05 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.133 2006/10/04 00:30:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -786,8 +786,8 @@ InitCatCache(int id,
 
    /*
     * nbuckets is the number of hash buckets to use in this catcache.
-    * Currently we just use a hard-wired estimate of an appropriate size
-    * for each cache; maybe later make them dynamically resizable?
+    * Currently we just use a hard-wired estimate of an appropriate size for
+    * each cache; maybe later make them dynamically resizable?
     *
     * nbuckets must be a power of two.  We check this via Assert rather than
     * a full runtime check because the values will be coming from constant
index 247c6bf5a682f25fa8bbc7d1e217e14e7f087edb..899c8e202b36f2cc8b42e3ed8c3ffc874357189f 100644 (file)
@@ -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.77 2006/07/14 14:52:25 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/cache/inval.c,v 1.78 2006/10/04 00:30:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -633,11 +633,11 @@ AcceptInvalidationMessages(void)
     * However, it also makes the system unbelievably slow --- the regression
     * tests take about 100 times longer than normal.
     *
-    * If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY.
-    * This slows things by at least a factor of 10000, so I wouldn't suggest
-    * trying to run the entire regression tests that way.  It's useful to
-    * try a few simple tests, to make sure that cache reload isn't subject
-    * to internal cache-flush hazards, but after you've done a few thousand
+    * If you're a glutton for punishment, try CLOBBER_CACHE_RECURSIVELY. This
+    * slows things by at least a factor of 10000, so I wouldn't suggest
+    * trying to run the entire regression tests that way.  It's useful to try
+    * a few simple tests, to make sure that cache reload isn't subject to
+    * internal cache-flush hazards, but after you've done a few thousand
     * recursive reloads it's unlikely you'll learn more.
     */
 #if defined(CLOBBER_CACHE_ALWAYS)
index 53e3a5bf552e0e0f78f20044a432ce10d9983cd1..fdc31e0d97741362b45e9752dd3c04c584a73c80 100644 (file)
@@ -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.137 2006/09/28 20:51:42 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.138 2006/10/04 00:30:00 momjian Exp $
  *
  * NOTES
  *   Eventually, the index information should go through here, too.
@@ -206,9 +206,9 @@ get_op_btree_interpretation(Oid opno, List **opclasses, List **opstrats)
 
    /*
     * Get the nominal left-hand input type of the operator; we will ignore
-    * opclasses that don't have that as the expected input datatype.  This
-    * is a kluge to avoid being confused by binary-compatible opclasses
-    * (such as text_ops and varchar_ops, which share the same operators).
+    * opclasses that don't have that as the expected input datatype.  This is
+    * a kluge to avoid being confused by binary-compatible opclasses (such as
+    * text_ops and varchar_ops, which share the same operators).
     */
    op_input_types(opno, &lefttype, &righttype);
    Assert(OidIsValid(lefttype));
@@ -219,14 +219,15 @@ get_op_btree_interpretation(Oid opno, List **opclasses, List **opstrats)
    catlist = SearchSysCacheList(AMOPOPID, 1,
                                 ObjectIdGetDatum(opno),
                                 0, 0, 0);
+
    /*
-    * If we can't find any opclass containing the op, perhaps it is a
-    * <> operator.  See if it has a negator that is in an opclass.
+    * If we can't find any opclass containing the op, perhaps it is a <>
+    * operator.  See if it has a negator that is in an opclass.
     */
    op_negated = false;
    if (catlist->n_members == 0)
    {
-       Oid     op_negator = get_negator(opno);
+       Oid         op_negator = get_negator(opno);
 
        if (OidIsValid(op_negator))
        {
@@ -1395,13 +1396,13 @@ get_type_io_data(Oid typid,
    Form_pg_type typeStruct;
 
    /*
-    * In bootstrap mode, pass it off to bootstrap.c.  This hack allows
-    * us to use array_in and array_out during bootstrap.
+    * In bootstrap mode, pass it off to bootstrap.c.  This hack allows us to
+    * use array_in and array_out during bootstrap.
     */
    if (IsBootstrapProcessingMode())
    {
-       Oid typinput;
-       Oid typoutput;
+       Oid         typinput;
+       Oid         typoutput;
 
        boot_get_type_io_data(typid,
                              typlen,
index 190543e2bd712eeab57ee0b25115195cd08c281a..40e71d513d256b76f39705369dfaa24e2a3098d1 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.248 2006/09/05 21:08:36 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.249 2006/10/04 00:30:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -182,7 +182,7 @@ static void RelationReloadClassinfo(Relation relation);
 static void RelationFlushRelation(Relation relation);
 static bool load_relcache_init_file(void);
 static void write_relcache_init_file(void);
-static void    write_item(const void *data, Size len, FILE *fp);
+static void write_item(const void *data, Size len, FILE *fp);
 
 static void formrdesc(const char *relationName, Oid relationReltype,
          bool hasoids, int natts, FormData_pg_attribute *att);
@@ -298,14 +298,14 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
    /*
     * Copy the relation tuple form
     *
-    * We only allocate space for the fixed fields, ie, CLASS_TUPLE_SIZE.
-    * The variable-length fields (relacl, reloptions) are NOT stored in the
+    * We only allocate space for the fixed fields, ie, CLASS_TUPLE_SIZE. The
+    * variable-length fields (relacl, reloptions) are NOT stored in the
     * relcache --- there'd be little point in it, since we don't copy the
     * tuple's nulls bitmap and hence wouldn't know if the values are valid.
-    * Bottom line is that relacl *cannot* be retrieved from the relcache.
-    * Get it from the syscache if you need it.  The same goes for the
-    * original form of reloptions (however, we do store the parsed form
-    * of reloptions in rd_options).
+    * Bottom line is that relacl *cannot* be retrieved from the relcache. Get
+    * it from the syscache if you need it.  The same goes for the original
+    * form of reloptions (however, we do store the parsed form of reloptions
+    * in rd_options).
     */
    relationForm = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
 
@@ -355,9 +355,9 @@ RelationParseRelOptions(Relation relation, HeapTuple tuple)
    }
 
    /*
-    * Fetch reloptions from tuple; have to use a hardwired descriptor
-    * because we might not have any other for pg_class yet (consider
-    * executing this code for pg_class itself)
+    * Fetch reloptions from tuple; have to use a hardwired descriptor because
+    * we might not have any other for pg_class yet (consider executing this
+    * code for pg_class itself)
     */
    datum = fastgetattr(tuple,
                        Anum_pg_class_reloptions,
@@ -620,8 +620,8 @@ RelationBuildRuleLock(Relation relation)
     *
     * Note: since we scan the rules using RewriteRelRulenameIndexId, we will
     * be reading the rules in name order, except possibly during
-    * emergency-recovery operations (ie, IgnoreSystemIndexes). This in
-    * turn ensures that rules will be fired in name order.
+    * emergency-recovery operations (ie, IgnoreSystemIndexes). This in turn
+    * ensures that rules will be fired in name order.
     */
    rewrite_desc = heap_open(RewriteRelationId, AccessShareLock);
    rewrite_tupdesc = RelationGetDescr(rewrite_desc);
@@ -649,10 +649,10 @@ RelationBuildRuleLock(Relation relation)
        rule->isInstead = rewrite_form->is_instead;
 
        /*
-        * Must use heap_getattr to fetch ev_action and ev_qual.  Also,
-        * the rule strings are often large enough to be toasted.  To avoid
-        * leaking memory in the caller's context, do the detoasting here
-        * so we can free the detoasted version.
+        * Must use heap_getattr to fetch ev_action and ev_qual.  Also, the
+        * rule strings are often large enough to be toasted.  To avoid
+        * leaking memory in the caller's context, do the detoasting here so
+        * we can free the detoasted version.
         */
        rule_datum = heap_getattr(rewrite_tuple,
                                  Anum_pg_rewrite_ev_action,
@@ -686,16 +686,16 @@ RelationBuildRuleLock(Relation relation)
 
        /*
         * We want the rule's table references to be checked as though by the
-        * table owner, not the user referencing the rule.  Therefore, scan
+        * table owner, not the user referencing the rule.  Therefore, scan
         * through the rule's actions and set the checkAsUser field on all
-        * rtable entries.  We have to look at the qual as well, in case it
+        * rtable entries.  We have to look at the qual as well, in case it
         * contains sublinks.
         *
-        * The reason for doing this when the rule is loaded, rather than
-        * when it is stored, is that otherwise ALTER TABLE OWNER would have
-        * to grovel through stored rules to update checkAsUser fields.
-        * Scanning the rule tree during load is relatively cheap (compared
-        * to constructing it in the first place), so we do it here.
+        * The reason for doing this when the rule is loaded, rather than when
+        * it is stored, is that otherwise ALTER TABLE OWNER would have to
+        * grovel through stored rules to update checkAsUser fields. Scanning
+        * the rule tree during load is relatively cheap (compared to
+        * constructing it in the first place), so we do it here.
         */
        setRuleCheckAsUser((Node *) rule->actions, relation->rd_rel->relowner);
        setRuleCheckAsUser(rule->qual, relation->rd_rel->relowner);
@@ -1626,14 +1626,14 @@ RelationClearRelation(Relation relation, bool rebuild)
     * Even non-system indexes should not be blown away if they are open and
     * have valid index support information.  This avoids problems with active
     * use of the index support information.  As with nailed indexes, we
-    * re-read the pg_class row to handle possible physical relocation of
-    * the index.
+    * re-read the pg_class row to handle possible physical relocation of the
+    * index.
     */
    if (relation->rd_rel->relkind == RELKIND_INDEX &&
        relation->rd_refcnt > 0 &&
        relation->rd_indexcxt != NULL)
    {
-       relation->rd_isvalid = false;           /* needs to be revalidated */
+       relation->rd_isvalid = false;   /* needs to be revalidated */
        RelationReloadClassinfo(relation);
        return;
    }
@@ -2140,9 +2140,9 @@ RelationBuildLocalRelation(const char *relname,
 
    /*
     * check that hardwired list of shared rels matches what's in the
-    * bootstrap .bki file.  If you get a failure here during initdb,
-    * you probably need to fix IsSharedRelation() to match whatever
-    * you've done to the set of shared relations.
+    * bootstrap .bki file.  If you get a failure here during initdb, you
+    * probably need to fix IsSharedRelation() to match whatever you've done
+    * to the set of shared relations.
     */
    if (shared_relation != IsSharedRelation(relid))
        elog(ERROR, "shared_relation flag for \"%s\" does not match IsSharedRelation(%u)",
@@ -2308,7 +2308,7 @@ RelationCacheInitialize(void)
  *     the system catalogs.  We first try to read pre-computed relcache
  *     entries from the pg_internal.init file.  If that's missing or
  *     broken, make phony entries for the minimum set of nailed-in-cache
- *     relations.  Then (unless bootstrapping) make sure we have entries
+ *     relations.  Then (unless bootstrapping) make sure we have entries
  *     for the critical system indexes.  Once we've done all this, we
  *     have enough infrastructure to open any system catalog or use any
  *     catcache.  The last step is to rewrite pg_internal.init if needed.
@@ -2319,7 +2319,7 @@ RelationCacheInitializePhase2(void)
    HASH_SEQ_STATUS status;
    RelIdCacheEnt *idhentry;
    MemoryContext oldcxt;
-   bool needNewCacheFile = false;
+   bool        needNewCacheFile = false;
 
    /*
     * switch to cache memory context
@@ -2375,7 +2375,7 @@ RelationCacheInitializePhase2(void)
     * RewriteRelRulenameIndexId and TriggerRelidNameIndexId are not critical
     * in the same way as the others, because the critical catalogs don't
     * (currently) have any rules or triggers, and so these indexes can be
-    * rebuilt without inducing recursion.  However they are used during
+    * rebuilt without inducing recursion.  However they are used during
     * relcache load when a rel does have rules or triggers, so we choose to
     * nail them for performance reasons.
     */
@@ -2505,7 +2505,7 @@ BuildHardcodedDescriptor(int natts, Form_pg_attribute attrs, bool hasoids)
    oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
 
    result = CreateTemplateTupleDesc(natts, hasoids);
-   result->tdtypeid = RECORDOID;   /* not right, but we don't care */
+   result->tdtypeid = RECORDOID;       /* not right, but we don't care */
    result->tdtypmod = -1;
 
    for (i = 0; i < natts; i++)
@@ -3166,7 +3166,7 @@ load_relcache_init_file(void)
            if ((nread = fread(rel->rd_options, 1, len, fp)) != len)
                goto read_failed;
            if (len != VARATT_SIZE(rel->rd_options))
-               goto read_failed;               /* sanity check */
+               goto read_failed;       /* sanity check */
        }
        else
        {
@@ -3457,7 +3457,7 @@ write_relcache_init_file(void)
 
            /* finally, write the vector of support procedures */
            write_item(rel->rd_support,
-                      relform->relnatts * (am->amsupport * sizeof(RegProcedure)),
+                 relform->relnatts * (am->amsupport * sizeof(RegProcedure)),
                       fp);
        }
 
index 2eaa9ee09699dbcf5059afa9af265b0aacf25eee..79aba4ebc824c3f77c20c4e20dffc32a33039b35 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.106 2006/07/14 14:52:25 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.107 2006/10/04 00:30:00 momjian Exp $
  *
  * NOTES
  *   These routines allow the parser/planner/executor to perform
@@ -516,7 +516,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;
 
index ee91c9fe411700da971d5dcece7c8a98b6d46a2d..c5a0272414d55994e74bf7b4fdd85ce2e8a8efe4 100644 (file)
@@ -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.21 2006/07/14 14:52:25 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.22 2006/10/04 00:30:01 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -268,9 +268,9 @@ lookup_type_cache(Oid type_id, int flags)
        Assert(rel->rd_rel->reltype == typentry->type_id);
 
        /*
-        * Link to the tupdesc and increment its refcount (we assert it's
-        * a refcounted descriptor).  We don't use IncrTupleDescRefCount()
-        * for this, because the reference mustn't be entered in the current
+        * Link to the tupdesc and increment its refcount (we assert it's a
+        * refcounted descriptor).  We don't use IncrTupleDescRefCount() for
+        * this, because the reference mustn't be entered in the current
         * resource owner; it can outlive the current query.
         */
        typentry->tupDesc = RelationGetDescr(rel);
@@ -372,7 +372,7 @@ lookup_rowtype_tupdesc_noerror(Oid type_id, int32 typmod, bool noError)
 TupleDesc
 lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod)
 {
-   TupleDesc tmp;
+   TupleDesc   tmp;
 
    tmp = lookup_rowtype_tupdesc_internal(type_id, typmod, false);
    return CreateTupleDescCopyConstr(tmp);
@@ -501,9 +501,9 @@ flush_rowtype_cache(Oid type_id)
        return;                 /* tupdesc hasn't been requested */
 
    /*
-    * Release our refcount and free the tupdesc if none remain.
-    * (Can't use DecrTupleDescRefCount because this reference is not
-    * logged in current resource owner.)
+    * Release our refcount and free the tupdesc if none remain. (Can't use
+    * DecrTupleDescRefCount because this reference is not logged in current
+    * resource owner.)
     */
    Assert(typentry->tupDesc->tdrefcount > 0);
    if (--typentry->tupDesc->tdrefcount == 0)
index b12674026e2d7be8956044b5fd95bfd6066a1449..c3710c62115f8228b3966e0ae65be2e1c6220681 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.90 2006/09/27 18:40:09 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.91 2006/10/04 00:30:01 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 
 /* signatures for PostgreSQL-specific library init/fini functions */
-typedef void (*PG_init_t)(void);
-typedef void (*PG_fini_t)(void);
+typedef void (*PG_init_t) (void);
+typedef void (*PG_fini_t) (void);
 
 /* hashtable entry for rendezvous variables */
 typedef struct
-{ 
-   char    varName[NAMEDATALEN];   /* hash key (must be first) */
-   void   *varValue;
+{
+   char        varName[NAMEDATALEN];   /* hash key (must be first) */
+   void       *varValue;
 } rendezvousHashEntry;
 
 /*
@@ -168,7 +168,7 @@ lookup_external_function(void *filehandle, char *funcname)
 
 /*
  * Load the specified dynamic-link library file, unless it already is
- * loaded.  Return the pg_dl* handle for the file.
+ * loaded. Return the pg_dl* handle for the file.
  *
  * Note: libname is expected to be an exact name for the library file.
  */
@@ -248,7 +248,7 @@ internal_load_library(const char *libname)
            const Pg_magic_struct *magic_data_ptr = (*magic_func) ();
 
            if (magic_data_ptr->len != magic_data.len ||
-               memcmp(magic_data_ptr, &magic_data, magic_data.len) != 0)
+               memcmp(magic_data_ptr, &magic_data, magic_data.len) != 0)
            {
                /* copy data block before unlinking library */
                Pg_magic_struct module_magic_data = *magic_data_ptr;
@@ -258,22 +258,22 @@ internal_load_library(const char *libname)
                free((char *) file_scanner);
 
                /*
-                * Report suitable error.  It's probably not worth writing
-                * a separate error message for each field; only the most
-                * common case of wrong major version gets its own message.
+                * Report suitable error.  It's probably not worth writing a
+                * separate error message for each field; only the most common
+                * case of wrong major version gets its own message.
                 */
                if (module_magic_data.version != magic_data.version)
                    ereport(ERROR,
-                           (errmsg("incompatible library \"%s\": version mismatch",
-                                   libname),
-                            errdetail("Server is version %d.%d, library is version %d.%d.",
-                                      magic_data.version/100,
-                                      magic_data.version % 100,
-                                      module_magic_data.version/100,
-                                      module_magic_data.version % 100)));
+                    (errmsg("incompatible library \"%s\": version mismatch",
+                            libname),
+                     errdetail("Server is version %d.%d, library is version %d.%d.",
+                               magic_data.version / 100,
+                               magic_data.version % 100,
+                               module_magic_data.version / 100,
+                               module_magic_data.version % 100)));
                ereport(ERROR,
-                       (errmsg("incompatible library \"%s\": magic block mismatch",
-                               libname)));
+                (errmsg("incompatible library \"%s\": magic block mismatch",
+                        libname)));
            }
        }
        else
@@ -283,9 +283,9 @@ internal_load_library(const char *libname)
            free((char *) file_scanner);
            /* complain */
            ereport(ERROR,
-                   (errmsg("incompatible library \"%s\": missing magic block",
-                           libname),
-                    errhint("Extension libraries are now required to use the PG_MODULE_MAGIC macro.")));
+                 (errmsg("incompatible library \"%s\": missing magic block",
+                         libname),
+                  errhint("Extension libraries are now required to use the PG_MODULE_MAGIC macro.")));
        }
 
        /*
@@ -293,7 +293,7 @@ internal_load_library(const char *libname)
         */
        PG_init = (PG_init_t) pg_dlsym(file_scanner->handle, "_PG_init");
        if (PG_init)
-           (*PG_init)();
+           (*PG_init) ();
 
        /* OK to link it into list */
        if (file_list == NULL)
@@ -351,7 +351,7 @@ internal_unload_library(const char *libname)
             */
            PG_fini = (PG_fini_t) pg_dlsym(file_scanner->handle, "_PG_fini");
            if (PG_fini)
-               (*PG_fini)();
+               (*PG_fini) ();
 
            clear_external_function_hash(file_scanner->handle);
            pg_dlclose(file_scanner->handle);
@@ -441,8 +441,8 @@ expand_dynamic_library_name(const char *name)
    }
 
    /*
-    * If we can't find the file, just return the string as-is.
-    * The ensuing load attempt will fail and report a suitable message.
+    * If we can't find the file, just return the string as-is. The ensuing
+    * load attempt will fail and report a suitable message.
     */
    return pstrdup(name);
 }
@@ -575,7 +575,7 @@ find_in_dynamic_libpath(const char *basename)
 
 
 /*
- * Find (or create) a rendezvous variable that one dynamically 
+ * Find (or create) a rendezvous variable that one dynamically
  * loaded library can use to meet up with another.
  *
  * On the first call of this function for a particular varName,
@@ -589,22 +589,22 @@ find_in_dynamic_libpath(const char *basename)
  * to find each other and share information: they just need to agree
  * on the variable name and the data it will point to.
  */
-void **
+void     **
 find_rendezvous_variable(const char *varName)
 {
-   static HTAB         *rendezvousHash = NULL;
+   static HTAB *rendezvousHash = NULL;
 
    rendezvousHashEntry *hentry;
-   bool                 found;
+   bool        found;
 
    /* Create a hashtable if we haven't already done so in this process */
    if (rendezvousHash == NULL)
    {
-       HASHCTL ctl;
+       HASHCTL     ctl;
 
        MemSet(&ctl, 0, sizeof(ctl));
-       ctl.keysize    = NAMEDATALEN;
-       ctl.entrysize  = sizeof(rendezvousHashEntry);
+       ctl.keysize = NAMEDATALEN;
+       ctl.entrysize = sizeof(rendezvousHashEntry);
        rendezvousHash = hash_create("Rendezvous variable hash",
                                     16,
                                     &ctl,
index 4472b3fcc99410cb0d4b5041e67dab7ecec590cb..df4594b43583374b3dec9904511d0bbcec2ebb7c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.101 2006/05/30 21:21:30 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.102 2006/10/04 00:30:01 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1798,7 +1798,7 @@ ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf,
  *
  * This is little more than window dressing for FunctionCall1, but its use is
  * recommended anyway so that code invoking output functions can be identified
- * easily.  Note however that it does guarantee a non-toasted result.
+ * easily. Note however that it does guarantee a non-toasted result.
  */
 bytea *
 SendFunctionCall(FmgrInfo *flinfo, Datum val)
index aa0a6b11f2ac2992bf5608a8dcca052e6612b78b..23b48c0b6344829b6e51ac3c5cd75b3f7a9d75ad 100644 (file)
@@ -5,19 +5,19 @@
  *
  * dynahash.c supports both local-to-a-backend hash tables and hash tables in
  * shared memory.  For shared hash tables, it is the caller's responsibility
- * to provide appropriate access interlocking.  The simplest convention is
- * that a single LWLock protects the whole hash table.  Searches (HASH_FIND or
+ * to provide appropriate access interlocking. The simplest convention is
+ * that a single LWLock protects the whole hash table. Searches (HASH_FIND or
  * hash_seq_search) need only shared lock, but any update requires exclusive
  * lock.  For heavily-used shared tables, the single-lock approach creates a
  * concurrency bottleneck, so we also support "partitioned" locking wherein
  * there are multiple LWLocks guarding distinct subsets of the table.  To use
  * a hash table in partitioned mode, the HASH_PARTITION flag must be given
- * to hash_create.  This prevents any attempt to split buckets on-the-fly.
+ * to hash_create. This prevents any attempt to split buckets on-the-fly.
  * Therefore, each hash bucket chain operates independently, and no fields
  * of the hash header change after init except nentries and freeList.
  * A partitioned table uses a spinlock to guard changes of those two fields.
  * This lets any subset of the hash buckets be treated as a separately
- * lockable partition.  We expect callers to use the low-order bits of a
+ * lockable partition. We expect callers to use the low-order bits of a
  * lookup key's hash value as a partition number --- this will work because
  * of the way calc_bucket() maps hash values to bucket numbers.
  *
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.72 2006/09/27 18:40:09 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.73 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -124,7 +124,7 @@ struct HASHHDR
    /* These fields are fixed at hashtable creation */
    Size        keysize;        /* hash key length in bytes */
    Size        entrysize;      /* total user element size in bytes */
-   long        num_partitions; /* # partitions (must be power of 2), or 0 */
+   long        num_partitions; /* # partitions (must be power of 2), or 0 */
    long        ffactor;        /* target fill factor */
    long        max_dsize;      /* 'dsize' limit if directory is fixed size */
    long        ssize;          /* segment size --- must be power of 2 */
@@ -132,9 +132,10 @@ struct HASHHDR
    int         nelem_alloc;    /* number of entries to allocate at once */
 
 #ifdef HASH_STATISTICS
+
    /*
-    * Count statistics here.  NB: stats code doesn't bother with mutex,
-    * so counts could be corrupted a bit in a partitioned table.
+    * Count statistics here.  NB: stats code doesn't bother with mutex, so
+    * counts could be corrupted a bit in a partitioned table.
     */
    long        accesses;
    long        collisions;
@@ -287,8 +288,8 @@ 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 string_compare
-    * if you used string_hash (either explicitly or by default) and to memcmp
+    * If you don't specify a match function, it defaults to string_compare 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)
@@ -317,8 +318,8 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
    {
        /*
         * ctl structure and directory are preallocated for shared memory
-        * tables.  Note that HASH_DIRSIZE and HASH_ALLOC had better be set
-        * as well.
+        * tables.  Note that HASH_DIRSIZE and HASH_ALLOC had better be set as
+        * well.
         */
        hashp->hctl = info->hctl;
        hashp->dir = (HASHSEGMENT *) (((char *) info->hctl) + sizeof(HASHHDR));
@@ -413,8 +414,8 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
     * This reduces problems with run-time out-of-shared-memory conditions.
     *
     * For a non-shared hash table, preallocate the requested number of
-    * elements if it's less than our chosen nelem_alloc.  This avoids
-    * wasting space if the caller correctly estimates a small table size.
+    * elements if it's less than our chosen nelem_alloc.  This avoids wasting
+    * space if the caller correctly estimates a small table size.
     */
    if ((flags & HASH_SHARED_MEM) ||
        nelem < hctl->nelem_alloc)
@@ -479,15 +480,16 @@ choose_nelem_alloc(Size entrysize)
    elementSize = MAXALIGN(sizeof(HASHELEMENT)) + MAXALIGN(entrysize);
 
    /*
-    * The idea here is to choose nelem_alloc at least 32, but round up
-    * so that the allocation request will be a power of 2 or just less.
-    * This makes little difference for hash tables in shared memory,
-    * but for hash tables managed by palloc, the allocation request
-    * will be rounded up to a power of 2 anyway.  If we fail to take
-    * this into account, we'll waste as much as half the allocated space.
+    * The idea here is to choose nelem_alloc at least 32, but round up so
+    * that the allocation request will be a power of 2 or just less. This
+    * makes little difference for hash tables in shared memory, but for hash
+    * tables managed by palloc, the allocation request will be rounded up to
+    * a power of 2 anyway.  If we fail to take this into account, we'll waste
+    * as much as half the allocated space.
     */
    allocSize = 32 * 4;         /* assume elementSize at least 8 */
-   do {
+   do
+   {
        allocSize <<= 1;
        nelem_alloc = allocSize / elementSize;
    } while (nelem_alloc < 32);
@@ -926,7 +928,7 @@ hash_search_with_hash_value(HTAB *hashp,
            /* Check if it is time to split a bucket */
            /* Can't split if running in partitioned mode */
            if (!IS_PARTITIONED(hctl) &&
-               hctl->nentries / (long) (hctl->max_bucket + 1) >= hctl->ffactor)
+            hctl->nentries / (long) (hctl->max_bucket + 1) >= hctl->ffactor)
            {
                /*
                 * NOTE: failure to expand table is not a fatal error, it just
index af528881eff36c5bea59f87a38d07a855b7627c0..2b0a30abe0d4792678369b20cc5928f578913338 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.28 2006/09/27 18:40:09 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.29 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -32,9 +32,9 @@ string_hash(const void *key, Size keysize)
     * because when it is copied into the hash table it will be truncated at
     * that length.
     */
-   Size    s_len = strlen((const char *) key);
+   Size        s_len = strlen((const char *) key);
 
-   s_len = Min(s_len, keysize-1);
+   s_len = Min(s_len, keysize - 1);
    return DatumGetUInt32(hash_any((const unsigned char *) key,
                                   (int) s_len));
 }
index 1295288b89cd07a4e8d18d054afb6694f84bc776..265a3a06bee9f64b482d7244ba1158d66f1abdb6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.98 2006/05/02 11:28:55 teodor Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.99 2006/10/04 00:30:02 momjian Exp $
  *
  * NOTES
  *   Globals used all over the place should be declared here and not
@@ -108,4 +108,4 @@ int         VacuumCostDelay = 0;
 int            VacuumCostBalance = 0;      /* working state for vacuum */
 bool       VacuumCostActive = false;
 
-int        GinFuzzySearchLimit = 0;
+int            GinFuzzySearchLimit = 0;
index 2d979afeada2f72952cf97d1d7d39b397c2fcf65..5ddb0b2e44c3c737bba0d30f1ca694d25cdd0799 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.158 2006/08/16 04:32:48 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.159 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -60,7 +60,7 @@ static char socketLockFile[MAXPGPATH];
  * ----------------------------------------------------------------
  */
 
-bool IgnoreSystemIndexes = false;
+bool       IgnoreSystemIndexes = false;
 
 /* ----------------------------------------------------------------
  *     system index reindexing support
@@ -1097,7 +1097,7 @@ ValidatePgVersion(const char *path)
  *-------------------------------------------------------------------------
  */
 
-/* 
+/*
  * GUC variables: lists of library names to be preloaded at postmaster
  * start and at backend start
  */
@@ -1146,7 +1146,7 @@ load_libraries(const char *libraries, const char *gucname, bool restricted)
        /* If restricting, insert $libdir/plugins if not mentioned already */
        if (restricted && first_dir_separator(filename) == NULL)
        {
-           char   *expanded;
+           char       *expanded;
 
            expanded = palloc(strlen("$libdir/plugins/") + strlen(filename) + 1);
            strcpy(expanded, "$libdir/plugins/");
index 6664755fd3e0699d246bbb3dcaf43520d6c790a4..9ab8c9ba97f31659ca6e37b6a84fd05fe4d14187 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.170 2006/09/18 22:40:38 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.171 2006/10/04 00:30:02 momjian Exp $
  *
  *
  *-------------------------------------------------------------------------
@@ -132,9 +132,9 @@ CheckMyDatabase(const char *name, bool am_superuser)
    /*
     * Check permissions to connect to the database.
     *
-    * These checks are not enforced when in standalone mode, so that
-    * there is a way to recover from disabling all access to all databases,
-    * for example "UPDATE pg_database SET datallowconn = false;".
+    * These checks are not enforced when in standalone mode, so that there is
+    * a way to recover from disabling all access to all databases, for
+    * example "UPDATE pg_database SET datallowconn = false;".
     *
     * We do not enforce them for the autovacuum process either.
     */
@@ -150,9 +150,9 @@ CheckMyDatabase(const char *name, bool am_superuser)
                    name)));
 
        /*
-        * Check privilege to connect to the database.  (The am_superuser
-        * test is redundant, but since we have the flag, might as well
-        * check it and save a few cycles.)
+        * Check privilege to connect to the database.  (The am_superuser test
+        * is redundant, but since we have the flag, might as well check it
+        * and save a few cycles.)
         */
        if (!am_superuser &&
            pg_database_aclcheck(MyDatabaseId, GetUserId(),
@@ -294,8 +294,8 @@ InitPostgres(const char *dbname, const char *username)
    char       *fullpath;
 
    /*
-    * Set up the global variables holding database id and path.  But note
-    * we won't actually try to touch the database just yet.
+    * Set up the global variables holding database id and path.  But note we
+    * won't actually try to touch the database just yet.
     *
     * We take a shortcut in the bootstrap case, otherwise we have to look up
     * the db name in pg_database.
@@ -324,8 +324,8 @@ InitPostgres(const char *dbname, const char *username)
    SetDatabasePath(fullpath);
 
    /*
-    * Finish filling in the PGPROC struct, and add it to the ProcArray.
-    * (We need to know MyDatabaseId before we can do this, since it's entered
+    * Finish filling in the PGPROC struct, and add it to the ProcArray. (We
+    * need to know MyDatabaseId before we can do this, since it's entered
     * into the PGPROC struct.)
     *
     * Once I have done this, I am visible to other backends!
@@ -360,8 +360,8 @@ InitPostgres(const char *dbname, const char *username)
    /*
     * Initialize the relation cache and the system catalog caches.  Note that
     * no catalog access happens here; we only set up the hashtable structure.
-    * We must do this before starting a transaction because transaction
-    * abort would try to touch these hashtables.
+    * We must do this before starting a transaction because transaction abort
+    * would try to touch these hashtables.
     */
    RelationCacheInitialize();
    InitCatalogCache();
@@ -388,20 +388,19 @@ InitPostgres(const char *dbname, const char *username)
 
    /*
     * Now that we have a transaction, we can take locks.  Take a writer's
-    * lock on the database we are trying to connect to.  If there is
-    * a concurrently running DROP DATABASE on that database, this will
-    * block us until it finishes (and has updated the flat file copy
-    * of pg_database).
+    * lock on the database we are trying to connect to.  If there is a
+    * concurrently running DROP DATABASE on that database, this will block us
+    * until it finishes (and has updated the flat file copy of pg_database).
     *
-    * Note that the lock is not held long, only until the end of this
-    * startup transaction.  This is OK since we are already advertising
-    * our use of the database in the PGPROC array; anyone trying a DROP
-    * DATABASE after this point will see us there.
+    * Note that the lock is not held long, only until the end of this startup
+    * transaction.  This is OK since we are already advertising our use of
+    * the database in the PGPROC array; anyone trying a DROP DATABASE after
+    * this point will see us there.
     *
     * Note: use of RowExclusiveLock here is reasonable because we envision
-    * our session as being a concurrent writer of the database.  If we had
-    * a way of declaring a session as being guaranteed-read-only, we could
-    * use AccessShareLock for such sessions and thereby not conflict against
+    * our session as being a concurrent writer of the database.  If we had a
+    * way of declaring a session as being guaranteed-read-only, we could use
+    * AccessShareLock for such sessions and thereby not conflict against
     * CREATE DATABASE.
     */
    if (!bootstrap)
@@ -415,8 +414,8 @@ InitPostgres(const char *dbname, const char *username)
     */
    if (!bootstrap)
    {
-       Oid     dbid2;
-       Oid     tsid2;
+       Oid         dbid2;
+       Oid         tsid2;
 
        if (!FindMyDatabase(dbname, &dbid2, &tsid2) ||
            dbid2 != MyDatabaseId || tsid2 != MyDatabaseTableSpace)
@@ -424,12 +423,12 @@ InitPostgres(const char *dbname, const char *username)
                    (errcode(ERRCODE_UNDEFINED_DATABASE),
                     errmsg("database \"%s\" does not exist",
                            dbname),
-               errdetail("It seems to have just been dropped or renamed.")));
+              errdetail("It seems to have just been dropped or renamed.")));
    }
 
    /*
-    * Now we should be able to access the database directory safely.
-    * Verify it's there and looks reasonable.
+    * Now we should be able to access the database directory safely. Verify
+    * it's there and looks reasonable.
     */
    if (!bootstrap)
    {
@@ -440,8 +439,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(),
@@ -493,10 +492,10 @@ InitPostgres(const char *dbname, const char *username)
    initialize_acl();
 
    /*
-    * Read the real pg_database row for our database, check permissions
-    * and set up database-specific GUC settings.  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.)
+    * Read the real pg_database row for our database, check permissions and
+    * set up database-specific GUC settings.  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)
        CheckMyDatabase(dbname, am_superuser);
index deaf912ed005602381cc572a9ce729235414b2f7..5a771f5f55a983671093b64697a8fcddf8eebef0 100644 (file)
@@ -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.60 2006/05/21 20:05:19 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.61 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -70,7 +70,7 @@ mic2latin(const unsigned char *mic, unsigned char *p, int len,
        }
        else
        {
-           int     l = pg_mic_mblen(mic);
+           int         l = pg_mic_mblen(mic);
 
            if (len < l)
                report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,
@@ -217,7 +217,7 @@ mic2latin_with_table(const unsigned char *mic,
        }
        else
        {
-           int     l = pg_mic_mblen(mic);
+           int         l = pg_mic_mblen(mic);
 
            if (len < l)
                report_invalid_encoding(PG_MULE_INTERNAL, (const char *) mic,
index 0e964c4583763e2d92a7a722d4b75029a6d77c94..326d84238c52a6fa628221739317094dccd2778d 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.15 2006/05/30 22:12:14 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.16 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -173,7 +173,7 @@ euc_tw2mic(const unsigned char *euc, unsigned char *p, int len)
                                        (const char *) euc, len);
            if (c1 == SS2)
            {
-               c1 = euc[1];        /* plane No. */
+               c1 = euc[1];    /* plane No. */
                if (c1 == 0xa1)
                    *p++ = LC_CNS11643_1;
                else if (c1 == 0xa2)
@@ -187,7 +187,7 @@ euc_tw2mic(const unsigned char *euc, unsigned char *p, int len)
                *p++ = euc[3];
            }
            else
-           {                       /* CNS11643-1 */
+           {                   /* CNS11643-1 */
                *p++ = LC_CNS11643_1;
                *p++ = c1;
                *p++ = euc[1];
@@ -302,7 +302,7 @@ big52mic(const unsigned char *big5, unsigned char *p, int len)
            {
                *p++ = 0x9d;    /* LCPRV2 */
            }
-           *p++ = lc;      /* Plane No. */
+           *p++ = lc;          /* Plane No. */
            *p++ = (cnsBuf >> 8) & 0x00ff;
            *p++ = cnsBuf & 0x00ff;
        }
index b9f6c46c22b3c9ea3f6db05594e5c5ba3406cd6b..c311c1d3afa285a0830dd2fe07e9e9d23eadb60e 100644 (file)
@@ -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.16 2006/05/30 22:12:15 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.17 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -69,4 +69,3 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
 
    PG_RETURN_VOID();
 }
-
index d65f64f1efda21d8be56624d355c0da77a443bed..b8cbe7c7c0f3f01c8214e7d131b9de72c606228c 100644 (file)
@@ -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.15 2006/05/30 22:12:15 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.16 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,7 +64,7 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
    Assert(len >= 0);
 
    UtfToLocal(src, dest, ULmapGB18030,
-              sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), PG_GB18030, len);
+           sizeof(ULmapGB18030) / sizeof(pg_utf_to_local), PG_GB18030, len);
 
    PG_RETURN_VOID();
 }
index a53f99985add3ff9cd3e92b0cbd161a62976df74..668758e746d532c2abd6977ea3c4536473a71be8 100644 (file)
@@ -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.21 2006/07/11 18:26:11 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.22 2006/10/04 00:30:02 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -118,12 +118,12 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
    int         len = PG_GETARG_INT32(4);
-   int i;
+   int         i;
 
    Assert(PG_GETARG_INT32(1) == PG_UTF8);
    Assert(len >= 0);
 
-   for (i=0;ii++)
+   for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
    {
        if (encoding == maps[i].encoding)
        {
@@ -134,7 +134,7 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
 
    ereport(ERROR,
            (errcode(ERRCODE_INTERNAL_ERROR),
-            errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
+      errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
 
    PG_RETURN_VOID();
 }
@@ -146,12 +146,12 @@ utf8_to_iso8859(PG_FUNCTION_ARGS)
    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
    int         len = PG_GETARG_INT32(4);
-   int i;
+   int         i;
 
    Assert(PG_GETARG_INT32(0) == PG_UTF8);
    Assert(len >= 0);
 
-   for (i=0;ii++)
+   for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
    {
        if (encoding == maps[i].encoding)
        {
@@ -162,7 +162,7 @@ utf8_to_iso8859(PG_FUNCTION_ARGS)
 
    ereport(ERROR,
            (errcode(ERRCODE_INTERNAL_ERROR),
-            errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
+      errmsg("unexpected encoding id %d for ISO-8859 charsets", encoding)));
 
    PG_RETURN_VOID();
 }
index 627573b0f522af5a31ea66743d2579fc60635550..a3746d754b1db57ee56a4b8bd751b805bafd86df 100644 (file)
@@ -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_1/utf8_and_iso8859_1.c,v 1.17 2006/05/30 22:12:15 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.18 2006/10/04 00:30:03 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -93,7 +93,7 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS)
        }
        else
        {
-           int     l = pg_utf_mblen(src);
+           int         l = pg_utf_mblen(src);
 
            if (l > len || !pg_utf8_islegal(src, l))
                report_invalid_encoding(PG_UTF8, (const char *) src, len);
index c95919fa0a1ef8ea81c57107b58cc033d330ca43..559367701b0bc946342a93a3e6beacf875ee893e 100644 (file)
@@ -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_win/utf8_and_win.c,v 1.5 2006/07/11 18:26:11 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win/utf8_and_win.c,v 1.6 2006/10/04 00:30:03 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -68,37 +68,37 @@ typedef struct
 static pg_conv_map maps[] = {
    {PG_WIN866, LUmapWIN866, ULmapWIN866,
        sizeof(LUmapWIN866) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN866) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN866) / sizeof(pg_utf_to_local)},
    {PG_WIN874, LUmapWIN874, ULmapWIN874,
        sizeof(LUmapWIN874) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN874) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN874) / sizeof(pg_utf_to_local)},
    {PG_WIN1250, LUmapWIN1250, ULmapWIN1250,
        sizeof(LUmapWIN1250) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local)},
    {PG_WIN1251, LUmapWIN1251, ULmapWIN1251,
        sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1251) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1251) / sizeof(pg_utf_to_local)},
    {PG_WIN1252, LUmapWIN1252, ULmapWIN1252,
        sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1252) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1252) / sizeof(pg_utf_to_local)},
    {PG_WIN1253, LUmapWIN1253, ULmapWIN1253,
        sizeof(LUmapWIN1253) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1253) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1253) / sizeof(pg_utf_to_local)},
    {PG_WIN1254, LUmapWIN1254, ULmapWIN1254,
        sizeof(LUmapWIN1254) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1254) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1254) / sizeof(pg_utf_to_local)},
    {PG_WIN1255, LUmapWIN1255, ULmapWIN1255,
        sizeof(LUmapWIN1255) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1255) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1255) / sizeof(pg_utf_to_local)},
    {PG_WIN1256, LUmapWIN1256, ULmapWIN1256,
        sizeof(LUmapWIN1256) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local)},
    {PG_WIN1257, LUmapWIN1257, ULmapWIN1257,
        sizeof(LUmapWIN1257) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1257) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1257) / sizeof(pg_utf_to_local)},
    {PG_WIN1258, LUmapWIN1258, ULmapWIN1258,
        sizeof(LUmapWIN1258) / sizeof(pg_local_to_utf),
-       sizeof(ULmapWIN1258) / sizeof(pg_utf_to_local)},
+   sizeof(ULmapWIN1258) / sizeof(pg_utf_to_local)},
 };
 
 Datum
@@ -108,12 +108,12 @@ win_to_utf8(PG_FUNCTION_ARGS)
    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
    int         len = PG_GETARG_INT32(4);
-   int i;
+   int         i;
 
    Assert(PG_GETARG_INT32(1) == PG_UTF8);
    Assert(len >= 0);
 
-   for (i=0;ii++)
+   for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
    {
        if (encoding == maps[i].encoding)
        {
@@ -136,12 +136,12 @@ utf8_to_win(PG_FUNCTION_ARGS)
    unsigned char *src = (unsigned char *) PG_GETARG_CSTRING(2);
    unsigned char *dest = (unsigned char *) PG_GETARG_CSTRING(3);
    int         len = PG_GETARG_INT32(4);
-   int i;
+   int         i;
 
    Assert(PG_GETARG_INT32(0) == PG_UTF8);
    Assert(len >= 0);
 
-   for (i=0;ii++)
+   for (i = 0; i < sizeof(maps) / sizeof(pg_conv_map); i++)
    {
        if (encoding == maps[i].encoding)
        {
index c45d3eb77815fb2f1114309a31346dd8e46e2549..e91c8a2a58c2a2f6a874fc0490b200f54ce40255 100644 (file)
@@ -4,7 +4,7 @@
  * (currently mule internal code (mic) is used)
  * Tatsuo Ishii
  *
- * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.58 2006/07/14 14:52:25 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.59 2006/10/04 00:30:02 momjian Exp $
  */
 #include "postgres.h"
 
@@ -133,9 +133,9 @@ SetClientEncoding(int encoding, bool doit)
    else
    {
        /*
-        * This is the first time through, so create the context. Make
-        * it a child of TopMemoryContext so that these values survive
-        * across transactions.
+        * This is the first time through, so create the context. Make it a
+        * child of TopMemoryContext so that these values survive across
+        * transactions.
         */
        MbProcContext = AllocSetContextCreate(TopMemoryContext,
                                              "MbProcContext",
@@ -378,28 +378,27 @@ pg_client_to_server(const char *s, int len)
    {
        /*
         * No conversion is possible, but we must still validate the data,
-        * because the client-side code might have done string escaping
-        * using the selected client_encoding.  If the client encoding is
-        * ASCII-safe then we just do a straight validation under that
-        * encoding.  For an ASCII-unsafe encoding we have a problem:
-        * we dare not pass such data to the parser but we have no way
-        * to convert it.  We compromise by rejecting the data if it
-        * contains any non-ASCII characters.
+        * because the client-side code might have done string escaping using
+        * the selected client_encoding.  If the client encoding is ASCII-safe
+        * then we just do a straight validation under that encoding.  For an
+        * ASCII-unsafe encoding we have a problem: we dare not pass such data
+        * to the parser but we have no way to convert it.  We compromise by
+        * rejecting the data if it contains any non-ASCII characters.
         */
        if (PG_VALID_BE_ENCODING(ClientEncoding->encoding))
            (void) pg_verify_mbstr(ClientEncoding->encoding, s, len, false);
        else
        {
-           int     i;
+           int         i;
 
            for (i = 0; i < len; i++)
            {
                if (s[i] == '\0' || IS_HIGHBIT_SET(s[i]))
                    ereport(ERROR,
                            (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
-                            errmsg("invalid byte value for encoding \"%s\": 0x%02x",
-                                   pg_enc2name_tbl[PG_SQL_ASCII].name,
-                                   (unsigned char) s[i])));
+                    errmsg("invalid byte value for encoding \"%s\": 0x%02x",
+                           pg_enc2name_tbl[PG_SQL_ASCII].name,
+                           (unsigned char) s[i])));
            }
        }
        return (char *) s;
index b33cbef49ff17987f6a12600b6d003dce354d9aa..6828fce7d3a1add4b02e48554e4d47901ba6acab 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * conversion functions between pg_wchar and multibyte streams.
  * Tatsuo Ishii
- * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.57 2006/08/22 12:11:28 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.58 2006/10/04 00:30:02 momjian Exp $
  *
  * WIN1250 client encoding updated by Pavel Behal
  *
@@ -40,7 +40,7 @@
  * SQL/ASCII
  */
 static int
-pg_ascii2wchar_with_len
+           pg_ascii2wchar_with_len
            (const unsigned char *from, pg_wchar *to, int len)
 {
    int         cnt = 0;
@@ -68,7 +68,7 @@ pg_ascii_dsplen(const unsigned char *s)
        return 0;
    if (*s < 0x20 || *s == 0x7f)
        return -1;
-       
+
    return 1;
 }
 
@@ -82,7 +82,8 @@ static int    pg_euc2wchar_with_len
 
    while (len > 0 && *from)
    {
-       if (*from == SS2 && len >= 2)   /* JIS X 0201 (so called "1 byte KANA") */
+       if (*from == SS2 && len >= 2)   /* JIS X 0201 (so called "1 byte
+                                        * KANA") */
        {
            from++;
            *to = (SS2 << 8) | *from++;
@@ -95,13 +96,14 @@ static int  pg_euc2wchar_with_len
            *to |= *from++;
            len -= 3;
        }
-       else if (IS_HIGHBIT_SET(*from) && len >= 2) /* JIS X 0208 KANJI */
+       else if (IS_HIGHBIT_SET(*from) && len >= 2)     /* JIS X 0208 KANJI */
        {
            *to = *from++ << 8;
            *to |= *from++;
            len -= 2;
        }
-       else    /* must be ASCII */
+       else
+           /* must be ASCII */
        {
            *to = *from++;
            len--;
@@ -222,7 +224,7 @@ static int  pg_euccn2wchar_with_len
            *to |= *from++;
            len -= 3;
        }
-       else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 1 */
+       else if (IS_HIGHBIT_SET(*from) && len >= 2)     /* code set 1 */
        {
            *to = *from++ << 8;
            *to |= *from++;
@@ -278,7 +280,7 @@ static int  pg_euctw2wchar_with_len
        if (*from == SS2 && len >= 4)   /* code set 2 */
        {
            from++;
-           *to = (SS2 << 24) | (*from++ << 16) ;
+           *to = (SS2 << 24) | (*from++ << 16);
            *to |= *from++ << 8;
            *to |= *from++;
            len -= 4;
@@ -290,7 +292,7 @@ static int  pg_euctw2wchar_with_len
            *to |= *from++;
            len -= 3;
        }
-       else if (IS_HIGHBIT_SET(*from) && len >= 2) /* code set 2 */
+       else if (IS_HIGHBIT_SET(*from) && len >= 2)     /* code set 2 */
        {
            *to = *from++ << 8;
            *to |= *from++;
@@ -455,7 +457,7 @@ struct mbinterval
 
 /* auxiliary function for binary search in interval table */
 static int
-mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
+mbbisearch(pg_wchar ucs, const struct mbinterval * table, int max)
 {
    int         min = 0;
    int         mid;
@@ -677,14 +679,14 @@ pg_mule_mblen(const unsigned char *s)
    else if (IS_LCPRV2(*s))
        len = 4;
    else
-       len = 1;    /* assume ASCII */
+       len = 1;                /* assume ASCII */
    return len;
 }
 
 static int
 pg_mule_dsplen(const unsigned char *s)
 {
-   int len;
+   int         len;
 
    if (IS_LC1(*s))
        len = 1;
@@ -695,7 +697,7 @@ pg_mule_dsplen(const unsigned char *s)
    else if (IS_LCPRV2(*s))
        len = 2;
    else
-       len = 1;    /* assume ASCII */
+       len = 1;                /* assume ASCII */
 
    return len;
 }
@@ -739,11 +741,11 @@ pg_sjis_mblen(const unsigned char *s)
    int         len;
 
    if (*s >= 0xa1 && *s <= 0xdf)
-       len = 1;    /* 1 byte kana? */
+       len = 1;                /* 1 byte kana? */
    else if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* kanji? */
+       len = 2;                /* kanji? */
    else
-       len = 1;    /* should be ASCII */
+       len = 1;                /* should be ASCII */
    return len;
 }
 
@@ -753,11 +755,11 @@ pg_sjis_dsplen(const unsigned char *s)
    int         len;
 
    if (*s >= 0xa1 && *s <= 0xdf)
-       len = 1;    /* 1 byte kana? */
+       len = 1;                /* 1 byte kana? */
    else if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* kanji? */
+       len = 2;                /* kanji? */
    else
-       len = pg_ascii_dsplen(s);   /* should be ASCII */
+       len = pg_ascii_dsplen(s);       /* should be ASCII */
    return len;
 }
 
@@ -770,9 +772,9 @@ pg_big5_mblen(const unsigned char *s)
    int         len;
 
    if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* kanji? */
+       len = 2;                /* kanji? */
    else
-       len = 1;    /* should be ASCII */
+       len = 1;                /* should be ASCII */
    return len;
 }
 
@@ -782,9 +784,9 @@ pg_big5_dsplen(const unsigned char *s)
    int         len;
 
    if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* kanji? */
+       len = 2;                /* kanji? */
    else
-       len = pg_ascii_dsplen(s);   /* should be ASCII */
+       len = pg_ascii_dsplen(s);       /* should be ASCII */
    return len;
 }
 
@@ -797,9 +799,9 @@ pg_gbk_mblen(const unsigned char *s)
    int         len;
 
    if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* kanji? */
+       len = 2;                /* kanji? */
    else
-       len = 1;    /* should be ASCII */
+       len = 1;                /* should be ASCII */
    return len;
 }
 
@@ -809,9 +811,9 @@ pg_gbk_dsplen(const unsigned char *s)
    int         len;
 
    if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* kanji? */
+       len = 2;                /* kanji? */
    else
-       len = pg_ascii_dsplen(s);   /* should be ASCII */
+       len = pg_ascii_dsplen(s);       /* should be ASCII */
    return len;
 }
 
@@ -824,9 +826,9 @@ pg_uhc_mblen(const unsigned char *s)
    int         len;
 
    if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* 2byte? */
+       len = 2;                /* 2byte? */
    else
-       len = 1;    /* should be ASCII */
+       len = 1;                /* should be ASCII */
    return len;
 }
 
@@ -836,9 +838,9 @@ pg_uhc_dsplen(const unsigned char *s)
    int         len;
 
    if (IS_HIGHBIT_SET(*s))
-       len = 2;    /* 2byte? */
+       len = 2;                /* 2byte? */
    else
-       len = pg_ascii_dsplen(s);   /* should be ASCII */
+       len = pg_ascii_dsplen(s);       /* should be ASCII */
    return len;
 }
 
@@ -852,7 +854,7 @@ pg_gb18030_mblen(const unsigned char *s)
    int         len;
 
    if (!IS_HIGHBIT_SET(*s))
-       len = 1;    /* ASCII */
+       len = 1;                /* ASCII */
    else
    {
        if ((*(s + 1) >= 0x40 && *(s + 1) <= 0x7e) || (*(s + 1) >= 0x80 && *(s + 1) <= 0xfe))
@@ -873,7 +875,7 @@ pg_gb18030_dsplen(const unsigned char *s)
    if (IS_HIGHBIT_SET(*s))
        len = 2;
    else
-       len = pg_ascii_dsplen(s);   /* ASCII */
+       len = pg_ascii_dsplen(s);       /* ASCII */
    return len;
 }
 
@@ -906,13 +908,14 @@ static int
 pg_eucjp_verifier(const unsigned char *s, int len)
 {
    int         l;
-   unsigned char c1, c2;
+   unsigned char c1,
+               c2;
 
    c1 = *s++;
 
    switch (c1)
    {
-       case SS2:       /* JIS X 0201 */
+       case SS2:               /* JIS X 0201 */
            l = 2;
            if (l > len)
                return -1;
@@ -921,7 +924,7 @@ pg_eucjp_verifier(const unsigned char *s, int len)
                return -1;
            break;
 
-       case SS3:       /* JIS X 0212 */
+       case SS3:               /* JIS X 0212 */
            l = 3;
            if (l > len)
                return -1;
@@ -945,7 +948,8 @@ pg_eucjp_verifier(const unsigned char *s, int len)
                if (!IS_EUC_RANGE_VALID(c2))
                    return -1;
            }
-           else        /* must be ASCII */
+           else
+               /* must be ASCII */
            {
                l = 1;
            }
@@ -959,7 +963,8 @@ static int
 pg_euckr_verifier(const unsigned char *s, int len)
 {
    int         l;
-   unsigned char c1, c2;
+   unsigned char c1,
+               c2;
 
    c1 = *s++;
 
@@ -974,7 +979,8 @@ pg_euckr_verifier(const unsigned char *s, int len)
        if (!IS_EUC_RANGE_VALID(c2))
            return -1;
    }
-   else        /* must be ASCII */
+   else
+       /* must be ASCII */
    {
        l = 1;
    }
@@ -989,13 +995,14 @@ static int
 pg_euctw_verifier(const unsigned char *s, int len)
 {
    int         l;
-   unsigned char c1, c2;
+   unsigned char c1,
+               c2;
 
    c1 = *s++;
 
    switch (c1)
    {
-       case SS2:       /* CNS 11643 Plane 1-7 */
+       case SS2:               /* CNS 11643 Plane 1-7 */
            l = 4;
            if (l > len)
                return -1;
@@ -1010,7 +1017,7 @@ pg_euctw_verifier(const unsigned char *s, int len)
                return -1;
            break;
 
-       case SS3:       /* unused */
+       case SS3:               /* unused */
            return -1;
 
        default:
@@ -1024,7 +1031,8 @@ pg_euctw_verifier(const unsigned char *s, int len)
                if (!IS_EUC_RANGE_VALID(c2))
                    return -1;
            }
-           else        /* must be ASCII */
+           else
+               /* must be ASCII */
            {
                l = 1;
            }
@@ -1036,7 +1044,8 @@ pg_euctw_verifier(const unsigned char *s, int len)
 static int
 pg_johab_verifier(const unsigned char *s, int len)
 {
-   int l, mbl;
+   int         l,
+               mbl;
    unsigned char c;
 
    l = mbl = pg_johab_mblen(s);
@@ -1059,7 +1068,8 @@ pg_johab_verifier(const unsigned char *s, int len)
 static int
 pg_mule_verifier(const unsigned char *s, int len)
 {
-   int l, mbl;
+   int         l,
+               mbl;
    unsigned char c;
 
    l = mbl = pg_mule_mblen(s);
@@ -1085,8 +1095,10 @@ pg_latin1_verifier(const unsigned char *s, int len)
 static int
 pg_sjis_verifier(const unsigned char *s, int len)
 {
-   int l, mbl;
-   unsigned char c1, c2;
+   int         l,
+               mbl;
+   unsigned char c1,
+               c2;
 
    l = mbl = pg_sjis_mblen(s);
 
@@ -1106,7 +1118,8 @@ pg_sjis_verifier(const unsigned char *s, int len)
 static int
 pg_big5_verifier(const unsigned char *s, int len)
 {
-   int l, mbl;
+   int         l,
+               mbl;
 
    l = mbl = pg_big5_mblen(s);
 
@@ -1125,7 +1138,8 @@ pg_big5_verifier(const unsigned char *s, int len)
 static int
 pg_gbk_verifier(const unsigned char *s, int len)
 {
-   int l, mbl;
+   int         l,
+               mbl;
 
    l = mbl = pg_gbk_mblen(s);
 
@@ -1144,7 +1158,8 @@ pg_gbk_verifier(const unsigned char *s, int len)
 static int
 pg_uhc_verifier(const unsigned char *s, int len)
 {
-   int l, mbl;
+   int         l,
+               mbl;
 
    l = mbl = pg_uhc_mblen(s);
 
@@ -1163,7 +1178,8 @@ pg_uhc_verifier(const unsigned char *s, int len)
 static int
 pg_gb18030_verifier(const unsigned char *s, int len)
 {
-   int l, mbl;
+   int         l,
+               mbl;
 
    l = mbl = pg_gb18030_mblen(s);
 
@@ -1182,7 +1198,7 @@ pg_gb18030_verifier(const unsigned char *s, int len)
 static int
 pg_utf8_verifier(const unsigned char *s, int len)
 {
-   int l = pg_utf_mblen(s);
+   int         l = pg_utf_mblen(s);
 
    if (len < l)
        return -1;
@@ -1270,45 +1286,45 @@ pg_utf8_islegal(const unsigned char *source, int length)
  *-------------------------------------------------------------------
  */
 pg_wchar_tbl pg_wchar_table[] = {
-   {pg_ascii2wchar_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1},       /* 0; PG_SQL_ASCII  */
-   {pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3},       /* 1; PG_EUC_JP */
-   {pg_euccn2wchar_with_len, pg_euccn_mblen, pg_euccn_dsplen, pg_euccn_verifier, 3},       /* 2; PG_EUC_CN */
-   {pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3},       /* 3; PG_EUC_KR */
-   {pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, pg_euctw_verifier, 3},       /* 4; PG_EUC_TW */
-   {pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3},       /* 5; PG_JOHAB */
+   {pg_ascii2wchar_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1},   /* 0; PG_SQL_ASCII  */
+   {pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3},   /* 1; PG_EUC_JP */
+   {pg_euccn2wchar_with_len, pg_euccn_mblen, pg_euccn_dsplen, pg_euccn_verifier, 3},   /* 2; PG_EUC_CN */
+   {pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3},   /* 3; PG_EUC_KR */
+   {pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, pg_euctw_verifier, 3},   /* 4; PG_EUC_TW */
+   {pg_johab2wchar_with_len, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3},   /* 5; PG_JOHAB */
    {pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, pg_utf8_verifier, 4},  /* 6; PG_UTF8 */
-   {pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 3}, /* 7; PG_MULE_INTERNAL */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 8; PG_LATIN1 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 9; PG_LATIN2 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 10; PG_LATIN3 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 11; PG_LATIN4 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 12; PG_LATIN5 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 13; PG_LATIN6 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 14; PG_LATIN7 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 15; PG_LATIN8 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 16; PG_LATIN9 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 17; PG_LATIN10 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 18; PG_WIN1256 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 19; PG_WIN1258 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 20; PG_WIN874 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 21; PG_KOI8 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 22; PG_WIN1251 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 22; PG_WIN1252 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 23; PG_WIN866 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 24; ISO-8859-5 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 25; ISO-8859-6 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 26; ISO-8859-7 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 27; ISO-8859-8 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 28; PG_WIN1250 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 29; PG_WIN1253 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 30; PG_WIN1254 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 31; PG_WIN1255 */
-   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},   /* 32; PG_WIN1257 */
-   {0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2},        /* 33; PG_SJIS */
-   {0, pg_big5_mblen, pg_big5_dsplen, pg_big5_verifier, 2},        /* 34; PG_BIG5 */
+   {pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 3},       /* 7; PG_MULE_INTERNAL */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 8; PG_LATIN1 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 9; PG_LATIN2 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 10; PG_LATIN3 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 11; PG_LATIN4 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 12; PG_LATIN5 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 13; PG_LATIN6 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 14; PG_LATIN7 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 15; PG_LATIN8 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 16; PG_LATIN9 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 17; PG_LATIN10 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 18; PG_WIN1256 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 19; PG_WIN1258 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 20; PG_WIN874 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 21; PG_KOI8 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 22; PG_WIN1251 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 22; PG_WIN1252 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 23; PG_WIN866 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 24; ISO-8859-5 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 25; ISO-8859-6 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 26; ISO-8859-7 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 27; ISO-8859-8 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 28; PG_WIN1250 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 29; PG_WIN1253 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 30; PG_WIN1254 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 31; PG_WIN1255 */
+   {pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1},       /* 32; PG_WIN1257 */
+   {0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2},    /* 33; PG_SJIS */
+   {0, pg_big5_mblen, pg_big5_dsplen, pg_big5_verifier, 2},    /* 34; PG_BIG5 */
    {0, pg_gbk_mblen, pg_gbk_dsplen, pg_gbk_verifier, 2},       /* 35; PG_GBK */
    {0, pg_uhc_mblen, pg_uhc_dsplen, pg_uhc_verifier, 2},       /* 36; PG_UHC */
-   {0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 2} /* 37; PG_GB18030 */
+   {0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 2}    /* 37; PG_GB18030 */
 };
 
 /* returns the byte length of a word for mule internal code */
@@ -1358,8 +1374,8 @@ pg_encoding_verifymb(int encoding, const char *mbstr, int len)
 
    return ((encoding >= 0 &&
             encoding < sizeof(pg_wchar_table) / sizeof(pg_wchar_tbl)) ?
-       ((*pg_wchar_table[encoding].mbverify) ((const unsigned char *) mbstr, len)) :
-   ((*pg_wchar_table[PG_SQL_ASCII].mbverify) ((const unsigned char *) mbstr, len)));
+           ((*pg_wchar_table[encoding].mbverify) ((const unsigned char *) mbstr, len)) :
+           ((*pg_wchar_table[PG_SQL_ASCII].mbverify) ((const unsigned char *) mbstr, len)));
 }
 
 /*
@@ -1487,9 +1503,9 @@ report_invalid_encoding(int encoding, const char *mbstr, int len)
             errmsg("invalid byte sequence for encoding \"%s\": 0x%s",
                    pg_enc2name_tbl[encoding].name,
                    buf),
-            errhint("This error can also happen if the byte sequence does not "
-                    "match the encoding expected by the server, which is controlled "
-                    "by \"client_encoding\".")));
+         errhint("This error can also happen if the byte sequence does not "
+           "match the encoding expected by the server, which is controlled "
+                 "by \"client_encoding\".")));
 }
 
 /*
@@ -1516,10 +1532,10 @@ report_untranslatable_char(int src_encoding, int dest_encoding,
 
    ereport(ERROR,
            (errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
-            errmsg("character 0x%s of encoding \"%s\" has no equivalent in \"%s\"",
-                   buf,
-                   pg_enc2name_tbl[src_encoding].name,
-                   pg_enc2name_tbl[dest_encoding].name)));
+     errmsg("character 0x%s of encoding \"%s\" has no equivalent in \"%s\"",
+            buf,
+            pg_enc2name_tbl[src_encoding].name,
+            pg_enc2name_tbl[dest_encoding].name)));
 }
 
 #endif
index d0eb77a4ad428d02a69f3c0ba801a3a8e2370d1f..74092a8f78521a3de3c8422387c23e7178347a86 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut .
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.353 2006/10/03 21:11:54 momjian Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.354 2006/10/04 00:30:03 momjian Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -204,6 +204,7 @@ static char *log_error_verbosity_str;
 static char *log_statement_str;
 static char *log_min_error_statement_str;
 static char *log_destination_string;
+
 #ifdef HAVE_SYSLOG
 static char *syslog_facility_str;
 static char *syslog_ident_str;
@@ -220,7 +221,7 @@ static char *locale_ctype;
 static char *regex_flavor_string;
 static char *server_encoding_string;
 static char *server_version_string;
-static int  server_version_num;
+static int server_version_num;
 static char *timezone_string;
 static char *timezone_abbreviations_string;
 static char *XactIsoLevel_string;
@@ -992,9 +993,9 @@ static struct config_bool ConfigureNamesBool[] =
 
    {
        {"allow_system_table_mods", PGC_POSTMASTER, DEVELOPER_OPTIONS,
-        gettext_noop("Allows modifications of the structure of system tables."),
-        NULL,
-        GUC_NOT_IN_SAMPLE
+           gettext_noop("Allows modifications of the structure of system tables."),
+           NULL,
+           GUC_NOT_IN_SAMPLE
        },
        &allowSystemTableMods,
        false, NULL, NULL
@@ -1002,10 +1003,10 @@ static struct config_bool ConfigureNamesBool[] =
 
    {
        {"ignore_system_indexes", PGC_BACKEND, DEVELOPER_OPTIONS,
-        gettext_noop("Disables reading from system indexes."),
-        gettext_noop("It does not prevent updating the indexes, so it is safe "
-                     "to use.  The worst consequence is slowness."),
-        GUC_NOT_IN_SAMPLE
+           gettext_noop("Disables reading from system indexes."),
+           gettext_noop("It does not prevent updating the indexes, so it is safe "
+                        "to use.  The worst consequence is slowness."),
+           GUC_NOT_IN_SAMPLE
        },
        &IgnoreSystemIndexes,
        false, NULL, NULL
@@ -1022,19 +1023,19 @@ static struct config_int ConfigureNamesInt[] =
 {
    {
        {"archive_timeout", PGC_SIGHUP, WAL_SETTINGS,
-        gettext_noop("Forces a switch to the next xlog file if a "
-                      "new file has not been started within N seconds."),
-        NULL,
-        GUC_UNIT_S
+           gettext_noop("Forces a switch to the next xlog file if a "
+                        "new file has not been started within N seconds."),
+           NULL,
+           GUC_UNIT_S
        },
        &XLogArchiveTimeout,
        0, 0, INT_MAX, NULL, NULL
    },
    {
        {"post_auth_delay", PGC_BACKEND, DEVELOPER_OPTIONS,
-        gettext_noop("Waits N seconds on connection startup after authentication."),
-        gettext_noop("This allows attaching a debugger to the process."),
-        GUC_NOT_IN_SAMPLE | GUC_UNIT_S
+           gettext_noop("Waits N seconds on connection startup after authentication."),
+           gettext_noop("This allows attaching a debugger to the process."),
+           GUC_NOT_IN_SAMPLE | GUC_UNIT_S
        },
        &PostAuthDelay,
        0, 0, INT_MAX, NULL, NULL
@@ -1863,7 +1864,7 @@ static struct config_string ConfigureNamesString[] =
        {"default_tablespace", PGC_USERSET, CLIENT_CONN_STATEMENT,
            gettext_noop("Sets the default tablespace to create tables and indexes in."),
            gettext_noop("An empty string selects the database's default tablespace."),
-           GUC_IS_NAME
+           GUC_IS_NAME
        },
        &default_tablespace,
        "", assign_default_tablespace, NULL
@@ -2295,7 +2296,7 @@ static void ReportGUCOption(struct config_generic * record);
 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
 static void ShowAllGUCConfig(DestReceiver *dest);
 static char *_ShowOption(struct config_generic * record, bool use_units);
-static bool is_newvalue_equal(struct config_generic *record, const char *newvalue);
+static bool is_newvalue_equal(struct config_generic * record, const char *newvalue);
 
 
 /*
@@ -3584,7 +3585,7 @@ parse_int(const char *value, int *result, int flags)
 
    if ((flags & GUC_UNIT_MEMORY) && endptr != value)
    {
-       bool used = false;
+       bool        used = false;
 
        while (*endptr == ' ')
            endptr++;
@@ -3612,10 +3613,10 @@ parse_int(const char *value, int *result, int flags)
            switch (flags & GUC_UNIT_MEMORY)
            {
                case GUC_UNIT_BLOCKS:
-                   val /= (BLCKSZ/1024);
+                   val /= (BLCKSZ / 1024);
                    break;
                case GUC_UNIT_XBLOCKS:
-                   val /= (XLOG_BLCKSZ/1024);
+                   val /= (XLOG_BLCKSZ / 1024);
                    break;
            }
        }
@@ -3623,7 +3624,7 @@ parse_int(const char *value, int *result, int flags)
 
    if ((flags & GUC_UNIT_TIME) && endptr != value)
    {
-       bool used = false;
+       bool        used = false;
 
        while (*endptr == ' ')
            endptr++;
@@ -3662,12 +3663,12 @@ parse_int(const char *value, int *result, int flags)
        {
            switch (flags & GUC_UNIT_TIME)
            {
-           case GUC_UNIT_S:
-               val /= MS_PER_S;
-               break;
-           case GUC_UNIT_MIN:
-               val /= MS_PER_MIN;
-               break;
+               case GUC_UNIT_S:
+                   val /= MS_PER_S;
+                   break;
+               case GUC_UNIT_MIN:
+                   val /= MS_PER_MIN;
+                   break;
            }
        }
    }
@@ -4173,9 +4174,10 @@ set_config_option(const char *name, const char *value,
                    newval = guc_strdup(elevel, value);
                    if (newval == NULL)
                        return false;
+
                    /*
-                    * The only sort of "parsing" check we need to do is
-                    * apply truncation if GUC_IS_NAME.
+                    * The only sort of "parsing" check we need to do is apply
+                    * truncation if GUC_IS_NAME.
                     */
                    if (conf->gen.flags & GUC_IS_NAME)
                        truncate_identifier(newval, strlen(newval), true);
@@ -4988,11 +4990,11 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
                values[2] = "kB";
                break;
            case GUC_UNIT_BLOCKS:
-               snprintf(buf, sizeof(buf), "%dkB", BLCKSZ/1024);
+               snprintf(buf, sizeof(buf), "%dkB", BLCKSZ / 1024);
                values[2] = buf;
                break;
            case GUC_UNIT_XBLOCKS:
-               snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ/1024);
+               snprintf(buf, sizeof(buf), "%dkB", XLOG_BLCKSZ / 1024);
                values[2] = buf;
                break;
            case GUC_UNIT_MS:
@@ -5271,18 +5273,18 @@ _ShowOption(struct config_generic * record, bool use_units)
                    val = (*conf->show_hook) ();
                else
                {
-                   char unit[4];
-                   int result = *conf->variable;
+                   char        unit[4];
+                   int         result = *conf->variable;
 
                    if (use_units && result > 0 && (record->flags & GUC_UNIT_MEMORY))
                    {
                        switch (record->flags & GUC_UNIT_MEMORY)
                        {
                            case GUC_UNIT_BLOCKS:
-                               result *= BLCKSZ/1024;
+                               result *= BLCKSZ / 1024;
                                break;
                            case GUC_UNIT_XBLOCKS:
-                               result *= XLOG_BLCKSZ/1024;
+                               result *= XLOG_BLCKSZ / 1024;
                                break;
                        }
 
@@ -5342,7 +5344,7 @@ _ShowOption(struct config_generic * record, bool use_units)
                        strcpy(unit, "");
 
                    snprintf(buffer, sizeof(buffer), "%d%s",
-                            (int)result, unit);
+                            (int) result, unit);
                    val = buffer;
                }
            }
@@ -5387,37 +5389,37 @@ _ShowOption(struct config_generic * record, bool use_units)
 
 
 static bool
-is_newvalue_equal(struct config_generic *record, const char *newvalue)
+is_newvalue_equal(struct config_generic * record, const char *newvalue)
 {
    switch (record->vartype)
    {
        case PGC_BOOL:
-       {
-           struct config_bool *conf = (struct config_bool *) record;
-           bool newval;
+           {
+               struct config_bool *conf = (struct config_bool *) record;
+               bool        newval;
 
-           return parse_bool(newvalue, &newval) && *conf->variable == newval;
-       }
+               return parse_bool(newvalue, &newval) && *conf->variable == newval;
+           }
        case PGC_INT:
-       {
-           struct config_int *conf = (struct config_int *) record;
-           int newval;
+           {
+               struct config_int *conf = (struct config_int *) record;
+               int         newval;
 
-           return parse_int(newvalue, &newval, record->flags) && *conf->variable == newval;
-       }
+               return parse_int(newvalue, &newval, record->flags) && *conf->variable == newval;
+           }
        case PGC_REAL:
-       {
-           struct config_real *conf = (struct config_real *) record;
-           double newval;
+           {
+               struct config_real *conf = (struct config_real *) record;
+               double      newval;
 
-           return parse_real(newvalue, &newval) && *conf->variable == newval;
-       }
+               return parse_real(newvalue, &newval) && *conf->variable == newval;
+           }
        case PGC_STRING:
-       {
-           struct config_string *conf = (struct config_string *) record;
+           {
+               struct config_string *conf = (struct config_string *) record;
 
-           return strcmp(*conf->variable, newvalue) == 0;
-       }
+               return strcmp(*conf->variable, newvalue) == 0;
+           }
    }
 
    return false;
@@ -6251,7 +6253,7 @@ assign_debug_assertions(bool newval, bool doit, GucSource source)
    if (newval)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                errmsg("assertion checking is not supported by this build")));
+              errmsg("assertion checking is not supported by this build")));
 #endif
    return true;
 }
@@ -6338,12 +6340,11 @@ static const char *
 assign_backslash_quote(const char *newval, bool doit, GucSource source)
 {
    BackslashQuoteType bq;
-   bool    bqbool;
+   bool        bqbool;
 
    /*
-    * Although only "on", "off", and "safe_encoding" are documented,
-    * we use parse_bool so we can accept all the likely variants of
-    * "on" and "off".
+    * Although only "on", "off", and "safe_encoding" are documented, we use
+    * parse_bool so we can accept all the likely variants of "on" and "off".
     */
    if (pg_strcasecmp(newval, "safe_encoding") == 0)
        bq = BACKSLASH_QUOTE_SAFE_ENCODING;
@@ -6367,14 +6368,14 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
     * The powerup value shown above for timezone_abbreviations is "UNKNOWN".
     * When we see this we just do nothing.  If this value isn't overridden
     * from the config file then pg_timezone_abbrev_initialize() will
-    * eventually replace it with "Default".  This hack has two purposes:
-    * to avoid wasting cycles loading values that might soon be overridden
-    * from the config file, and to avoid trying to read the timezone abbrev
-    * files during InitializeGUCOptions().  The latter doesn't work in an
-    * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and
-    * so we can't locate PGSHAREDIR.  (Essentially the same hack is used
-    * to delay initializing TimeZone ... if we have any more, we should
-    * try to clean up and centralize this mechanism ...)
+    * eventually replace it with "Default".  This hack has two purposes: to
+    * avoid wasting cycles loading values that might soon be overridden from
+    * the config file, and to avoid trying to read the timezone abbrev files
+    * during InitializeGUCOptions().  The latter doesn't work in an
+    * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
+    * we can't locate PGSHAREDIR.  (Essentially the same hack is used to
+    * delay initializing TimeZone ... if we have any more, we should try to
+    * clean up and centralize this mechanism ...)
     */
    if (strcmp(newval, "UNKNOWN") == 0)
    {
@@ -6385,11 +6386,11 @@ assign_timezone_abbreviations(const char *newval, bool doit, GucSource source)
    if (timezone_abbreviations_string == NULL ||
        strcmp(timezone_abbreviations_string, newval) != 0)
    {
-       int     elevel;
+       int         elevel;
 
        /*
         * If reading config file, only the postmaster should bleat loudly
-        * about problems.  Otherwise, it's just this one process doing it,
+        * about problems.  Otherwise, it's just this one process doing it,
         * and we use WARNING message level.
         */
        if (source == PGC_S_FILE)
index f6c4c588b203bb23d46245334c29d709f9f290ae..38d98634f1019843688fd5557ff6d5540d36c480 100644 (file)
@@ -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.32 2006/09/27 18:40:10 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.33 2006/10/04 00:30:04 momjian Exp $
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  * various details abducted from various places
@@ -31,7 +31,7 @@
 #include "utils/ps_status.h"
 
 extern char **environ;
-bool update_process_title = true;
+bool       update_process_title = true;
 
 
 /*
@@ -287,7 +287,7 @@ set_ps_display(const char *activity, bool force)
 
    if (!force && !update_process_title)
        return;
-       
+
 #ifndef PS_USE_NONE
    /* no ps display for stand-alone backend */
    if (!IsUnderPostmaster)
@@ -336,8 +336,8 @@ set_ps_display(const char *activity, bool force)
 #ifdef PS_USE_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
+        * 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;
@@ -351,7 +351,6 @@ set_ps_display(const char *activity, bool force)
        ident_handle = CreateEvent(NULL, TRUE, FALSE, name);
    }
 #endif   /* PS_USE_WIN32 */
-
 #endif   /* not PS_USE_NONE */
 }
 
index 1a092ca24225a63dac804d17b699deae81d175c1..1eff2e401b618ccabba45fcc0c9f201b93d1593c 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/misc/tzparser.c,v 1.1 2006/07/25 03:51:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/misc/tzparser.c,v 1.2 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,11 +35,11 @@ static int  tz_elevel;          /* to avoid passing this around a lot */
 
 static bool validateTzEntry(tzEntry *tzentry);
 static bool splitTzLine(const char *filename, int lineno,
-                       char *line, tzEntry *tzentry);
-static int addToArray(tzEntry **base, int *arraysize, int n,
-                      tzEntry *entry, bool override);
-static int ParseTzFile(const char *filename, int depth,
-                       tzEntry **base, int *arraysize, int n);
+           char *line, tzEntry *tzentry);
+static int addToArray(tzEntry **base, int *arraysize, int n,
+          tzEntry *entry, bool override);
+static int ParseTzFile(const char *filename, int depth,
+           tzEntry **base, int *arraysize, int n);
 
 
 /*
@@ -53,7 +53,8 @@ validateTzEntry(tzEntry *tzentry)
    unsigned char *p;
 
    /*
-    * Check restrictions imposed by datetkntbl storage format (see datetime.c)
+    * Check restrictions imposed by datetkntbl storage format (see
+    * datetime.c)
     */
    if (strlen(tzentry->abbrev) > TOKMAXLEN)
    {
@@ -77,8 +78,8 @@ validateTzEntry(tzEntry *tzentry)
    /*
     * Sanity-check the offset: shouldn't exceed 14 hours
     */
-   if (tzentry->offset > 14*60*60 ||
-       tzentry->offset < -14*60*60)
+   if (tzentry->offset > 14 * 60 * 60 ||
+       tzentry->offset < -14 * 60 * 60)
    {
        ereport(tz_elevel,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@@ -105,11 +106,11 @@ validateTzEntry(tzEntry *tzentry)
 static bool
 splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
 {
-   char    *abbrev;
-   char    *offset;
-   char    *offset_endptr;
-   char    *remain;
-   char    *is_dst;
+   char       *abbrev;
+   char       *offset;
+   char       *offset_endptr;
+   char       *remain;
+   char       *is_dst;
 
    tzentry->lineno = lineno;
    tzentry->filename = filename;
@@ -130,8 +131,8 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
    {
        ereport(tz_elevel,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                errmsg("missing time zone offset in time zone file \"%s\", line %d",
-                       filename, lineno)));
+        errmsg("missing time zone offset in time zone file \"%s\", line %d",
+               filename, lineno)));
        return false;
    }
    tzentry->offset = strtol(offset, &offset_endptr, 10);
@@ -157,7 +158,7 @@ splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
        remain = is_dst;
    }
 
-   if (!remain)        /* no more non-whitespace chars */
+   if (!remain)                /* no more non-whitespace chars */
        return true;
 
    if (remain[0] != '#')       /* must be a comment */
@@ -186,23 +187,23 @@ static int
 addToArray(tzEntry **base, int *arraysize, int n,
           tzEntry *entry, bool override)
 {
-   tzEntryarrayptr;
+   tzEntry    *arrayptr;
    int         low;
    int         high;
 
    /*
-    * Search the array for a duplicate; as a useful side effect, the array
-    * is maintained in sorted order.  We use strcmp() to ensure we match
-    * the sort order datetime.c expects.
+    * Search the array for a duplicate; as a useful side effect, the array is
+    * maintained in sorted order.  We use strcmp() to ensure we match the
+    * sort order datetime.c expects.
     */
    arrayptr = *base;
    low = 0;
-   high = n-1;
+   high = n - 1;
    while (low <= high)
    {
-       int     mid = (low + high) >> 1;
-       tzEntry *midptr = arrayptr + mid;
-       int     cmp;
+       int         mid = (low + high) >> 1;
+       tzEntry    *midptr = arrayptr + mid;
+       int         cmp;
 
        cmp = strcmp(entry->abbrev, midptr->abbrev);
        if (cmp < 0)
@@ -214,7 +215,7 @@ addToArray(tzEntry **base, int *arraysize, int n,
            /*
             * Found a duplicate entry; complain unless it's the same.
             */
-           if (midptr->offset == entry->offset &&
+           if (midptr->offset == entry->offset &&
                midptr->is_dst == entry->is_dst)
            {
                /* return unchanged array */
@@ -230,8 +231,8 @@ addToArray(tzEntry **base, int *arraysize, int n,
            /* same abbrev but something is different, complain */
            ereport(tz_elevel,
                    (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                    errmsg("time zone abbreviation \"%s\" is multiply defined",
-                           entry->abbrev),
+                 errmsg("time zone abbreviation \"%s\" is multiply defined",
+                        entry->abbrev),
                     errdetail("Time zone file \"%s\", line %d conflicts with file \"%s\", line %d.",
                               midptr->filename, midptr->lineno,
                               entry->filename, entry->lineno)));
@@ -257,7 +258,7 @@ addToArray(tzEntry **base, int *arraysize, int n,
    /* Must dup the abbrev to ensure it survives */
    arrayptr->abbrev = pstrdup(entry->abbrev);
 
-   return n+1;
+   return n + 1;
 }
 
 /*
@@ -275,15 +276,15 @@ static int
 ParseTzFile(const char *filename, int depth,
            tzEntry **base, int *arraysize, int n)
 {
-   char            share_path[MAXPGPATH];
-   char            file_path[MAXPGPATH];
-   FILE           *tzFile;
-   char            tzbuf[1024];
-   char           *line;
-   tzEntry         tzentry;
-   int             lineno = 0;
-   bool            override = false;
-   const char     *p;
+   char        share_path[MAXPGPATH];
+   char        file_path[MAXPGPATH];
+   FILE       *tzFile;
+   char        tzbuf[1024];
+   char       *line;
+   tzEntry     tzentry;
+   int         lineno = 0;
+   bool        override = false;
+   const char *p;
 
    /*
     * We enforce that the filename is all alpha characters.  This may be
@@ -299,23 +300,23 @@ ParseTzFile(const char *filename, int depth,
            if (depth > 0)
                ereport(tz_elevel,
                        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                          errmsg("invalid time zone file name \"%s\"",
-                                filename)));
+                        errmsg("invalid time zone file name \"%s\"",
+                               filename)));
            return -1;
        }
    }
 
    /*
-    * The maximal recursion depth is a pretty arbitrary setting.
-    * It is hard to imagine that someone needs more than 3 levels so stick
-    * with this conservative setting until someone complains.
+    * The maximal recursion depth is a pretty arbitrary setting. It is hard
+    * to imagine that someone needs more than 3 levels so stick with this
+    * conservative setting until someone complains.
     */
    if (depth > 3)
    {
        ereport(tz_elevel,
                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                errmsg("time zone file recursion limit exceeded in file \"%s\"",
-                       filename)));
+            errmsg("time zone file recursion limit exceeded in file \"%s\"",
+                   filename)));
        return -1;
    }
 
@@ -350,13 +351,13 @@ ParseTzFile(const char *filename, int depth,
            /* else we're at EOF after all */
            break;
        }
-       if (strlen(tzbuf) == sizeof(tzbuf)-1) 
+       if (strlen(tzbuf) == sizeof(tzbuf) - 1)
        {
            /* the line is too long for tzbuf */
            ereport(tz_elevel,
                    (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
-                    errmsg("line is too long in time zone file \"%s\", line %d",
-                           filename, lineno)));
+                errmsg("line is too long in time zone file \"%s\", line %d",
+                       filename, lineno)));
            return -1;
        }
 
@@ -365,15 +366,15 @@ ParseTzFile(const char *filename, int depth,
        while (*line && isspace((unsigned char) *line))
            line++;
 
-       if (*line == '\0')              /* empty line */
+       if (*line == '\0')      /* empty line */
            continue;
-       if (*line == '#')               /* comment line */
+       if (*line == '#')       /* comment line */
            continue;
 
        if (pg_strncasecmp(line, "@INCLUDE", strlen("@INCLUDE")) == 0)
        {
            /* pstrdup so we can use filename in result data structure */
-           charincludeFile = pstrdup(line + strlen("@INCLUDE"));
+           char       *includeFile = pstrdup(line + strlen("@INCLUDE"));
 
            includeFile = strtok(includeFile, WHITESPACE);
            if (!includeFile || !*includeFile)
@@ -425,15 +426,15 @@ load_tzoffsets(const char *filename, bool doit, int elevel)
 {
    MemoryContext tmpContext;
    MemoryContext oldContext;
-   tzEntry    *array;
+   tzEntry    *array;
    int         arraysize;
    int         n;
 
    tz_elevel = elevel;
 
    /*
-    * Create a temp memory context to work in.  This makes it easy to
-    * clean up afterwards.
+    * Create a temp memory context to work in.  This makes it easy to clean
+    * up afterwards.
     */
    tmpContext = AllocSetContextCreate(CurrentMemoryContext,
                                       "TZParserMemory",
index 5762607b9e3df8bfd11126348dbb066f83f0beda..7f525891f6091bb3aad954c8ad697187529b1c9a 100644 (file)
@@ -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.67 2006/06/28 22:05:37 neilc Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mmgr/aset.c,v 1.68 2006/10/04 00:30:04 momjian Exp $
  *
  * NOTE:
  * This is a new (Feb. 05, 1999) implementation of the allocation set
@@ -883,7 +883,7 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
    if (oldsize > ALLOC_CHUNK_LIMIT)
    {
        /*
-        * The chunk must have been allocated as a single-chunk block.  Find
+        * The chunk must have been allocated as a single-chunk block.  Find
         * the containing block and use realloc() to make it bigger with
         * minimum space wastage.
         */
index 883f075eec227c94f23ad2a366b5a62a449c7805..7fabe243ace066e521d8a0782513348ecf7211b8 100644 (file)
@@ -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.95 2006/09/27 18:40:10 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.96 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -69,7 +69,7 @@ do { \
    PortalHashEnt *hentry; bool found; \
    \
    hentry = (PortalHashEnt *) hash_search(PortalHashTable, \
-                                          (NAME), HASH_ENTER, &found); \
+                                          (NAME), HASH_ENTER, &found); \
    if (found) \
        elog(ERROR, "duplicate portal name"); \
    hentry->portal = PORTAL; \
@@ -145,11 +145,11 @@ GetPortalByName(const char *name)
  *     Get the "primary" Query within a portal, ie, the one marked canSetTag.
  *
  * Returns NULL if no such Query.  If multiple Query structs within the
- * portal are marked canSetTag, returns the first one.  Neither of these
+ * portal are marked canSetTag, returns the first one. Neither of these
  * cases should occur in present usages of this function.
  *
  * Note: the reason this is just handed a List is so that prepared statements
- * can share the code.  For use with a portal, use PortalGetPrimaryQuery
+ * can share the code. For use with a portal, use PortalGetPrimaryQuery
  * rather than calling this directly.
  */
 Query *
@@ -790,22 +790,21 @@ AtSubCleanup_Portals(SubTransactionId mySubid)
 Datum
 pg_cursor(PG_FUNCTION_ARGS)
 {
-   FuncCallContext    *funcctx;
-   HASH_SEQ_STATUS    *hash_seq;
-   PortalHashEnt      *hentry;
+   FuncCallContext *funcctx;
+   HASH_SEQ_STATUS *hash_seq;
+   PortalHashEnt *hentry;
 
    /* stuff done only on the first call of the function */
    if (SRF_IS_FIRSTCALL())
    {
-       MemoryContext       oldcontext;
-       TupleDesc           tupdesc;
+       MemoryContext oldcontext;
+       TupleDesc   tupdesc;
 
        /* create a function context for cross-call persistence */
        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);
 
@@ -819,8 +818,8 @@ pg_cursor(PG_FUNCTION_ARGS)
            funcctx->user_fctx = NULL;
 
        /*
-        * build tupdesc for result tuples. This must match the
-        * definition of the pg_cursors view in system_views.sql
+        * build tupdesc for result tuples. This must match the definition of
+        * the pg_cursors view in system_views.sql
         */
        tupdesc = CreateTemplateTupleDesc(6, false);
        TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
@@ -871,7 +870,7 @@ pg_cursor(PG_FUNCTION_ARGS)
            nulls[1] = true;
        else
            values[1] = DirectFunctionCall1(textin,
-                                           CStringGetDatum(portal->sourceText));
+                                       CStringGetDatum(portal->sourceText));
        values[2] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_HOLD);
        values[3] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_BINARY);
        values[4] = BoolGetDatum(portal->cursorOptions & CURSOR_OPT_SCROLL);
@@ -884,4 +883,3 @@ pg_cursor(PG_FUNCTION_ARGS)
 
    SRF_RETURN_DONE(funcctx);
 }
-
index 18dc4617785f0919c436ccc495ec6a4a535ec121..d978fd135a7e9cd6f174bc4256536e00c6af7d86 100644 (file)
@@ -55,7 +55,7 @@
  * To support the above policy of writing to the lowest free block,
  * ltsGetFreeBlock sorts the list of free block numbers into decreasing
  * order each time it is asked for a block and the list isn't currently
- * sorted.  This is an efficient way to handle it because we expect cycles
+ * sorted. This is an efficient way to handle it because we expect cycles
  * of releasing many blocks followed by re-using many blocks, due to
  * tuplesort.c's "preread" behavior.
  *
@@ -70,7 +70,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.21 2006/03/07 23:46:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.22 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -157,7 +157,7 @@ struct LogicalTapeSet
     *
     * If blocksSorted is true then the block numbers in freeBlocks are in
     * *decreasing* order, so that removing the last entry gives us the lowest
-    * free block.  We re-sort the blocks whenever a block is demanded; this
+    * free block.  We re-sort the blocks whenever a block is demanded; this
     * should be reasonably efficient given the expected usage pattern.
     */
    bool        forgetFreeSpace;    /* are we remembering free blocks? */
@@ -171,7 +171,7 @@ struct LogicalTapeSet
     * is of length nTapes.
     */
    int         nTapes;         /* # of logical tapes in set */
-   LogicalTape tapes[1];       /* must be last in struct! */
+   LogicalTape tapes[1];       /* must be last in struct! */
 };
 
 static void ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer);
@@ -303,12 +303,12 @@ ltsReleaseBlock(LogicalTapeSet *lts, long blocknum)
    }
 
    /*
-    * Add blocknum to array, and mark the array unsorted if it's no longer
-    * in decreasing order.
+    * Add blocknum to array, and mark the array unsorted if it's no longer in
+    * decreasing order.
     */
    ndx = lts->nFreeBlocks++;
    lts->freeBlocks[ndx] = blocknum;
-   if (ndx > 0 && lts->freeBlocks[ndx-1] < blocknum)
+   if (ndx > 0 && lts->freeBlocks[ndx - 1] < blocknum)
        lts->blocksSorted = false;
 }
 
@@ -522,12 +522,12 @@ LogicalTapeSetCreate(int ntapes)
    int         i;
 
    /*
-    * Create top-level struct including per-tape LogicalTape structs.
-    * First LogicalTape struct is already counted in sizeof(LogicalTapeSet).
+    * Create top-level struct including per-tape LogicalTape structs. First
+    * LogicalTape struct is already counted in sizeof(LogicalTapeSet).
     */
    Assert(ntapes > 0);
    lts = (LogicalTapeSet *) palloc(sizeof(LogicalTapeSet) +
-                                   (ntapes - 1) * sizeof(LogicalTape));
+                                   (ntapes - 1) *sizeof(LogicalTape));
    lts->pfile = BufFileCreateTemp(false);
    lts->nFileBlocks = 0L;
    lts->forgetFreeSpace = false;
@@ -540,7 +540,7 @@ LogicalTapeSetCreate(int ntapes)
    /*
     * Initialize per-tape structs.  Note we allocate the I/O buffer and
     * first-level indirect block for a tape only when it is first actually
-    * written to.  This avoids wasting memory space when tuplesort.c
+    * written to.  This avoids wasting memory space when tuplesort.c
     * overestimates the number of tapes needed.
     */
    for (i = 0; i < ntapes; i++)
@@ -591,7 +591,7 @@ LogicalTapeSetClose(LogicalTapeSet *lts)
  * Mark a logical tape set as not needing management of free space anymore.
  *
  * This should be called if the caller does not intend to write any more data
- * into the tape set, but is reading from un-frozen tapes.  Since no more
+ * into the tape set, but is reading from un-frozen tapes. Since no more
  * writes are planned, remembering free blocks is no longer useful.  Setting
  * this flag lets us avoid wasting time and space in ltsReleaseBlock(), which
  * is not designed to handle large numbers of free blocks.
index 08e63e0756dbc1cb8837e89818f370c8ae4c428b..652f9a2ff44b36a915faf5dcb69e227043a08b1b 100644 (file)
@@ -77,7 +77,7 @@
  * grounds that 7 is the "sweet spot" on the tapes-to-passes curve according
  * to Knuth's figure 70 (section 5.4.2).  However, Knuth is assuming that
  * tape drives are expensive beasts, and in particular that there will always
- * be many more runs than tape drives.  In our implementation a "tape drive"
+ * be many more runs than tape drives. In our implementation a "tape drive"
  * doesn't cost much more than a few Kb of memory buffers, so we can afford
  * to have lots of them.  In particular, if we can have as many tape drives
  * as sorted runs, we can eliminate any repeated I/O at all.  In the current
@@ -91,7 +91,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.69 2006/10/03 22:18:23 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.70 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -119,28 +119,28 @@ bool      trace_sort = false;
 
 
 /*
- * The objects we actually sort are SortTuple structs.  These contain
+ * The objects we actually sort are SortTuple structs. These contain
  * a pointer to the tuple proper (might be a MinimalTuple or IndexTuple),
  * which is a separate palloc chunk --- we assume it is just one chunk and
  * can be freed by a simple pfree().  SortTuples also contain the tuple's
  * first key column in Datum/nullflag format, and an index integer.
  *
  * Storing the first key column lets us save heap_getattr or index_getattr
- * calls during tuple comparisons.  We could extract and save all the key
+ * calls during tuple comparisons. We could extract and save all the key
  * columns not just the first, but this would increase code complexity and
  * overhead, and wouldn't actually save any comparison cycles in the common
  * case where the first key determines the comparison result.  Note that
  * for a pass-by-reference datatype, datum1 points into the "tuple" storage.
  *
  * When sorting single Datums, the data value is represented directly by
- * datum1/isnull1.  If the datatype is pass-by-reference and isnull1 is false,
+ * datum1/isnull1. If the datatype is pass-by-reference and isnull1 is false,
  * then datum1 points to a separately palloc'd data value that is also pointed
  * to by the "tuple" pointer; otherwise "tuple" is NULL.
  *
  * While building initial runs, tupindex holds the tuple's run number.  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.  tupindex goes unused
+ * from the same tape in the case of pre-read entries. tupindex goes unused
  * if the sort occurs entirely in memory.
  */
 typedef struct
@@ -205,7 +205,7 @@ struct Tuplesortstate
     * qsort_arg_comparator.
     */
    int         (*comparetup) (const SortTuple *a, const SortTuple *b,
-                              Tuplesortstate *state);
+                                          Tuplesortstate *state);
 
    /*
     * Function to copy a supplied input tuple into palloc'd space and set up
@@ -223,19 +223,19 @@ struct Tuplesortstate
     * state->availMem by the amount of memory space thereby released.
     */
    void        (*writetup) (Tuplesortstate *state, int tapenum,
-                            SortTuple *stup);
+                                        SortTuple *stup);
 
    /*
     * Function to read a stored tuple from tape back into memory. 'len' is
     * the already-read length of the stored tuple.  Create a palloc'd copy,
-    * initialize tuple/datum1/isnull1 in the target SortTuple struct,
-    * and decrease state->availMem by the amount of memory space consumed.
+    * initialize tuple/datum1/isnull1 in the target SortTuple struct, and
+    * decrease state->availMem by the amount of memory space consumed.
     */
    void        (*readtup) (Tuplesortstate *state, SortTuple *stup,
-                           int tapenum, unsigned int len);
+                                       int tapenum, unsigned int len);
 
    /*
-    * This array holds the tuples now in sort memory.  If we are in state
+    * This array holds the tuples now 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
@@ -255,8 +255,8 @@ struct Tuplesortstate
    int         currentRun;
 
    /*
-    * Unless otherwise noted, all pointer variables below are pointers
-    * to arrays of length maxTapes, holding per-tape data.
+    * Unless otherwise noted, all pointer variables below are pointers to
+    * arrays of length maxTapes, holding per-tape data.
     */
 
    /*
@@ -280,7 +280,7 @@ struct Tuplesortstate
    int        *mergeavailslots;    /* slots left for prereading each tape */
    long       *mergeavailmem;  /* availMem for prereading each tape */
    int         mergefreelist;  /* head of freelist of recycled slots */
-   int         mergefirstfree; /* first slot never used in this merge */
+   int         mergefirstfree; /* first slot never used in this merge */
 
    /*
     * Variables for Algorithm D.  Note that destTape is a "logical" tape
@@ -314,8 +314,8 @@ struct Tuplesortstate
     * tuplesort_begin_heap and used only by the MinimalTuple routines.
     */
    TupleDesc   tupDesc;
-   ScanKey     scanKeys;           /* array of length nKeys */
-   SortFunctionKind *sortFnKinds;  /* array of length nKeys */
+   ScanKey     scanKeys;       /* array of length nKeys */
+   SortFunctionKind *sortFnKinds;      /* array of length nKeys */
 
    /*
     * These variables are specific to the IndexTuple case; they are set by
@@ -346,7 +346,7 @@ struct Tuplesortstate
 };
 
 #define COMPARETUP(state,a,b)  ((*(state)->comparetup) (a, b, state))
-#define COPYTUP(state,stup,tup)    ((*(state)->copytup) (state, stup, tup))
+#define COPYTUP(state,stup,tup) ((*(state)->copytup) (state, stup, tup))
 #define WRITETUP(state,tape,stup)  ((*(state)->writetup) (state, tape, stup))
 #define READTUP(state,stup,tape,len) ((*(state)->readtup) (state, stup, tape, len))
 #define LACKMEM(state)     ((state)->availMem < 0)
@@ -411,26 +411,26 @@ static void tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex);
 static unsigned int getlen(Tuplesortstate *state, int tapenum, bool eofOK);
 static void markrunend(Tuplesortstate *state, int tapenum);
 static int comparetup_heap(const SortTuple *a, const SortTuple *b,
-                          Tuplesortstate *state);
+               Tuplesortstate *state);
 static void copytup_heap(Tuplesortstate *state, SortTuple *stup, void *tup);
 static void writetup_heap(Tuplesortstate *state, int tapenum,
-                         SortTuple *stup);
+             SortTuple *stup);
 static void readtup_heap(Tuplesortstate *state, SortTuple *stup,
-                        int tapenum, unsigned int len);
+            int tapenum, unsigned int len);
 static int comparetup_index(const SortTuple *a, const SortTuple *b,
-                           Tuplesortstate *state);
+                Tuplesortstate *state);
 static void copytup_index(Tuplesortstate *state, SortTuple *stup, void *tup);
 static void writetup_index(Tuplesortstate *state, int tapenum,
-                          SortTuple *stup);
+              SortTuple *stup);
 static void readtup_index(Tuplesortstate *state, SortTuple *stup,
-                         int tapenum, unsigned int len);
+             int tapenum, unsigned int len);
 static int comparetup_datum(const SortTuple *a, const SortTuple *b,
-                           Tuplesortstate *state);
+                Tuplesortstate *state);
 static void copytup_datum(Tuplesortstate *state, SortTuple *stup, void *tup);
 static void writetup_datum(Tuplesortstate *state, int tapenum,
-                          SortTuple *stup);
+              SortTuple *stup);
 static void readtup_datum(Tuplesortstate *state, SortTuple *stup,
-                         int tapenum, unsigned int len);
+             int tapenum, unsigned int len);
 
 
 /*
@@ -460,8 +460,8 @@ tuplesort_begin_common(int workMem, bool randomAccess)
    MemoryContext oldcontext;
 
    /*
-    * Create a working memory context for this sort operation.
-    * All data needed by the sort will live inside this context.
+    * Create a working memory context for this sort operation. All data
+    * needed by the sort will live inside this context.
     */
    sortcontext = AllocSetContextCreate(CurrentMemoryContext,
                                        "TupleSort",
@@ -470,8 +470,8 @@ tuplesort_begin_common(int workMem, bool randomAccess)
                                        ALLOCSET_DEFAULT_MAXSIZE);
 
    /*
-    * Make the Tuplesortstate within the per-sort context.  This way,
-    * we don't need a separate pfree() operation for it at shutdown.
+    * Make the Tuplesortstate within the per-sort context.  This way, we
+    * don't need a separate pfree() operation for it at shutdown.
     */
    oldcontext = MemoryContextSwitchTo(sortcontext);
 
@@ -680,8 +680,8 @@ tuplesort_end(Tuplesortstate *state)
    /*
     * Delete temporary "tape" files, if any.
     *
-    * Note: want to include this in reported total cost of sort, hence
-    * need for two #ifdef TRACE_SORT sections.
+    * Note: want to include this in reported total cost of sort, hence need
+    * for two #ifdef TRACE_SORT sections.
     */
    if (state->tapeset)
        LogicalTapeSetClose(state->tapeset);
@@ -701,8 +701,8 @@ tuplesort_end(Tuplesortstate *state)
    MemoryContextSwitchTo(oldcontext);
 
    /*
-    * Free the per-sort memory context, thereby releasing all working
-    * memory, including the Tuplesortstate struct itself.
+    * Free the per-sort memory context, thereby releasing all working memory,
+    * including the Tuplesortstate struct itself.
     */
    MemoryContextDelete(state->sortcontext);
 }
@@ -721,15 +721,16 @@ grow_memtuples(Tuplesortstate *state)
 {
    /*
     * We need to be sure that we do not cause LACKMEM to become true, else
-    * the space management algorithm will go nuts.  We assume here that
-    * the memory chunk overhead associated with the memtuples array is
-    * constant and so there will be no unexpected addition to what we ask
-    * for.  (The minimum array size established in tuplesort_begin_common
-    * is large enough to force palloc to treat it as a separate chunk, so
-    * this assumption should be good.  But let's check it.)
+    * the space management algorithm will go nuts.  We assume here that the
+    * memory chunk overhead associated with the memtuples array is constant
+    * and so there will be no unexpected addition to what we ask for.  (The
+    * minimum array size established in tuplesort_begin_common is large
+    * enough to force palloc to treat it as a separate chunk, so this
+    * assumption should be good.  But let's check it.)
     */
    if (state->availMem <= (long) (state->memtupsize * sizeof(SortTuple)))
        return false;
+
    /*
     * On a 64-bit machine, allowedMem could be high enough to get us into
     * trouble with MaxAllocSize, too.
@@ -804,8 +805,8 @@ tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
    SortTuple   stup;
 
    /*
-    * If it's a pass-by-reference value, copy it into memory we control,
-    * and decrease availMem.  Then call the common code.
+    * If it's a pass-by-reference value, copy it into memory we control, and
+    * decrease availMem.  Then call the common code.
     */
    if (isNull || state->datumTypeByVal)
    {
@@ -837,10 +838,10 @@ puttuple_common(Tuplesortstate *state, SortTuple *tuple)
        case TSS_INITIAL:
 
            /*
-            * Save the tuple into the unsorted array.  First, grow the
-            * array as needed.  Note that we try to grow the array when there
-            * is still one free slot remaining --- if we fail, there'll still
-            * be room to store the incoming tuple, and then we'll switch to
+            * Save the tuple into the unsorted array.  First, grow the array
+            * as needed.  Note that we try to grow the array when there is
+            * still one free slot remaining --- if we fail, there'll still be
+            * room to store the incoming tuple, and then we'll switch to
             * tape-based operation.
             */
            if (state->memtupcount >= state->memtupsize - 1)
@@ -869,14 +870,14 @@ puttuple_common(Tuplesortstate *state, SortTuple *tuple)
        case TSS_BUILDRUNS:
 
            /*
-            * Insert the 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.)
+            * Insert the 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.)
             *
             * Note there will always be at least one tuple in the heap at
             * this point; see dumptuples.
@@ -1262,14 +1263,14 @@ tuplesort_merge_order(long allowedMem)
    int         mOrder;
 
    /*
-    * We need one tape for each merge input, plus another one for the
-    * output, and each of these tapes needs buffer space.  In addition
-    * we want MERGE_BUFFER_SIZE workspace per input tape (but the output
-    * tape doesn't count).
+    * We need one tape for each merge input, plus another one for the output,
+    * and each of these tapes needs buffer space.  In addition we want
+    * MERGE_BUFFER_SIZE workspace per input tape (but the output tape doesn't
+    * count).
     *
     * Note: you might be thinking we need to account for the memtuples[]
-    * array in this calculation, but we effectively treat that as part of
-    * the MERGE_BUFFER_SIZE workspace.
+    * array in this calculation, but we effectively treat that as part of the
+    * MERGE_BUFFER_SIZE workspace.
     */
    mOrder = (allowedMem - TAPE_BUFFER_OVERHEAD) /
        (MERGE_BUFFER_SIZE + TAPE_BUFFER_OVERHEAD);
@@ -1298,8 +1299,8 @@ inittapes(Tuplesortstate *state)
 
    /*
     * We must have at least 2*maxTapes slots in the memtuples[] array, else
-    * we'd not have room for merge heap plus preread.  It seems unlikely
-    * that this case would ever occur, but be safe.
+    * we'd not have room for merge heap plus preread.  It seems unlikely that
+    * this case would ever occur, but be safe.
     */
    maxTapes = Min(maxTapes, state->memtupsize / 2);
 
@@ -1314,12 +1315,12 @@ inittapes(Tuplesortstate *state)
 
    /*
     * Decrease availMem to reflect the space needed for tape buffers; but
-    * don't decrease it to the point that we have no room for tuples.
-    * (That case is only likely to occur if sorting pass-by-value Datums;
-    * in all other scenarios the memtuples[] array is unlikely to occupy
-    * more than half of allowedMem.  In the pass-by-value case it's not
-    * important to account for tuple space, so we don't care if LACKMEM
-    * becomes inaccurate.)
+    * don't decrease it to the point that we have no room for tuples. (That
+    * case is only likely to occur if sorting pass-by-value Datums; in all
+    * other scenarios the memtuples[] array is unlikely to occupy more than
+    * half of allowedMem.  In the pass-by-value case it's not important to
+    * account for tuple space, so we don't care if LACKMEM becomes
+    * inaccurate.)
     */
    tapeSpace = maxTapes * TAPE_BUFFER_OVERHEAD;
    if (tapeSpace + GetMemoryChunkSpace(state->memtuples) < state->allowedMem)
@@ -1435,7 +1436,7 @@ 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.  (This obvious
+    * finished output, rather than doing a useless merge.  (This obvious
     * optimization is not in Knuth's algorithm.)
     */
    if (state->currentRun == 1)
@@ -1666,7 +1667,7 @@ beginmerge(Tuplesortstate *state)
    memset(state->mergelast, 0,
           state->maxTapes * sizeof(*state->mergelast));
    state->mergefreelist = 0;   /* nothing in the freelist */
-   state->mergefirstfree = activeTapes;  /* 1st slot avail for preread */
+   state->mergefirstfree = activeTapes;        /* 1st slot avail for preread */
 
    /*
     * Initialize space allocation to let each active input tape have an equal
@@ -1966,7 +1967,7 @@ tuplesort_restorepos(Tuplesortstate *state)
 /*
  * Heap manipulation routines, per Knuth's Algorithm 5.2.3H.
  *
- * Compare two SortTuples.  If checkIndex is true, use the tuple index
+ * Compare two SortTuples. If checkIndex is true, use the tuple index
  * as the front of the sort key; otherwise, no.
  */
 
@@ -1977,7 +1978,7 @@ tuplesort_restorepos(Tuplesortstate *state)
 
 /*
  * Insert a new tuple into an empty or existing heap, maintaining the
- * heap invariant.  Caller is responsible for ensuring there's room.
+ * heap invariant. Caller is responsible for ensuring there's room.
  *
  * Note: we assume *tuple is a temporary variable that can be scribbled on.
  * For some callers, tuple actually points to a memtuples[] entry above the
@@ -1993,10 +1994,10 @@ tuplesort_heap_insert(Tuplesortstate *state, SortTuple *tuple,
    int         j;
 
    /*
-    * Save the tupleindex --- see notes above about writing on *tuple.
-    * It's a historical artifact that tupleindex is passed as a separate
-    * argument and not in *tuple, but it's notationally convenient so
-    * let's leave it that way.
+    * Save the tupleindex --- see notes above about writing on *tuple. It's a
+    * historical artifact that tupleindex is passed as a separate argument
+    * and not in *tuple, but it's notationally convenient so let's leave it
+    * that way.
     */
    tuple->tupindex = tupleindex;
 
@@ -2432,8 +2433,8 @@ comparetup_index(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
 {
    /*
     * This is similar to _bt_tuplecompare(), but we have already done the
-    * index_getattr calls for the first column, and we need to keep track
-    * of whether any null fields are present.  Also see the special treatment
+    * index_getattr calls for the first column, and we need to keep track of
+    * whether any null fields are present.  Also see the special treatment
     * for equal keys at the end.
     */
    ScanKey     scanKey = state->indexScanKey;
@@ -2686,7 +2687,7 @@ readtup_datum(Tuplesortstate *state, SortTuple *stup,
    }
    else
    {
-       void   *raddr = palloc(tuplen);
+       void       *raddr = palloc(tuplen);
 
        if (LogicalTapeRead(state->tapeset, tapenum, raddr,
                            tuplen) != tuplen)
index a2ed330ccc6a3bea79da46b6cf7e579ec2ac60e6..dcf68de335dc15ccc98f3d91d967c3c97a40bc34 100644 (file)
@@ -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.28 2006/06/27 02:51:39 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.29 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -347,6 +347,7 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple)
    switch (state->status)
    {
        case TSS_INMEM:
+
            /*
             * Grow the array as needed.  Note that we try to grow the array
             * when there is still one free slot remaining --- if we fail,
index a3b52fa7eb436986aa25a5314590a4533a03c2ff..eedc6222be841a8d26f90e8a9fceb415c0c46f26 100644 (file)
@@ -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.97 2006/09/15 16:39:32 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.98 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1326,7 +1326,7 @@ XidInSnapshot(TransactionId xid, Snapshot snapshot)
 
    /*
     * Make a quick range check to eliminate most XIDs without looking at the
-    * xip arrays.  Note that this is OK even if we convert a subxact XID to
+    * xip arrays.  Note that this is OK even if we convert a subxact XID to
     * its parent below, 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.
@@ -1342,7 +1342,7 @@ XidInSnapshot(TransactionId xid, Snapshot snapshot)
    /*
     * If the snapshot contains full subxact data, the fastest way to check
     * things is just to compare the given XID against both subxact XIDs and
-    * top-level XIDs.  If the snapshot overflowed, we have to use pg_subtrans
+    * top-level XIDs.  If the snapshot overflowed, we have to use pg_subtrans
     * to convert a subxact XID to its parent XID, but then we need only look
     * at top-level XIDs not subxacts.
     */
@@ -1365,8 +1365,8 @@ XidInSnapshot(TransactionId xid, Snapshot snapshot)
        xid = SubTransGetTopmostTransaction(xid);
 
        /*
-        * If xid was indeed a subxact, we might now have an xid < xmin,
-        * so recheck to avoid an array scan.  No point in rechecking xmax.
+        * If xid was indeed a subxact, we might now have an xid < xmin, so
+        * recheck to avoid an array scan.  No point in rechecking xmax.
         */
        if (TransactionIdPrecedes(xid, snapshot->xmin))
            return false;
index 70f481c372e200a03b141ace16ca40a6d8646c78..f001d43b2570a99d5239a4c903b42825530620b0 100644 (file)
@@ -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.123 2006/10/03 21:11:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.124 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -120,7 +120,7 @@ static int  output_errno = 0;
 /* defaults */
 static int n_connections = 10;
 static int n_buffers = 50;
-static int  n_fsm_pages = 20000; 
+static int n_fsm_pages = 20000;
 
 /*
  * Warning messages for authentication methods
@@ -191,8 +191,9 @@ static int  locale_date_order(const char *locale);
 static bool chklocale(const char *locale);
 static void setlocales(void);
 static void usage(const char *progname);
+
 #ifdef WIN32
-static int CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo);
+static int CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION * processInfo);
 #endif
 
 
@@ -1102,21 +1103,21 @@ test_config_settings(void)
 {
    /*
     * These macros define the minimum shared_buffers we want for a given
-    * max_connections value, and the max_fsm_pages setting to be used for
-    * given shared_buffers value.  The arrays show the settings to try.
+    * max_connections value, and the max_fsm_pages setting to be used for a
+    * given shared_buffers value.  The arrays show the settings to try.
     *
     */
 
-#define MIN_BUFS_FOR_CONNS(nconns)  ((nconns) * 10 * (BLCKSZ/1024))
-#define FSM_FOR_BUFS(nbuffers)  ((nbuffers) > 1000 ? 50 * (nbuffers) : 20000)
+#define MIN_BUFS_FOR_CONNS(nconns) ((nconns) * 10 * (BLCKSZ/1024))
+#define FSM_FOR_BUFS(nbuffers) ((nbuffers) > 1000 ? 50 * (nbuffers) : 20000)
 
    static const int trial_conns[] = {
        100, 50, 40, 30, 20, 10
    };
 
    /*
-    * Candidate values for shared_buffers in kB. When the value is
-    * divisible by 1024, we write it in MB-unit to configuration files.
+    * Candidate values for shared_buffers in kB. When the value is divisible
+    * by 1024, we write it in MB-unit to configuration files.
     */
    static const int trial_bufs[] = {
        32768, 28672, 24576, 20480, 16384, 12288,
@@ -1124,15 +1125,15 @@ test_config_settings(void)
    };
 
    char        cmd[MAXPGPATH];
-   const int connslen = sizeof(trial_conns) / sizeof(int);
-   const int bufslen = sizeof(trial_bufs) / sizeof(int);
+   const int   connslen = sizeof(trial_conns) / sizeof(int);
+   const int   bufslen = sizeof(trial_bufs) / sizeof(int);
    int         i,
                status,
                test_conns,
                test_buffs,
-               test_max_fsm,
-               ok_buffers = 0;
-     
+               test_max_fsm,
+               ok_buffers = 0;
+
 
    printf(_("selecting default max_connections ... "));
    fflush(stdout);
@@ -1195,7 +1196,7 @@ test_config_settings(void)
    n_fsm_pages = FSM_FOR_BUFS(n_buffers);
 
    if (n_buffers % 1024 == 0)
-       printf("%dMB/%d\n", n_buffers/1024, n_fsm_pages);
+       printf("%dMB/%d\n", n_buffers / 1024, n_fsm_pages);
    else
        printf("%dkB/%d\n", n_buffers, n_fsm_pages);
 }
@@ -1221,7 +1222,7 @@ setup_config(void)
    conflines = replace_token(conflines, "#max_connections = 100", repltok);
 
    if (n_buffers % 1024 == 0)
-       snprintf(repltok, sizeof(repltok), "shared_buffers = %dMB", n_buffers/1024);
+       snprintf(repltok, sizeof(repltok), "shared_buffers = %dMB", n_buffers / 1024);
    else
        snprintf(repltok, sizeof(repltok), "shared_buffers = %dkB", n_buffers);
    conflines = replace_token(conflines, "#shared_buffers = 32MB", repltok);
@@ -1250,7 +1251,8 @@ setup_config(void)
             escape_quotes(lc_time));
    conflines = replace_token(conflines, "#lc_time = 'C'", repltok);
 
-   switch (locale_date_order(lc_time)) {
+   switch (locale_date_order(lc_time))
+   {
        case DATEORDER_YMD:
            strcpy(repltok, "datestyle = 'iso, ymd'");
            break;
@@ -2083,7 +2085,7 @@ check_ok(void)
  *
  * Note: this is used to process both postgresql.conf entries and SQL
  * string literals.  Since postgresql.conf strings are defined to treat
- * backslashes as escapes, we have to double backslashes here.  Hence,
+ * backslashes as escapes, we have to double backslashes here. Hence,
  * when using this for a SQL string literal, use E'' syntax.
  *
  * We do not need to worry about encoding considerations because all
@@ -2245,8 +2247,9 @@ setlocales(void)
 }
 
 #ifdef WIN32
-typedef BOOL (WINAPI *__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
-#define DISABLE_MAX_PRIVILEGE   0x1 
+typedef        BOOL(WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
+
+#define DISABLE_MAX_PRIVILEGE  0x1
 
 /*
  * Create a restricted token and execute the specified process with it.
@@ -2256,75 +2259,75 @@ typedef BOOL (WINAPI *__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_AT
  * On NT4, or any other system not containing the required functions, will
  * NOT execute anything.
  */
-static int 
-CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo)
+static int
+CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION * processInfo)
 {
-    BOOL b;
-    STARTUPINFO si;
-    HANDLE origToken;
-    HANDLE restrictedToken;
-    SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
-    SID_AND_ATTRIBUTES dropSids[2];
-    __CreateRestrictedToken _CreateRestrictedToken = NULL;
-    HANDLE Advapi32Handle;
-    
-    ZeroMemory(&si, sizeof(si));
-    si.cb = sizeof(si);
-
-    Advapi32Handle = LoadLibrary("ADVAPI32.DLL");
-    if (Advapi32Handle != NULL)
-    {
-        _CreateRestrictedToken = (__CreateRestrictedToken) GetProcAddress(Advapi32Handle, "CreateRestrictedToken");
-    }
-
-    if (_CreateRestrictedToken == NULL)
-    {
-        fprintf(stderr,"WARNING: Unable to create restricted tokens on this platform\n");
-        if (Advapi32Handle != NULL)
-            FreeLibrary(Advapi32Handle);
-        return 0;
-    }
-
-    /* Open the current token to use as a base for the restricted one */
-    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
-    {
-        fprintf(stderr, "Failed to open process token: %lu\n", GetLastError());
-        return 0;
-    }
-
-    /* Allocate list of SIDs to remove */
-    ZeroMemory(&dropSids, sizeof(dropSids));
-    if (!AllocateAndInitializeSid(&NtAuthority, 2,
-            SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0,0,0,0,0,
-            0, &dropSids[0].Sid) ||
-        !AllocateAndInitializeSid(&NtAuthority, 2, 
-            SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0,0,0,0,0,
-            0, &dropSids[1].Sid))
-    {
-        fprintf(stderr,"Failed to allocate SIDs: %lu\n", GetLastError());
-        return 0;
-    }
-
-    b = _CreateRestrictedToken(origToken,
-            DISABLE_MAX_PRIVILEGE,
-            sizeof(dropSids)/sizeof(dropSids[0]),
-            dropSids,
-            0, NULL,
-            0, NULL,
-            &restrictedToken);
-    
-    FreeSid(dropSids[1].Sid);
-    FreeSid(dropSids[0].Sid);
-    CloseHandle(origToken);
-    FreeLibrary(Advapi32Handle);
-
-    if (!b)
-    {
-        fprintf(stderr,"Failed to create restricted token: %lu\n", GetLastError());
-        return 0;
-    }
-
-    return CreateProcessAsUser(restrictedToken, NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, processInfo);
+   BOOL        b;
+   STARTUPINFO si;
+   HANDLE      origToken;
+   HANDLE      restrictedToken;
+   SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
+   SID_AND_ATTRIBUTES dropSids[2];
+   __CreateRestrictedToken _CreateRestrictedToken = NULL;
+   HANDLE      Advapi32Handle;
+
+   ZeroMemory(&si, sizeof(si));
+   si.cb = sizeof(si);
+
+   Advapi32Handle = LoadLibrary("ADVAPI32.DLL");
+   if (Advapi32Handle != NULL)
+   {
+       _CreateRestrictedToken = (__CreateRestrictedToken) GetProcAddress(Advapi32Handle, "CreateRestrictedToken");
+   }
+
+   if (_CreateRestrictedToken == NULL)
+   {
+       fprintf(stderr, "WARNING: Unable to create restricted tokens on this platform\n");
+       if (Advapi32Handle != NULL)
+           FreeLibrary(Advapi32Handle);
+       return 0;
+   }
+
+   /* Open the current token to use as a base for the restricted one */
+   if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
+   {
+       fprintf(stderr, "Failed to open process token: %lu\n", GetLastError());
+       return 0;
+   }
+
+   /* Allocate list of SIDs to remove */
+   ZeroMemory(&dropSids, sizeof(dropSids));
+   if (!AllocateAndInitializeSid(&NtAuthority, 2,
+        SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0,
+                                 0, &dropSids[0].Sid) ||
+       !AllocateAndInitializeSid(&NtAuthority, 2,
+   SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
+                                 0, &dropSids[1].Sid))
+   {
+       fprintf(stderr, "Failed to allocate SIDs: %lu\n", GetLastError());
+       return 0;
+   }
+
+   b = _CreateRestrictedToken(origToken,
+                              DISABLE_MAX_PRIVILEGE,
+                              sizeof(dropSids) / sizeof(dropSids[0]),
+                              dropSids,
+                              0, NULL,
+                              0, NULL,
+                              &restrictedToken);
+
+   FreeSid(dropSids[1].Sid);
+   FreeSid(dropSids[0].Sid);
+   CloseHandle(origToken);
+   FreeLibrary(Advapi32Handle);
+
+   if (!b)
+   {
+       fprintf(stderr, "Failed to create restricted token: %lu\n", GetLastError());
+       return 0;
+   }
+
+   return CreateProcessAsUser(restrictedToken, NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, processInfo);
 }
 #endif
 
@@ -2382,7 +2385,7 @@ main(int argc, char *argv[])
        {"lc-messages", required_argument, NULL, 7},
        {"no-locale", no_argument, NULL, 8},
        {"auth", required_argument, NULL, 'A'},
-       {"pwprompt", no_argument, NULL, 'W'},  
+       {"pwprompt", no_argument, NULL, 'W'},
        {"pwfile", required_argument, NULL, 9},
        {"username", required_argument, NULL, 'U'},
        {"help", no_argument, NULL, '?'},
@@ -2398,13 +2401,14 @@ main(int argc, char *argv[])
                ret;
    int         option_index;
    char       *short_version;
-    char       *effective_user;
+   char       *effective_user;
    char       *pgdenv;         /* PGDATA value gotten from and sent to
                                 * environment */
    char        bin_dir[MAXPGPATH];
    char       *pg_data_native;
+
 #ifdef WIN32
-   char       *restrict_env;
+   char       *restrict_env;
 #endif
    static const char *subdirs[] = {
        "global",
@@ -2592,43 +2596,47 @@ main(int argc, char *argv[])
    canonicalize_path(pg_data);
 
 #ifdef WIN32
-    /* 
-     * Before we execute another program, make sure that we are running with a 
-     * restricted token. If not, re-execute ourselves with one.
-     */
 
-   if ((restrict_env = getenv("PG_RESTRICT_EXEC")) == NULL 
-       || strcmp(restrict_env,"1") != 0)
-    {
-        PROCESS_INFORMATION pi;
-        char *cmdline;
-        
-        ZeroMemory(&pi, sizeof(pi));
+   /*
+    * Before we execute another program, make sure that we are running with a
+    * restricted token. If not, re-execute ourselves with one.
+    */
 
-        cmdline = xstrdup(GetCommandLine());
+   if ((restrict_env = getenv("PG_RESTRICT_EXEC")) == NULL
+       || strcmp(restrict_env, "1") != 0)
+   {
+       PROCESS_INFORMATION pi;
+       char       *cmdline;
+
+       ZeroMemory(&pi, sizeof(pi));
+
+       cmdline = xstrdup(GetCommandLine());
 
        putenv("PG_RESTRICT_EXEC=1");
-        
-        if (!CreateRestrictedProcess(cmdline, &pi))
-        {
-            fprintf(stderr,"Failed to re-exec with restricted token: %lu.\n", GetLastError());
-        }
-        else
-        {
-            /* Successfully re-execed. Now wait for child process to capture exitcode. */
-            DWORD x;
-            
-            CloseHandle(pi.hThread);
-            WaitForSingleObject(pi.hProcess, INFINITE);
-
-            if (!GetExitCodeProcess(pi.hProcess, &x))
-            {
-                fprintf(stderr,"Failed to get exit code from subprocess: %lu\n", GetLastError());
-                exit(1);
-            }
-            exit(x);
-        }
-    }
+
+       if (!CreateRestrictedProcess(cmdline, &pi))
+       {
+           fprintf(stderr, "Failed to re-exec with restricted token: %lu.\n", GetLastError());
+       }
+       else
+       {
+           /*
+            * Successfully re-execed. Now wait for child process to capture
+            * exitcode.
+            */
+           DWORD       x;
+
+           CloseHandle(pi.hThread);
+           WaitForSingleObject(pi.hProcess, INFINITE);
+
+           if (!GetExitCodeProcess(pi.hProcess, &x))
+           {
+               fprintf(stderr, "Failed to get exit code from subprocess: %lu\n", GetLastError());
+               exit(1);
+           }
+           exit(x);
+       }
+   }
 #endif
 
    /*
index edd4a6af368ac4d743fd00dd9abc82dccc6d5e52..788ffed786a94682bb17faa99eaab87c63edd679 100644 (file)
@@ -17,7 +17,7 @@
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.21 2006/09/27 16:19:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.22 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -43,10 +43,10 @@ cleanup_path(char *path)
    char       *ptr;
 
    /*
-    *  GetShortPathName() will fail if the path does not exist, or short names
-    *  are disabled on this file system.  In both cases, we just return the
-    *  original path.  This is particularly useful for --sysconfdir, which
-    *  might not exist.
+    * GetShortPathName() will fail if the path does not exist, or short names
+    * are disabled on this file system.  In both cases, we just return the
+    * original path.  This is particularly useful for --sysconfdir, which
+    * might not exist.
     */
    GetShortPathName(path, path, MAXPGPATH - 1);
 
index c94fe04a54f7c531dce4a3e2fd648f2d900ce6fa..728538b971e30a7a54cbfa48784a2d9c959e0aa9 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.72 2006/09/24 16:59:45 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.73 2006/10/04 00:30:04 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -119,7 +119,7 @@ static void pgwin32_SetServiceStatus(DWORD);
 static void WINAPI pgwin32_ServiceHandler(DWORD);
 static void WINAPI pgwin32_ServiceMain(DWORD, LPTSTR *);
 static void pgwin32_doRunAsService(void);
-static int CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo);
+static int CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION * processInfo);
 #endif
 static pgpid_t get_pgpid(void);
 static char **readfile(const char *path);
@@ -336,7 +336,9 @@ static int
 start_postmaster(void)
 {
    char        cmd[MAXPGPATH];
+
 #ifndef WIN32
+
    /*
     * Since there might be quotes to handle here, it is easier simply to pass
     * everything to a shell to process them.
@@ -345,36 +347,36 @@ start_postmaster(void)
        snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
                 SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
                 DEVNULL, log_file, SYSTEMQUOTE);
-    else
+   else
        snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
                 SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
                 DEVNULL, SYSTEMQUOTE);
 
    return system(cmd);
-    
-#else /* WIN32 */
-    /*
-     * On win32 we don't use system(). So we don't need to use &
-     * (which would be START /B on win32). However, we still call the shell
-     * (CMD.EXE) with it to handle redirection etc. 
-     */
-    PROCESS_INFORMATION pi;
-
-    if (log_file != NULL)
-        snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
+#else                          /* WIN32 */
+
+   /*
+    * On win32 we don't use system(). So we don't need to use & (which would
+    * be START /B on win32). However, we still call the shell (CMD.EXE) with
+    * it to handle redirection etc.
+    */
+   PROCESS_INFORMATION pi;
+
+   if (log_file != NULL)
+       snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
                 SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
                 DEVNULL, log_file, SYSTEMQUOTE);
-    else
-        snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" 2>&1%s",
+   else
+       snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" 2>&1%s",
                 SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
                 DEVNULL, SYSTEMQUOTE);
 
-    if (!CreateRestrictedProcess(cmd, &pi))
-        return GetLastError();
-    CloseHandle(pi.hProcess);
-    CloseHandle(pi.hThread);
-    return 0;
-#endif /* WIN32 */
+   if (!CreateRestrictedProcess(cmd, &pi))
+       return GetLastError();
+   CloseHandle(pi.hProcess);
+   CloseHandle(pi.hThread);
+   return 0;
+#endif   /* WIN32 */
 }
 
 
@@ -1162,15 +1164,15 @@ pgwin32_doRunAsService(void)
  * also load the couple of functions that *do* exist in minwg headers but not
  * on NT4. That way, we don't break on NT4.
  */
-typedef BOOL (WINAPI *__CreateRestrictedToken)(HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
-typedef BOOL (WINAPI *__IsProcessInJob)(HANDLE, HANDLE, PBOOL);
-typedef HANDLE (WINAPI *__CreateJobObject)(LPSECURITY_ATTRIBUTES, LPCTSTR);
-typedef BOOL (WINAPI *__SetInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
-typedef BOOL (WINAPI *__AssignProcessToJobObject)(HANDLE, HANDLE);
-typedef BOOL (WINAPI *__QueryInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
+typedef        BOOL(WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
+typedef        BOOL(WINAPI * __IsProcessInJob) (HANDLE, HANDLE, PBOOL);
+typedef        HANDLE(WINAPI * __CreateJobObject) (LPSECURITY_ATTRIBUTES, LPCTSTR);
+typedef        BOOL(WINAPI * __SetInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD);
+typedef        BOOL(WINAPI * __AssignProcessToJobObject) (HANDLE, HANDLE);
+typedef        BOOL(WINAPI * __QueryInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
 
 /* Windows API define missing from MingW headers */
-#define DISABLE_MAX_PRIVILEGE   0x1 
+#define DISABLE_MAX_PRIVILEGE  0x1
 
 /*
  * Create a restricted token, a job object sandbox, and execute the specified
@@ -1185,165 +1187,178 @@ typedef BOOL (WINAPI *__QueryInformationJobObject)(HANDLE, JOBOBJECTINFOCLASS, L
  * automatically destroyed when pg_ctl exits.
  */
 static int
-CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo)
+CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION * processInfo)
 {
-    int r;
-    BOOL b;
-    STARTUPINFO si;
-    HANDLE origToken;
-    HANDLE restrictedToken;
-    SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
-    SID_AND_ATTRIBUTES dropSids[2];
-
-    /* Functions loaded dynamically */
-    __CreateRestrictedToken _CreateRestrictedToken = NULL;
-    __IsProcessInJob _IsProcessInJob = NULL;
-    __CreateJobObject _CreateJobObject = NULL;
-    __SetInformationJobObject _SetInformationJobObject = NULL;
-    __AssignProcessToJobObject _AssignProcessToJobObject = NULL;
-    __QueryInformationJobObject _QueryInformationJobObject = NULL;
-    HANDLE Kernel32Handle;
-    HANDLE Advapi32Handle;
-    
-    ZeroMemory(&si, sizeof(si));
-    si.cb = sizeof(si);
-
-    Advapi32Handle = LoadLibrary("ADVAPI32.DLL");
-    if (Advapi32Handle != NULL)
-    {
-        _CreateRestrictedToken = (__CreateRestrictedToken) GetProcAddress(Advapi32Handle, "CreateRestrictedToken");
-    }
-
-    if (_CreateRestrictedToken == NULL)
-    {
-        /* NT4 doesn't have CreateRestrictedToken, so just call ordinary CreateProcess */
-        write_stderr("WARNING: Unable to create restricted tokens on this platform\n");
-        if (Advapi32Handle != NULL)
-            FreeLibrary(Advapi32Handle);
-        return CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, processInfo);
-    }
-
-    /* Open the current token to use as a base for the restricted one */
-    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
-    {
-        write_stderr("Failed to open process token: %lu\n", GetLastError());
-        return 0;
-    }
-
-    /* Allocate list of SIDs to remove */
-    ZeroMemory(&dropSids, sizeof(dropSids));
-    if (!AllocateAndInitializeSid(&NtAuthority, 2,
-            SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0,0,0,0,0,
-            0, &dropSids[0].Sid) ||
-        !AllocateAndInitializeSid(&NtAuthority, 2, 
-            SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0,0,0,0,0,
-            0, &dropSids[1].Sid))
-    {
-        write_stderr("Failed to allocate SIDs: %lu\n", GetLastError());
-        return 0;
-    }
-
-    b = _CreateRestrictedToken(origToken,
-            DISABLE_MAX_PRIVILEGE,
-            sizeof(dropSids)/sizeof(dropSids[0]),
-            dropSids,
-            0, NULL,
-            0, NULL,
-            &restrictedToken);
-    
-    FreeSid(dropSids[1].Sid);
-    FreeSid(dropSids[0].Sid);
-    CloseHandle(origToken);
-    FreeLibrary(Advapi32Handle);
-
-    if (!b)
-    {
-        write_stderr("Failed to create restricted token: %lu\n", GetLastError());
-        return 0;
-    }
-
-    r = CreateProcessAsUser(restrictedToken, NULL, cmd, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, NULL, &si, processInfo);
-    
-    Kernel32Handle = LoadLibrary("KERNEL32.DLL");
-    if (Kernel32Handle != NULL)
-    {
-        _IsProcessInJob = (__IsProcessInJob) GetProcAddress(Kernel32Handle, "IsProcessInJob");
-        _CreateJobObject = (__CreateJobObject) GetProcAddress(Kernel32Handle, "CreateJobObjectA");
-        _SetInformationJobObject = (__SetInformationJobObject) GetProcAddress(Kernel32Handle, "SetInformationJobObject");
-        _AssignProcessToJobObject = (__AssignProcessToJobObject) GetProcAddress(Kernel32Handle, "AssignProcessToJobObject");
-        _QueryInformationJobObject = (__QueryInformationJobObject) GetProcAddress(Kernel32Handle, "QueryInformationJobObject");
-    }
-
-    /* Verify that we found all functions */
-    if (_IsProcessInJob == NULL || _CreateJobObject == NULL || _SetInformationJobObject == NULL || _AssignProcessToJobObject == NULL || _QueryInformationJobObject == NULL)
-    {
-       /* IsProcessInJob() is not available on < WinXP, so there is no need to log the error every time in that case */
+   int         r;
+   BOOL        b;
+   STARTUPINFO si;
+   HANDLE      origToken;
+   HANDLE      restrictedToken;
+   SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
+   SID_AND_ATTRIBUTES dropSids[2];
+
+   /* Functions loaded dynamically */
+   __CreateRestrictedToken _CreateRestrictedToken = NULL;
+   __IsProcessInJob _IsProcessInJob = NULL;
+   __CreateJobObject _CreateJobObject = NULL;
+   __SetInformationJobObject _SetInformationJobObject = NULL;
+   __AssignProcessToJobObject _AssignProcessToJobObject = NULL;
+   __QueryInformationJobObject _QueryInformationJobObject = NULL;
+   HANDLE      Kernel32Handle;
+   HANDLE      Advapi32Handle;
+
+   ZeroMemory(&si, sizeof(si));
+   si.cb = sizeof(si);
+
+   Advapi32Handle = LoadLibrary("ADVAPI32.DLL");
+   if (Advapi32Handle != NULL)
+   {
+       _CreateRestrictedToken = (__CreateRestrictedToken) GetProcAddress(Advapi32Handle, "CreateRestrictedToken");
+   }
+
+   if (_CreateRestrictedToken == NULL)
+   {
+       /*
+        * NT4 doesn't have CreateRestrictedToken, so just call ordinary
+        * CreateProcess
+        */
+       write_stderr("WARNING: Unable to create restricted tokens on this platform\n");
+       if (Advapi32Handle != NULL)
+           FreeLibrary(Advapi32Handle);
+       return CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, processInfo);
+   }
+
+   /* Open the current token to use as a base for the restricted one */
+   if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
+   {
+       write_stderr("Failed to open process token: %lu\n", GetLastError());
+       return 0;
+   }
+
+   /* Allocate list of SIDs to remove */
+   ZeroMemory(&dropSids, sizeof(dropSids));
+   if (!AllocateAndInitializeSid(&NtAuthority, 2,
+        SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0,
+                                 0, &dropSids[0].Sid) ||
+       !AllocateAndInitializeSid(&NtAuthority, 2,
+   SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
+                                 0, &dropSids[1].Sid))
+   {
+       write_stderr("Failed to allocate SIDs: %lu\n", GetLastError());
+       return 0;
+   }
+
+   b = _CreateRestrictedToken(origToken,
+                              DISABLE_MAX_PRIVILEGE,
+                              sizeof(dropSids) / sizeof(dropSids[0]),
+                              dropSids,
+                              0, NULL,
+                              0, NULL,
+                              &restrictedToken);
+
+   FreeSid(dropSids[1].Sid);
+   FreeSid(dropSids[0].Sid);
+   CloseHandle(origToken);
+   FreeLibrary(Advapi32Handle);
+
+   if (!b)
+   {
+       write_stderr("Failed to create restricted token: %lu\n", GetLastError());
+       return 0;
+   }
+
+   r = CreateProcessAsUser(restrictedToken, NULL, cmd, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, NULL, &si, processInfo);
+
+   Kernel32Handle = LoadLibrary("KERNEL32.DLL");
+   if (Kernel32Handle != NULL)
+   {
+       _IsProcessInJob = (__IsProcessInJob) GetProcAddress(Kernel32Handle, "IsProcessInJob");
+       _CreateJobObject = (__CreateJobObject) GetProcAddress(Kernel32Handle, "CreateJobObjectA");
+       _SetInformationJobObject = (__SetInformationJobObject) GetProcAddress(Kernel32Handle, "SetInformationJobObject");
+       _AssignProcessToJobObject = (__AssignProcessToJobObject) GetProcAddress(Kernel32Handle, "AssignProcessToJobObject");
+       _QueryInformationJobObject = (__QueryInformationJobObject) GetProcAddress(Kernel32Handle, "QueryInformationJobObject");
+   }
+
+   /* Verify that we found all functions */
+   if (_IsProcessInJob == NULL || _CreateJobObject == NULL || _SetInformationJobObject == NULL || _AssignProcessToJobObject == NULL || _QueryInformationJobObject == NULL)
+   {
+       /*
+        * IsProcessInJob() is not available on < WinXP, so there is no need
+        * to log the error every time in that case
+        */
        OSVERSIONINFO osv;
 
        osv.dwOSVersionInfoSize = sizeof(osv);
-       if (!GetVersionEx(&osv) || /* could not get version */
-           (osv.dwMajorVersion == 5 && osv.dwMinorVersion > 0) || /* 5.1=xp, 5.2=2003, etc */
-           osv.dwMajorVersion > 5) /* anything newer should have the API */
-           /* Log error if we can't get version, or if we're on WinXP/2003 or newer */
+       if (!GetVersionEx(&osv) ||      /* could not get version */
+           (osv.dwMajorVersion == 5 && osv.dwMinorVersion > 0) ||      /* 5.1=xp, 5.2=2003, etc */
+           osv.dwMajorVersion > 5)     /* anything newer should have the API */
+
+           /*
+            * Log error if we can't get version, or if we're on WinXP/2003 or
+            * newer
+            */
            write_stderr("WARNING: Unable to locate all job object functions in system API!\n");
-    } 
-    else
-    { 
-        BOOL inJob;
-        if (_IsProcessInJob(processInfo->hProcess, NULL, &inJob))
-        {
-            if (!inJob)
-            {
-                /* Job objects are working, and the new process isn't in one, so we can create one safely.
-                   If any problems show up when setting it, we're going to ignore them. */
-                HANDLE job;
-                char jobname[128];
-
-                sprintf(jobname,"PostgreSQL_%lu", processInfo->dwProcessId);
-
-                job = _CreateJobObject(NULL, jobname);
-                if (job)
-                {
-                    JOBOBJECT_BASIC_LIMIT_INFORMATION basicLimit;
-                    JOBOBJECT_BASIC_UI_RESTRICTIONS uiRestrictions;
-                    JOBOBJECT_SECURITY_LIMIT_INFORMATION securityLimit;
-
-                    ZeroMemory(&basicLimit, sizeof(basicLimit));
-                    ZeroMemory(&uiRestrictions, sizeof(uiRestrictions));
-                    ZeroMemory(&securityLimit, sizeof(securityLimit));
-
-                    basicLimit.LimitFlags = JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION | JOB_OBJECT_LIMIT_PRIORITY_CLASS;
-                    basicLimit.PriorityClass = NORMAL_PRIORITY_CLASS;
-                    _SetInformationJobObject(job, JobObjectBasicLimitInformation, &basicLimit, sizeof(basicLimit));
-
-                    uiRestrictions.UIRestrictionsClass = JOB_OBJECT_UILIMIT_DESKTOP | JOB_OBJECT_UILIMIT_DISPLAYSETTINGS |
-                        JOB_OBJECT_UILIMIT_EXITWINDOWS | JOB_OBJECT_UILIMIT_HANDLES | JOB_OBJECT_UILIMIT_READCLIPBOARD |
-                        JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS | JOB_OBJECT_UILIMIT_WRITECLIPBOARD;
-                    _SetInformationJobObject(job, JobObjectBasicUIRestrictions, &uiRestrictions, sizeof(uiRestrictions));
-
-                    securityLimit.SecurityLimitFlags = JOB_OBJECT_SECURITY_NO_ADMIN | JOB_OBJECT_SECURITY_ONLY_TOKEN;
-                    securityLimit.JobToken = restrictedToken;
-                    _SetInformationJobObject(job, JobObjectSecurityLimitInformation, &securityLimit, sizeof(securityLimit));
-
-                    _AssignProcessToJobObject(job, processInfo->hProcess);
-                }
-            }
-        }
-    }
-    
-    CloseHandle(restrictedToken);
-
-    ResumeThread(processInfo->hThread);
-
-    FreeLibrary(Kernel32Handle);
-
-    /*
+   }
+   else
+   {
+       BOOL        inJob;
+
+       if (_IsProcessInJob(processInfo->hProcess, NULL, &inJob))
+       {
+           if (!inJob)
+           {
+               /*
+                * Job objects are working, and the new process isn't in one,
+                * so we can create one safely. If any problems show up when
+                * setting it, we're going to ignore them.
+                */
+               HANDLE      job;
+               char        jobname[128];
+
+               sprintf(jobname, "PostgreSQL_%lu", processInfo->dwProcessId);
+
+               job = _CreateJobObject(NULL, jobname);
+               if (job)
+               {
+                   JOBOBJECT_BASIC_LIMIT_INFORMATION basicLimit;
+                   JOBOBJECT_BASIC_UI_RESTRICTIONS uiRestrictions;
+                   JOBOBJECT_SECURITY_LIMIT_INFORMATION securityLimit;
+
+                   ZeroMemory(&basicLimit, sizeof(basicLimit));
+                   ZeroMemory(&uiRestrictions, sizeof(uiRestrictions));
+                   ZeroMemory(&securityLimit, sizeof(securityLimit));
+
+                   basicLimit.LimitFlags = JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION | JOB_OBJECT_LIMIT_PRIORITY_CLASS;
+                   basicLimit.PriorityClass = NORMAL_PRIORITY_CLASS;
+                   _SetInformationJobObject(job, JobObjectBasicLimitInformation, &basicLimit, sizeof(basicLimit));
+
+                   uiRestrictions.UIRestrictionsClass = JOB_OBJECT_UILIMIT_DESKTOP | JOB_OBJECT_UILIMIT_DISPLAYSETTINGS |
+                       JOB_OBJECT_UILIMIT_EXITWINDOWS | JOB_OBJECT_UILIMIT_HANDLES | JOB_OBJECT_UILIMIT_READCLIPBOARD |
+                       JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS | JOB_OBJECT_UILIMIT_WRITECLIPBOARD;
+                   _SetInformationJobObject(job, JobObjectBasicUIRestrictions, &uiRestrictions, sizeof(uiRestrictions));
+
+                   securityLimit.SecurityLimitFlags = JOB_OBJECT_SECURITY_NO_ADMIN | JOB_OBJECT_SECURITY_ONLY_TOKEN;
+                   securityLimit.JobToken = restrictedToken;
+                   _SetInformationJobObject(job, JobObjectSecurityLimitInformation, &securityLimit, sizeof(securityLimit));
+
+                   _AssignProcessToJobObject(job, processInfo->hProcess);
+               }
+           }
+       }
+   }
+
+   CloseHandle(restrictedToken);
+
+   ResumeThread(processInfo->hThread);
+
+   FreeLibrary(Kernel32Handle);
+
+   /*
     * We intentionally don't close the job object handle, because we want the
     * object to live on until pg_ctl shuts down.
     */
-    return r;
+   return r;
 }
-
 #endif
 
 static void
@@ -1722,13 +1737,13 @@ main(int argc, char **argv)
        do_wait = false;
    }
 
-    if (pg_data)
-    {
-        snprintf(def_postopts_file, MAXPGPATH, "%s/postmaster.opts.default", pg_data);
-        snprintf(postopts_file, MAXPGPATH, "%s/postmaster.opts", pg_data);
-        snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pg_data);
-        snprintf(conf_file, MAXPGPATH, "%s/postgresql.conf", pg_data);
-    }
+   if (pg_data)
+   {
+       snprintf(def_postopts_file, MAXPGPATH, "%s/postmaster.opts.default", pg_data);
+       snprintf(postopts_file, MAXPGPATH, "%s/postmaster.opts", pg_data);
+       snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pg_data);
+       snprintf(conf_file, MAXPGPATH, "%s/postgresql.conf", pg_data);
+   }
 
    switch (ctl_command)
    {
index 6f5e2d243eb4bbd99772de84d1368e17c5ba1ad2..4023837408fd060d8de806d49dc6af46ed60c760 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.31 2006/09/08 18:05:35 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.c,v 1.32 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -104,7 +104,7 @@ fmtId(const char *rawid)
  * standard_conforming_strings settings.
  *
  * This is essentially equivalent to libpq's PQescapeStringInternal,
- * except for the output buffer structure.  We need it in situations
+ * except for the output buffer structure. We need it in situations
  * where we do not have a PGconn available.  Where we do,
  * appendStringLiteralConn is a better choice.
  */
@@ -124,9 +124,9 @@ appendStringLiteral(PQExpBuffer buf, const char *str,
 
    while (*source != '\0')
    {
-       char    c = *source;
-       int     len;
-       int     i;
+       char        c = *source;
+       int         len;
+       int         i;
 
        /* Fast path for plain ASCII */
        if (!IS_HIGHBIT_SET(c))
@@ -153,15 +153,15 @@ appendStringLiteral(PQExpBuffer buf, const char *str,
 
        /*
         * If we hit premature end of string (ie, incomplete multibyte
-        * character), try to pad out to the correct length with spaces.
-        * We may not be able to pad completely, but we will always be able
-        * to insert at least one pad space (since we'd not have quoted a
+        * character), try to pad out to the correct length with spaces. We
+        * may not be able to pad completely, but we will always be able to
+        * insert at least one pad space (since we'd not have quoted a
         * multibyte character).  This should be enough to make a string that
         * the server will error out on.
         */
        if (i < len)
        {
-           char   *stop = buf->data + buf->maxlen - 2;
+           char       *stop = buf->data + buf->maxlen - 2;
 
            for (; i < len; i++)
            {
@@ -189,7 +189,7 @@ appendStringLiteral(PQExpBuffer buf, const char *str,
 void
 appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
 {
-   size_t  length = strlen(str);
+   size_t      length = strlen(str);
 
    /*
     * XXX This is a kluge to silence escape_string_warning in our utility
@@ -198,7 +198,7 @@ appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
    if (strchr(str, '\\') != NULL && PQserverVersion(conn) >= 80100)
    {
        /* ensure we are not adjacent to an identifier */
-       if (buf->len > 0 && buf->data[buf->len-1] != ' ')
+       if (buf->len > 0 && buf->data[buf->len - 1] != ' ')
            appendPQExpBufferChar(buf, ' ');
        appendPQExpBufferChar(buf, ESCAPE_STRING_SYNTAX);
        appendStringLiteral(buf, str, PQclientEncoding(conn), false);
@@ -614,7 +614,7 @@ do { \
    if (strcmp(type, "TABLE") == 0 || strcmp(type, "SEQUENCE") == 0)
    {
        CONVERT_PRIV('r', "SELECT");
-       
+
        if (strcmp(type, "SEQUENCE") == 0)
            /* sequence only */
            CONVERT_PRIV('U', "USAGE");
index 7492d42f7e4e7928bd90a18ff64fc119dbcee4fc..b177bb4bc82e65e61ccec4efd179ec8b9ab085e6 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.h,v 1.17 2006/05/28 21:13:54 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/dumputils.h,v 1.18 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,9 +20,9 @@
 
 extern const char *fmtId(const char *identifier);
 extern void appendStringLiteral(PQExpBuffer buf, const char *str,
-                               int encoding, bool std_strings);
+                   int encoding, bool std_strings);
 extern void appendStringLiteralConn(PQExpBuffer buf, const char *str,
-                                   PGconn *conn);
+                       PGconn *conn);
 extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
                      const char *dqprefix);
 extern int parse_version(const char *versionString);
index 426b5110fbddb6ff04dd9956d04ecaf85a72cddb..ae4e295dbdc1b77563151e062293f076d1602ff8 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.42 2006/08/01 18:21:44 momjian Exp $
+ *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.43 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -119,7 +119,7 @@ typedef struct _restoreOptions
 
    int         suppressDumpWarnings;   /* Suppress output of WARNING entries
                                         * to stderr */
-    bool        single_txn;
+   bool        single_txn;
 
 } RestoreOptions;
 
index 6100633d56ef0eaa1e79ae8db9a635714b12257f..32b6490e6e6c84ad0cf40f96cbf7a03bcb326ab5 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.135 2006/08/01 18:21:44 momjian Exp $
+ *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.136 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -278,19 +278,25 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
            _printTocEntry(AH, te, ropt, false, false);
            defnDumped = true;
 
-           /* If we could not create a table, ignore the respective TABLE DATA if 
-            * -X no-data-for-failed-tables is given */
-           if (ropt->noDataForFailedTables && AH->lastErrorTE == te && strcmp (te->desc, "TABLE") == 0) {
-               TocEntry *tes, *last;
-                                
-               ahlog (AH, 1, "table %s could not be created, will not restore its data\n", te->tag);
-
-               for (last = te, tes = te->next; tes != AH->toc; last = tes, tes = tes->next) {
-                   if (strcmp (tes->desc, "TABLE DATA") == 0 && strcmp (tes->tag, te->tag) == 0 &&
-                       strcmp (tes->namespace ? tes->namespace : "", te->namespace ? te->namespace : "") == 0) {
-                       /* remove this node */
-                       last->next = tes->next;
-                                            break;
+           /*
+            * If we could not create a table, ignore the respective TABLE
+            * DATA if -X no-data-for-failed-tables is given
+            */
+           if (ropt->noDataForFailedTables && AH->lastErrorTE == te && strcmp(te->desc, "TABLE") == 0)
+           {
+               TocEntry   *tes,
+                          *last;
+
+               ahlog(AH, 1, "table %s could not be created, will not restore its data\n", te->tag);
+
+               for (last = te, tes = te->next; tes != AH->toc; last = tes, tes = tes->next)
+               {
+                   if (strcmp(tes->desc, "TABLE DATA") == 0 && strcmp(tes->tag, te->tag) == 0 &&
+                       strcmp(tes->namespace ? tes->namespace : "", te->namespace ? te->namespace : "") == 0)
+                   {
+                       /* remove this node */
+                       last->next = tes->next;
+                       break;
                    }
                }
            }
index 1ed3f281a63ff538fffd650667714549f9ea949a..b64b8f3d32c6d80b12657e8ef239df269a34e2ce 100644 (file)
@@ -17,7 +17,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.72 2006/07/18 17:42:00 momjian Exp $
+ *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.73 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -98,29 +98,29 @@ struct _archiveHandle;
 struct _tocEntry;
 struct _restoreList;
 
-typedef void (*ClosePtr) (struct _archiveHandle *AH);
-typedef void (*ArchiveEntryPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-
-typedef void (*StartDataPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-typedef size_t (*WriteDataPtr) (struct _archiveHandle *AH, const void *data, size_t dLen);
-typedef void (*EndDataPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-
-typedef void (*StartBlobsPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-typedef void (*StartBlobPtr) (struct _archiveHandle *AH, struct _tocEntry *te, Oid oid);
-typedef void (*EndBlobPtr) (struct _archiveHandle *AH, struct _tocEntry *te, Oid oid);
-typedef void (*EndBlobsPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-
-typedef int (*WriteBytePtr) (struct _archiveHandle *AH, const int i);
-typedef int (*ReadBytePtr) (struct _archiveHandle *AH);
-typedef size_t (*WriteBufPtr) (struct _archiveHandle *AH, const void *c, size_t len);
-typedef size_t (*ReadBufPtr) (struct _archiveHandle *AH, void *buf, size_t len);
-typedef void (*SaveArchivePtr) (struct _archiveHandle *AH);
-typedef void (*WriteExtraTocPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-typedef void (*ReadExtraTocPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-typedef void (*PrintExtraTocPtr) (struct _archiveHandle *AH, struct _tocEntry *te);
-typedef void (*PrintTocDataPtr) (struct _archiveHandle *AH, struct _tocEntry *te, RestoreOptions *ropt);
-
-typedef size_t (*CustomOutPtr) (struct _archiveHandle *AH, const void *buf, size_t len);
+typedef void (*ClosePtr) (struct _archiveHandle * AH);
+typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+
+typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef size_t (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, size_t dLen);
+typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+
+typedef void (*StartBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*StartBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
+typedef void (*EndBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
+typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+
+typedef int (*WriteBytePtr) (struct _archiveHandle * AH, const int i);
+typedef int (*ReadBytePtr) (struct _archiveHandle * AH);
+typedef size_t (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
+typedef size_t (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
+typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
+typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt);
+
+typedef size_t (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, size_t len);
 
 typedef enum _archiveMode
 {
index f0b65a2f3ffa3f992b76c8e1efb7b7e9e0da4932..8d77af19c9239c29b47ac0af1f3e81dfc8d6aff7 100644 (file)
@@ -19,7 +19,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.35 2006/07/14 14:52:26 momjian Exp $
+ *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.36 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -545,7 +545,7 @@ _PrintData(ArchiveHandle *AH)
                             "could not read from input file: end of file\n");
            else
                die_horribly(AH, modulename,
-                            "could not read from input file: %s\n", strerror(errno));
+                   "could not read from input file: %s\n", strerror(errno));
        }
 
        ctx->filePos += blkLen;
@@ -673,7 +673,7 @@ _skipData(ArchiveHandle *AH)
                             "could not read from input file: end of file\n");
            else
                die_horribly(AH, modulename,
-                            "could not read from input file: %s\n", strerror(errno));
+                   "could not read from input file: %s\n", strerror(errno));
        }
 
        ctx->filePos += blkLen;
index 362e053165e9675a7b098bfade647e91b54551a2..aeb34989e8a78f820f283b1c7a2087d30da78f17 100644 (file)
@@ -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.74 2006/09/27 15:41:23 tgl Exp $
+ *   $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.75 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -378,9 +378,9 @@ _sendCopyLine(ArchiveHandle *AH, char *qry, char *eos)
    isEnd = (strcmp(AH->pgCopyBuf->data, "\\.\n") == 0);
 
    /*
-    * Note that we drop the data on the floor if libpq has failed to
-    * enter COPY mode; this allows us to behave reasonably when trying
-    * to continue after an error in a COPY command.
+    * Note that we drop the data on the floor if libpq has failed to enter
+    * COPY mode; this allows us to behave reasonably when trying to continue
+    * after an error in a COPY command.
     */
    if (AH->pgCopyIn &&
        PQputCopyData(AH->connection, AH->pgCopyBuf->data,
@@ -619,7 +619,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, size_t bufLen)
    {
        /*
         * If libpq is in CopyIn mode *or* if the archive structure shows we
-        * are sending COPY data, treat the data as COPY data.  The pgCopyIn
+        * are sending COPY data, treat the data as COPY data.  The pgCopyIn
         * check is only needed for backwards compatibility with ancient
         * archive files that might just issue a COPY command without marking
         * it properly.  Note that in an archive entry that has a copyStmt,
index 9b0606b7537cf4e4feffe3e294c0302e6da621a5..51d783b1a5132458105930b5c0e9fc912d7444a1 100644 (file)
@@ -16,7 +16,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.54 2006/06/27 02:56:41 momjian Exp $
+ *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.55 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -363,16 +363,17 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
 #ifndef WIN32
        tm->tmpFH = tmpfile();
 #else
+
        /*
-        *  On WIN32, tmpfile() generates a filename in the root directory,
-        *  which requires administrative permissions on certain systems.
-        *  Loop until we find a unique file name we can create.
+        * On WIN32, tmpfile() generates a filename in the root directory,
+        * which requires administrative permissions on certain systems. Loop
+        * until we find a unique file name we can create.
         */
        while (1)
        {
-           char *name;
-           int fd;
-           
+           char       *name;
+           int         fd;
+
            name = _tempnam(NULL, "pg_temp_");
            if (name == NULL)
                break;
@@ -380,7 +381,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
                      O_TEMPORARY, S_IRUSR | S_IWUSR);
            free(name);
 
-           if (fd != -1)   /* created a file */
+           if (fd != -1)       /* created a file */
            {
                tm->tmpFH = fdopen(fd, "w+b");
                break;
@@ -1060,7 +1061,7 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
        res = fwrite(&buf[0], 1, cnt, th->tarFH);
        if (res != cnt)
            die_horribly(AH, modulename,
-                        "could not write to output file: %s\n", strerror(errno));
+                   "could not write to output file: %s\n", strerror(errno));
        len += res;
    }
 
index 8e243d0d4178485258abcfab38dbf5eb5210d438..2b207f382b1ef8782001c73fb9f0cda73ff1b8ce 100644 (file)
@@ -12,7 +12,7 @@
  * by PostgreSQL
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.449 2006/09/27 15:41:23 tgl Exp $
+ *   $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.450 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -91,15 +91,16 @@ static Oid  g_last_builtin_oid; /* value of the last builtin oid */
 typedef struct objnameArg
 {
    struct objnameArg *next;
-   char *name;         /* name of the relation */
-   bool is_include;    /* include/exclude? */
+   char       *name;           /* name of the relation */
+   bool        is_include;     /* include/exclude? */
 } objnameArg;
 
-objnameArg *schemaList = NULL; /* List of schemas to include/exclude */
-objnameArg *tableList = NULL; /* List of tables to include/exclude */
+objnameArg *schemaList = NULL; /* List of schemas to include/exclude */
+objnameArg *tableList = NULL;  /* List of tables to include/exclude */
 
-char *matchingSchemas = NULL; /* Final list of schemas to dump by oid */
-char *matchingTables = NULL; /* Final list of tables to dump by oid */
+char      *matchingSchemas = NULL;     /* Final list of schemas to dump by
+                                        * oid */
+char      *matchingTables = NULL;      /* Final list of tables to dump by oid */
 
 char       g_opaque_type[10];  /* name for the opaque type */
 
@@ -189,7 +190,9 @@ main(int argc, char **argv)
 {
    PQExpBuffer query = createPQExpBuffer();
    PGresult   *res;
-   objnameArg *this_obj_name, *schemaList_tail = NULL, *tableList_tail = NULL;
+   objnameArg *this_obj_name,
+              *schemaList_tail = NULL,
+              *tableList_tail = NULL;
    int         c;
    const char *filename = NULL;
    const char *format = "p";
@@ -345,10 +348,10 @@ main(int argc, char **argv)
                ignore_version = true;
                break;
 
-           case 'n':       /* Include schemas */
-           case 'N':       /* Exclude schemas */
-           case 't':       /* Include tables */
-           case 'T':       /* Exclude tables */
+           case 'n':           /* Include schemas */
+           case 'N':           /* Exclude schemas */
+           case 't':           /* Include tables */
+           case 'T':           /* Exclude tables */
 
                if (strlen(optarg) < 1)
                {
@@ -359,7 +362,7 @@ main(int argc, char **argv)
                {
                    /* Create a struct for this name */
                    objnameArg *new_obj_name = (objnameArg *)
-                                               malloc(sizeof(objnameArg));
+                   malloc(sizeof(objnameArg));
 
                    new_obj_name->next = NULL;
                    new_obj_name->name = strdup(optarg);
@@ -567,8 +570,8 @@ main(int argc, char **argv)
    }
 
    /*
-    * Get the active encoding and the standard_conforming_strings setting,
-    * so we know how to escape strings.
+    * Get the active encoding and the standard_conforming_strings setting, so
+    * we know how to escape strings.
     */
    g_fout->encoding = PQclientEncoding(g_conn);
 
@@ -629,36 +632,36 @@ main(int argc, char **argv)
            /* Special case for when -N is the first argument */
            if (this_obj_name == schemaList && !this_obj_name->is_include)
                appendPQExpBuffer(query,
-                   "SELECT oid FROM pg_catalog.pg_namespace "
-                   "WHERE nspname NOT LIKE 'pg_%%' AND "
-                   "      nspname != 'information_schema' EXCEPT\n");
-   
+                                 "SELECT oid FROM pg_catalog.pg_namespace "
+                                 "WHERE nspname NOT LIKE 'pg_%%' AND "
+                          "      nspname != 'information_schema' EXCEPT\n");
+
            appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_namespace WHERE");
        }
-   
+
        appendPQExpBuffer(query, "%s nspname %c ", switch_include_exclude ? "" : " OR",
-                           /* any meta-characters? */
-                           strpbrk(this_obj_name->name,"([{\\.?+") == NULL ? '=' : '~');
+       /* any meta-characters? */
+              strpbrk(this_obj_name->name, "([{\\.?+") == NULL ? '=' : '~');
        appendStringLiteralAH(query, this_obj_name->name, g_fout);
-   
+
        if (this_obj_name->next && this_obj_name->next->is_include == this_obj_name->is_include)
            switch_include_exclude = false;
        else
        {
            switch_include_exclude = true;
-   
+
            /* Add the joiner if needed */
            if (this_obj_name->next)
                appendPQExpBuffer(query, "\n%s\n",
-                                 this_obj_name->next->is_include ? "UNION" : "EXCEPT");
+                      this_obj_name->next->is_include ? "UNION" : "EXCEPT");
        }
    }
 
    /* Construct OID list of matching schemas */
    if (schemaList)
    {
-       int len;
-       
+       int         len;
+
        res = PQexec(g_conn, query->data);
        check_sql_result(res, g_conn, query->data, PGRES_TUPLES_OK);
        if (PQntuples(res) == 0)
@@ -671,8 +674,8 @@ main(int argc, char **argv)
            len += strlen(PQgetvalue(res, i, 0)) + 1;
 
        /*
-        *  Need to use comma separators so it can be used by IN.  zero
-        *  is a dummy placeholder.  Format is " oid oid oid ".
+        * Need to use comma separators so it can be used by IN.  zero is a
+        * dummy placeholder.  Format is " oid oid oid ".
         */
        matchingSchemas = malloc(len + 1);
        strcpy(matchingSchemas, " ");
@@ -694,27 +697,27 @@ main(int argc, char **argv)
            /* Special case for when -T is the first argument */
            if (this_obj_name == tableList && !this_obj_name->is_include && !strlen(query->data))
                appendPQExpBuffer(query,
-                   "SELECT pg_class.oid FROM pg_catalog.pg_class, pg_catalog.pg_namespace "
-                   "WHERE relkind='r' AND "
-                   "      relnamespace = pg_namespace.oid AND "
-                   "      nspname NOT LIKE 'pg_%%' AND "
-                   "      nspname != 'information_schema' EXCEPT\n");
-   
+                                 "SELECT pg_class.oid FROM pg_catalog.pg_class, pg_catalog.pg_namespace "
+                                 "WHERE relkind='r' AND "
+                                 "      relnamespace = pg_namespace.oid AND "
+                                 "      nspname NOT LIKE 'pg_%%' AND "
+                          "      nspname != 'information_schema' EXCEPT\n");
+
            appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_class WHERE relkind='r' AND (");
        }
-   
+
        appendPQExpBuffer(query, "%srelname %c ", switch_include_exclude ? "" : " OR ",
-                           /* any meta-characters? */
-                           strpbrk(this_obj_name->name,"([{\\.?+") == NULL ? '=' : '~');
+       /* any meta-characters? */
+              strpbrk(this_obj_name->name, "([{\\.?+") == NULL ? '=' : '~');
        appendStringLiteralAH(query, this_obj_name->name, g_fout);
-   
+
        if (this_obj_name->next && this_obj_name->next->is_include == this_obj_name->is_include)
            switch_include_exclude = false;
        else
        {
            switch_include_exclude = true;
            appendPQExpBuffer(query, ")");
-       
+
            /* Add the joiner if needed */
            if (this_obj_name->next)
                appendPQExpBuffer(query, "\n%s\n", this_obj_name->next->is_include ?
@@ -725,18 +728,19 @@ main(int argc, char **argv)
    /* Construct OID list of matching tables */
    if (tableList)
    {
-       int len;
-       
+       int         len;
+
        /* Restrict by schema? */
        if (matchingSchemas != NULL)
        {
-           char *matchingSchemas_commas = strdup(matchingSchemas), *p;
+           char       *matchingSchemas_commas = strdup(matchingSchemas),
+                      *p;
 
            /* Construct "IN" SQL string by adding commas, " oid, oid, oid " */
            for (p = matchingSchemas_commas; *p; p++)
            {
                /* No commas for first/last characters */
-               if (*p == ' ' && p != matchingSchemas_commas && *(p+1))
+               if (*p == ' ' && p != matchingSchemas_commas && *(p + 1))
                    *p = ',';
            }
 
@@ -940,16 +944,16 @@ selectDumpableNamespace(NamespaceInfo *nsinfo)
 {
    /*
     * If specific tables are being dumped, do not dump any complete
-    * namespaces.  If specific namespaces are being dumped, dump just 
-    * those namespaces. Otherwise, dump all non-system namespaces.
+    * namespaces.  If specific namespaces are being dumped, dump just those
+    * namespaces. Otherwise, dump all non-system namespaces.
     */
    nsinfo->dobj.dump = false;
 
    if (matchingTables != NULL)
-       /* false */;
+        /* false */ ;
    else if (matchingSchemas != NULL)
    {
-       char *search_oid = malloc(20);
+       char       *search_oid = malloc(20);
 
        sprintf(search_oid, " %d ", nsinfo->dobj.catId.oid);
        if (strstr(matchingSchemas, search_oid) != NULL)
@@ -984,7 +988,7 @@ selectDumpableTable(TableInfo *tbinfo)
    }
    else
    {
-       char *search_oid = malloc(20);
+       char       *search_oid = malloc(20);
 
        sprintf(search_oid, " %d ", tbinfo->dobj.catId.oid);
        if (strstr(matchingTables, search_oid) != NULL)
@@ -1034,8 +1038,8 @@ static void
 selectDumpableObject(DumpableObject *dobj)
 {
    /*
-    * Default policy is to dump if parent namespace is dumpable,
-    * or always for non-namespace-associated items.
+    * Default policy is to dump if parent namespace is dumpable, or always
+    * for non-namespace-associated items.
     */
    if (dobj->namespace)
        dobj->dump = dobj->namespace->dobj.dump;
@@ -1451,7 +1455,7 @@ dumpDatabase(Archive *AH)
                          "(%s datdba) as dba, "
                          "pg_encoding_to_char(encoding) as encoding, "
                          "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) as tablespace, "
-                         "shobj_description(oid, 'pg_database') as description "
+                     "shobj_description(oid, 'pg_database') as description "
 
                          "FROM pg_database "
                          "WHERE datname = ",
@@ -1562,25 +1566,30 @@ dumpDatabase(Archive *AH)
    /* Dump DB comment if any */
    if (g_fout->remoteVersion >= 80200)
    {
-       /* 8.2 keeps comments on shared objects in a shared table, so
-        * we cannot use the dumpComment used for other database objects.
+       /*
+        * 8.2 keeps comments on shared objects in a shared table, so we
+        * cannot use the dumpComment used for other database objects.
         */
-       char *comment = PQgetvalue(res, 0, PQfnumber(res, "description"));
-       if (comment && strlen(comment)) {
+       char       *comment = PQgetvalue(res, 0, PQfnumber(res, "description"));
+
+       if (comment && strlen(comment))
+       {
            resetPQExpBuffer(dbQry);
            appendPQExpBuffer(dbQry, "COMMENT ON DATABASE %s IS ", fmtId(datname));
            appendStringLiteralAH(dbQry, comment, AH);
            appendPQExpBuffer(dbQry, ";\n");
 
            ArchiveEntry(AH, dbCatId, createDumpId(), datname, NULL, NULL,
-                           dba, false, "COMMENT", dbQry->data, "", NULL,
-                           &dbDumpId, 1, NULL, NULL);
+                        dba, false, "COMMENT", dbQry->data, "", NULL,
+                        &dbDumpId, 1, NULL, NULL);
        }
-   } else {
+   }
+   else
+   {
        resetPQExpBuffer(dbQry);
        appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
        dumpComment(AH, dbQry->data, NULL, "",
-               dbCatId, 0, dbDumpId);
+                   dbCatId, 0, dbDumpId);
    }
 
    PQclear(res);
@@ -2138,12 +2147,12 @@ getTypes(int *numTypes)
 
        /*
         * If it's a base type, make a DumpableObject representing a shell
-        * definition of the type.  We will need to dump that ahead of the
-        * I/O functions for the type.
+        * definition of the type.  We will need to dump that ahead of the I/O
+        * functions for the type.
         *
         * Note: the shell type doesn't have a catId.  You might think it
-        * should copy the base type's catId, but then it might capture
-        * the pg_depend entries for the type, which we don't want.
+        * should copy the base type's catId, but then it might capture the
+        * pg_depend entries for the type, which we don't want.
         */
        if (tinfo[i].dobj.dump && tinfo[i].typtype == 'b')
        {
@@ -2157,9 +2166,9 @@ getTypes(int *numTypes)
            tinfo[i].shellType = stinfo;
 
            /*
-            * Initially mark the shell type as not to be dumped.  We'll
-            * only dump it if the I/O functions need to be dumped; this
-            * is taken care of while sorting dependencies.
+            * Initially mark the shell type as not to be dumped.  We'll only
+            * dump it if the I/O functions need to be dumped; this is taken
+            * care of while sorting dependencies.
             */
            stinfo->dobj.dump = false;
 
@@ -2557,7 +2566,7 @@ getAggregates(int *numAggs)
    {
        appendPQExpBuffer(query, "SELECT tableoid, oid, aggname, "
                          "0::oid as aggnamespace, "
-                         "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END as pronargs, "
+                 "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END as pronargs, "
                          "aggbasetype as proargtypes, "
                          "(%s aggowner) as rolname, "
                          "'{=X}' as aggacl "
@@ -2572,7 +2581,7 @@ getAggregates(int *numAggs)
                          "(SELECT oid FROM pg_class WHERE relname = 'pg_aggregate') AS tableoid, "
                          "oid, aggname, "
                          "0::oid as aggnamespace, "
-                         "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END as pronargs, "
+                 "CASE WHEN aggbasetype = 0 THEN 0 ELSE 1 END as pronargs, "
                          "aggbasetype as proargtypes, "
                          "(%s aggowner) as rolname, "
                          "'{=X}' as aggacl "
@@ -2625,7 +2634,8 @@ getAggregates(int *numAggs)
                parseOidArray(PQgetvalue(res, i, i_proargtypes),
                              agginfo[i].aggfn.argtypes,
                              agginfo[i].aggfn.nargs);
-           else                /* it's just aggbasetype */
+           else
+               /* it's just aggbasetype */
                agginfo[i].aggfn.argtypes[0] = atooid(PQgetvalue(res, i, i_proargtypes));
        }
 
@@ -3095,13 +3105,13 @@ getTables(int *numTables)
    PQclear(res);
 
    /*
-    * Force sequences that are "owned" by table columns to be dumped
-    * whenever their owning table is being dumped.
+    * Force sequences that are "owned" by table columns to be dumped whenever
+    * their owning table is being dumped.
     */
    for (i = 0; i < ntups; i++)
    {
        TableInfo  *seqinfo = &tblinfo[i];
-       int     j;
+       int         j;
 
        if (!OidIsValid(seqinfo->owning_tab))
            continue;           /* not an owned sequence */
@@ -3250,7 +3260,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
                              "c.tableoid as contableoid, "
                              "c.oid as conoid, "
                              "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace, "
-                             "array_to_string(t.reloptions, ', ') as options "
+                           "array_to_string(t.reloptions, ', ') as options "
                              "FROM pg_catalog.pg_index i "
                      "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
                              "LEFT JOIN pg_catalog.pg_depend d "
@@ -3276,7 +3286,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
                              "c.tableoid as contableoid, "
                              "c.oid as conoid, "
                              "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) as tablespace, "
-                             "null as options "
+                             "null as options "
                              "FROM pg_catalog.pg_index i "
                      "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
                              "LEFT JOIN pg_catalog.pg_depend d "
@@ -3302,7 +3312,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
                              "c.tableoid as contableoid, "
                              "c.oid as conoid, "
                              "NULL as tablespace, "
-                             "null as options "
+                             "null as options "
                              "FROM pg_catalog.pg_index i "
                      "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
                              "LEFT JOIN pg_catalog.pg_depend d "
@@ -3330,7 +3340,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
                              "0::oid as contableoid, "
                              "t.oid as conoid, "
                              "NULL as tablespace, "
-                             "null as options "
+                             "null as options "
                              "FROM pg_index i, pg_class t "
                              "WHERE t.oid = i.indexrelid "
                              "AND i.indrelid = '%u'::oid "
@@ -3353,7 +3363,7 @@ getIndexes(TableInfo tblinfo[], int numTables)
                              "0::oid as contableoid, "
                              "t.oid as conoid, "
                              "NULL as tablespace, "
-                             "null as options "
+                             "null as options "
                              "FROM pg_index i, pg_class t "
                              "WHERE t.oid = i.indexrelid "
                              "AND i.indrelid = '%u'::oid "
@@ -5211,7 +5221,7 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
    else if (!PQgetisnull(res, 0, PQfnumber(res, "typdefault")))
    {
        typdefault = PQgetvalue(res, 0, PQfnumber(res, "typdefault"));
-       typdefault_is_literal = true;       /* it needs quotes */
+       typdefault_is_literal = true;   /* it needs quotes */
    }
    else
        typdefault = NULL;
@@ -5219,8 +5229,8 @@ dumpBaseType(Archive *fout, TypeInfo *tinfo)
    /*
     * DROP must be fully qualified in case same name appears in pg_catalog.
     * The reason we include CASCADE is that the circular dependency between
-    * the type and its I/O functions makes it impossible to drop the type
-    * any other way.
+    * the type and its I/O functions makes it impossible to drop the type any
+    * other way.
     */
    appendPQExpBuffer(delq, "DROP TYPE %s.",
                      fmtId(tinfo->dobj.namespace->dobj.name));
@@ -5375,7 +5385,7 @@ dumpDomain(Archive *fout, TypeInfo *tinfo)
    else if (!PQgetisnull(res, 0, PQfnumber(res, "typdefault")))
    {
        typdefault = PQgetvalue(res, 0, PQfnumber(res, "typdefault"));
-       typdefault_is_literal = true;       /* it needs quotes */
+       typdefault_is_literal = true;   /* it needs quotes */
    }
    else
        typdefault = NULL;
@@ -5557,11 +5567,11 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
 
    /*
     * Note the lack of a DROP command for the shell type; any required DROP
-    * is driven off the base type entry, instead.  This interacts with
+    * is driven off the base type entry, instead.  This interacts with
     * _printTocEntry()'s use of the presence of a DROP command to decide
-    * whether an entry needs an ALTER OWNER command.  We don't want to
-    * alter the shell type's owner immediately on creation; that should
-    * happen only after it's filled in, otherwise the backend complains.
+    * whether an entry needs an ALTER OWNER command.  We don't want to alter
+    * the shell type's owner immediately on creation; that should happen only
+    * after it's filled in, otherwise the backend complains.
     */
 
    appendPQExpBuffer(q, "CREATE TYPE %s;\n",
@@ -5972,7 +5982,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
             * contains quote or backslash; else use regular quoting.
             */
            if (disable_dollar_quoting ||
-               (strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
+             (strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
                appendStringLiteralAH(asPart, prosrc, fout);
            else
                appendStringLiteralDQ(asPart, prosrc, NULL);
@@ -6158,7 +6168,7 @@ dumpCast(Archive *fout, CastInfo *cast)
     * Skip this cast if all objects are from pg_
     */
    if ((funcInfo == NULL ||
-       strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) == 0) &&
+        strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) == 0) &&
        strncmp(sourceInfo->dobj.namespace->dobj.name, "pg_", 3) == 0 &&
        strncmp(targetInfo->dobj.namespace->dobj.name, "pg_", 3) == 0)
        return;
@@ -7396,8 +7406,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
                }
 
                /*
-                * Default value --- suppress if inherited or to be
-                * printed separately.
+                * Default value --- suppress if inherited or to be printed
+                * separately.
                 */
                if (tbinfo->attrdefs[j] != NULL &&
                    !tbinfo->inhAttrDef[j] &&
@@ -8077,10 +8087,10 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
    /*
     * The logic we use for restoring sequences is as follows:
     *
-    * Add a CREATE SEQUENCE statement as part of a "schema" dump
-    * (use last_val for start if called is false, else use min_val for
-    * start_val).  Also, if the sequence is owned by a column, add an
-    * ALTER SEQUENCE SET OWNED command for it.
+    * Add a CREATE SEQUENCE statement as part of a "schema" dump (use
+    * last_val for start if called is false, else use min_val for start_val).
+    * Also, if the sequence is owned by a column, add an ALTER SEQUENCE SET
+    * OWNED command for it.
     *
     * Add a 'SETVAL(seq, last_val, iscalled)' as part of a "data" dump.
     */
@@ -8137,9 +8147,9 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
         * as a separate TOC entry immediately following the sequence's own
         * entry.  It's OK to do this rather than using full sorting logic,
         * because the dependency that tells us it's owned will have forced
-        * the table to be created first.  We can't just include the ALTER
-        * in the TOC entry because it will fail if we haven't reassigned
-        * the sequence owner to match the table's owner.
+        * the table to be created first.  We can't just include the ALTER in
+        * the TOC entry because it will fail if we haven't reassigned the
+        * sequence owner to match the table's owner.
         *
         * We need not schema-qualify the table reference because both
         * sequence and table must be in the same schema.
@@ -8156,14 +8166,14 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
                appendPQExpBuffer(query, " OWNED BY %s",
                                  fmtId(owning_tab->dobj.name));
                appendPQExpBuffer(query, ".%s;\n",
-                                 fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
+                       fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
 
                ArchiveEntry(fout, nilCatalogId, createDumpId(),
                             tbinfo->dobj.name,
                             tbinfo->dobj.namespace->dobj.name,
                             NULL,
                             tbinfo->rolname,
-                            false, "SEQUENCE OWNED BY", query->data, "", NULL,
+                          false, "SEQUENCE OWNED BY", query->data, "", NULL,
                             &(tbinfo->dobj.dumpId), 1,
                             NULL, NULL);
            }
@@ -8334,9 +8344,10 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
        {
            if (*s == '\'')
                appendPQExpBufferChar(query, '\'');
+
            /*
-            *  bytea unconditionally doubles backslashes, so we suppress
-            *  the doubling for standard_conforming_strings.
+            * bytea unconditionally doubles backslashes, so we suppress the
+            * doubling for standard_conforming_strings.
             */
            if (fout->std_strings && *s == '\\' && s[1] == '\\')
                s++;
index 2a18d2cfe2aa00ec4185e10040bfc5ecc7d77f1a..1df5ee10fa609175ff64d7603948ef2ec6b2db36 100644 (file)
@@ -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.82 2006/09/27 15:41:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.83 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -46,7 +46,7 @@ static void dumpCreateDB(PGconn *conn);
 static void dumpDatabaseConfig(PGconn *conn, const char *dbname);
 static void dumpUserConfig(PGconn *conn, const char *username);
 static void makeAlterConfigCommand(PGconn *conn, const char *arrayitem,
-                                  const char *type, const char *name);
+                      const char *type, const char *name);
 static void dumpDatabases(PGconn *conn);
 static void dumpTimestamp(char *msg);
 
@@ -309,8 +309,8 @@ main(int argc, char *argv[])
                               force_password, true);
 
    /*
-    * Get the active encoding and the standard_conforming_strings setting,
-    * so we know how to escape strings.
+    * Get the active encoding and the standard_conforming_strings setting, so
+    * we know how to escape strings.
     */
    encoding = PQclientEncoding(conn);
    std_strings = PQparameterStatus(conn, "standard_conforming_strings");
@@ -436,7 +436,7 @@ dumpRoles(PGconn *conn)
                          "rolcreaterole, rolcreatedb, rolcatupdate, "
                          "rolcanlogin, rolconnlimit, rolpassword, "
                          "rolvaliduntil, "
-                         "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment "
+             "pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment "
                          "FROM pg_authid "
                          "ORDER BY 1");
    else if (server_version >= 80100)
@@ -556,7 +556,8 @@ dumpRoles(PGconn *conn)
 
        appendPQExpBuffer(buf, ";\n");
 
-       if (!PQgetisnull(res, i, i_rolcomment)) {
+       if (!PQgetisnull(res, i, i_rolcomment))
+       {
            appendPQExpBuffer(buf, "COMMENT ON ROLE %s IS ", fmtId(rolename));
            appendStringLiteralConn(buf, PQgetvalue(res, i, i_rolcomment), conn);
            appendPQExpBuffer(buf, ";\n");
@@ -704,15 +705,15 @@ dumpTablespaces(PGconn *conn)
     */
    if (server_version >= 80200)
        res = executeQuery(conn, "SELECT spcname, "
-                          "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
+                        "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
                           "spclocation, spcacl, "
-                          "pg_catalog.shobj_description(oid, 'pg_tablespace') "
+                       "pg_catalog.shobj_description(oid, 'pg_tablespace') "
                           "FROM pg_catalog.pg_tablespace "
                           "WHERE spcname !~ '^pg_' "
                           "ORDER BY 1");
-   else 
+   else
        res = executeQuery(conn, "SELECT spcname, "
-                          "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
+                        "pg_catalog.pg_get_userbyid(spcowner) AS spcowner, "
                           "spclocation, spcacl, "
                           "null "
                           "FROM pg_catalog.pg_tablespace "
@@ -755,7 +756,8 @@ dumpTablespaces(PGconn *conn)
            exit(1);
        }
 
-       if (spccomment && strlen(spccomment)) {
+       if (spccomment && strlen(spccomment))
+       {
            appendPQExpBuffer(buf, "COMMENT ON TABLESPACE %s IS ", fspcname);
            appendStringLiteralConn(buf, spccomment, conn);
            appendPQExpBuffer(buf, ";\n");
@@ -883,13 +885,12 @@ dumpCreateDB(PGconn *conn)
            appendStringLiteralConn(buf, dbencoding, conn);
 
            /*
-            *  Output tablespace if it isn't the default.  For default, it
-            *  uses the default from the template database.  If tablespace
-            *  is specified and tablespace creation failed earlier,
-            *  (e.g. no such directory), the database creation will fail
-            *  too.  One solution would be to use 'SET default_tablespace'
-            *  like we do in pg_dump for setting non-default database
-            *  locations.
+            * Output tablespace if it isn't the default.  For default, it
+            * uses the default from the template database.  If tablespace is
+            * specified and tablespace creation failed earlier, (e.g. no such
+            * directory), the database creation will fail too.  One solution
+            * would be to use 'SET default_tablespace' like we do in pg_dump
+            * for setting non-default database locations.
             */
            if (strcmp(dbtablespace, "pg_default") != 0)
                appendPQExpBuffer(buf, " TABLESPACE = %s",
index a8308388e867f5328eeb67c4598795659f1421db..15613832792ccb7048ba6035ea3a106580e0960d 100644 (file)
@@ -23,7 +23,7 @@
  * Portions Copyright (c) 1996-2006, 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.52 2006/08/21 16:16:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.53 2006/10/04 00:30:05 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -587,7 +587,7 @@ static void
 RewriteControlFile(void)
 {
    int         fd;
-   char        buffer[PG_CONTROL_SIZE]; /* need not be aligned */
+   char        buffer[PG_CONTROL_SIZE];        /* need not be aligned */
 
    /*
     * Adjust fields as needed to force an empty XLOG starting at the next
index 28d5cef053604b84f7e141b59978776a6f5562d0..5bc849750b22ec136cd8ccff6f73323ac5ee8564 100644 (file)
@@ -3,12 +3,12 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.172 2006/08/29 15:19:50 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.173 2006/10/04 00:30:05 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "command.h"
 
-#ifdef __BORLANDC__        /* needed for BCC */
+#ifdef __BORLANDC__                /* needed for BCC */
 #undef mkdir
 #endif
 
@@ -157,17 +157,17 @@ HandleSlashCmds(PsqlScanState scan_state,
 static char *
 read_connect_arg(PsqlScanState scan_state)
 {
-   char *result;
-   char  quote;
+   char       *result;
+   char        quote;
 
    /*
-    * 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.
     */
    result = psql_scan_slash_option(scan_state, OT_SQLIDHACK, "e, true);
 
@@ -182,7 +182,7 @@ read_connect_arg(PsqlScanState scan_state)
 
    return result;
 }
-   
+
 
 /*
  * Subroutine to actually try to execute a backslash command.
@@ -223,17 +223,15 @@ exec_command(const char *cmd,
     *
     * \c dbname user host port
     *
-    * If any of these parameters are omitted or specified as '-', the
-    * current value of the parameter will be used instead. If the
-    * parameter has no current value, the default value for that
-    * parameter will be used. Some examples:
+    * If any of these parameters are omitted or specified as '-', the current
+    * value of the parameter will be used instead. If the parameter has no
+    * current value, the default value for that parameter will be used. Some
+    * examples:
     *
-    * \c - - hst       Connect to current database on current port of
-    *                  host "hst" as current user.
-    * \c - usr - prt   Connect to current database on "prt" port of current
-    *                  host as user "usr".
-    * \c dbs           Connect to "dbs" database on current port of current
-    *                  host as current user.
+    * \c - - hst       Connect to current database on current port of host
+    * "hst" as current user. \c - usr - prt   Connect to current database on
+    * "prt" port of current host as user "usr". \c dbs           Connect to
+    * "dbs" database on current port of current host as current user.
     */
    else if (strcmp(cmd, "c") == 0 || strcmp(cmd, "connect") == 0)
    {
@@ -970,13 +968,13 @@ exec_command(const char *cmd,
 static char *
 prompt_for_password(const char *username)
 {
-   char *result;
+   char       *result;
 
    if (username == NULL)
        result = simple_prompt("Password: ", 100, false);
    else
    {
-       char *prompt_text;
+       char       *prompt_text;
 
        prompt_text = malloc(strlen(username) + 32);
        sprintf(prompt_text, "Password for user \"%s\": ", username);
@@ -1013,9 +1011,9 @@ param_is_newly_set(const char *old_val, const char *new_val)
 static bool
 do_connect(char *dbname, char *user, char *host, char *port)
 {
-   PGconn      *o_conn = pset.db,
-               *n_conn;
-   char        *password = NULL;
+   PGconn     *o_conn = pset.db,
+              *n_conn;
+   char       *password = NULL;
 
    if (!dbname)
        dbname = PQdb(o_conn);
@@ -1027,15 +1025,14 @@ do_connect(char *dbname, char *user, char *host, char *port)
        port = PQport(o_conn);
 
    /*
-    * If the user asked to be prompted for a password, ask for one
-    * now. If not, use the password from the old connection, provided
-    * the username has not changed. Otherwise, try to connect without
-    * a password first, and then ask for a password if we got the
-    * appropriate error message.
+    * If the user asked to be prompted for a password, ask for one now. If
+    * not, use the password from the old connection, provided the username
+    * has not changed. Otherwise, try to connect without a password first,
+    * and then ask for a password if we got the appropriate error message.
     *
-    * XXX: this behavior is broken. It leads to spurious connection
-    * attempts in the postmaster's log, and doing a string comparison
-    * against the returned error message is pretty fragile.
+    * XXX: this behavior is broken. It leads to spurious connection attempts
+    * in the postmaster's log, and doing a string comparison against the
+    * returned error message is pretty fragile.
     */
    if (pset.getPassword)
    {
@@ -1059,8 +1056,8 @@ do_connect(char *dbname, char *user, char *host, char *port)
            break;
 
        /*
-        * Connection attempt failed; either retry the connection
-        * attempt with a new password, or give up.
+        * Connection attempt failed; either retry the connection attempt with
+        * a new password, or give up.
         */
        if (strcmp(PQerrorMessage(n_conn), PQnoPasswordSupplied) == 0)
        {
@@ -1070,9 +1067,9 @@ do_connect(char *dbname, char *user, char *host, char *port)
        }
 
        /*
-        * Failed to connect to the database. In interactive mode,
-        * keep the previous connection to the DB; in scripting mode,
-        * close our previous connection as well.
+        * Failed to connect to the database. In interactive mode, keep the
+        * previous connection to the DB; in scripting mode, close our
+        * previous connection as well.
         */
        if (pset.cur_cmd_interactive)
        {
@@ -1375,7 +1372,7 @@ process_file(char *filename, bool single_txn)
    FILE       *fd;
    int         result;
    char       *oldfilename;
-   PGresult   *res; 
+   PGresult   *res;
 
    if (!filename)
        return EXIT_FAILURE;
@@ -1392,11 +1389,11 @@ process_file(char *filename, bool single_txn)
    oldfilename = pset.inputfile;
    pset.inputfile = filename;
 
-    if (single_txn)
-        res = PSQLexec("BEGIN", false);
+   if (single_txn)
+       res = PSQLexec("BEGIN", false);
    result = MainLoop(fd);
-    if (single_txn)
-        res = PSQLexec("COMMIT", false);
+   if (single_txn)
+       res = PSQLexec("COMMIT", false);
 
    fclose(fd);
    pset.inputfile = oldfilename;
index 2abbe499d16302fba77d1aa1c8b0c909c8fd0d80..cd791b1d45fa1c1bef9cd04f990f914a4efd8424 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/command.h,v 1.27 2006/07/18 17:42:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.h,v 1.28 2006/10/04 00:30:05 momjian Exp $
  */
 #ifndef COMMAND_H
 #define COMMAND_H
 
 typedef enum _backslashResult
 {
-   PSQL_CMD_UNKNOWN = 0,           /* not done parsing yet (internal only) */
-   PSQL_CMD_SEND,                  /* query complete; send off */
-   PSQL_CMD_SKIP_LINE,             /* keep building query */
-   PSQL_CMD_TERMINATE,             /* quit program */
-   PSQL_CMD_NEWEDIT,               /* query buffer was changed (e.g., via \e) */
-   PSQL_CMD_ERROR                  /* the execution of the backslash command
+   PSQL_CMD_UNKNOWN = 0,       /* not done parsing yet (internal only) */
+   PSQL_CMD_SEND,              /* query complete; send off */
+   PSQL_CMD_SKIP_LINE,         /* keep building query */
+   PSQL_CMD_TERMINATE,         /* quit program */
+   PSQL_CMD_NEWEDIT,           /* query buffer was changed (e.g., via \e) */
+   PSQL_CMD_ERROR              /* the execution of the backslash command
                                 * resulted in an error */
 } backslashResult;
 
index ded8ecf2b1cc0bbfb84d178ebf34f57a16bb2957..2e30c4e9a26c2106dfdb53bab61b75e86905d4d1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.129 2006/09/27 15:41:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.130 2006/10/04 00:30:05 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "common.h"
@@ -236,7 +236,7 @@ volatile bool sigint_interrupt_enabled = false;
 
 sigjmp_buf sigint_interrupt_jmp;
 
-static PGcancel * volatile cancelConn = NULL;
+static PGcancel *volatile cancelConn = NULL;
 
 #ifdef WIN32
 static CRITICAL_SECTION cancelConnLock;
@@ -283,7 +283,6 @@ setup_cancel_handler(void)
 {
    pqsignal(SIGINT, handle_sigint);
 }
-
 #else                          /* WIN32 */
 
 static BOOL WINAPI
@@ -329,7 +328,6 @@ setup_cancel_handler(void)
 
    SetConsoleCtrlHandler(consoleHandler, TRUE);
 }
-
 #endif   /* WIN32 */
 
 
@@ -397,7 +395,7 @@ CheckConnection(void)
 void
 SetCancelConn(void)
 {
-   PGcancel *oldCancelConn;
+   PGcancel   *oldCancelConn;
 
 #ifdef WIN32
    EnterCriticalSection(&cancelConnLock);
@@ -427,7 +425,7 @@ SetCancelConn(void)
 void
 ResetCancelConn(void)
 {
-   PGcancel *oldCancelConn;
+   PGcancel   *oldCancelConn;
 
 #ifdef WIN32
    EnterCriticalSection(&cancelConnLock);
@@ -872,7 +870,7 @@ SendQuery(const char *query)
    {
        /* Default fetch-it-all-and-print mode */
        TimevalStruct before,
-               after;
+                   after;
 
        if (pset.timing)
            GETTIMEOFDAY(&before);
@@ -979,17 +977,17 @@ static bool
 ExecQueryUsingCursor(const char *query, double *elapsed_msec)
 {
    bool        OK = true;
-   PGresult        *results;
-   PQExpBufferData buf;
+   PGresult   *results;
+   PQExpBufferData buf;
    printQueryOpt my_popt = pset.popt;
    FILE       *queryFout_copy = pset.queryFout;
    bool        queryFoutPipe_copy = pset.queryFoutPipe;
-   bool            started_txn = false;
-   bool            did_pager = false;
-   int             ntuples;
-   char            fetch_cmd[64];
+   bool        started_txn = false;
+   bool        did_pager = false;
+   int         ntuples;
+   char        fetch_cmd[64];
    TimevalStruct before,
-                   after;
+               after;
 
    *elapsed_msec = 0;
 
@@ -1040,7 +1038,7 @@ ExecQueryUsingCursor(const char *query, double *elapsed_msec)
    if (pset.gfname)
    {
        /* keep this code in sync with PrintQueryTuples */
-       pset.queryFout = stdout;    /* so it doesn't get closed */
+       pset.queryFout = stdout;    /* so it doesn't get closed */
 
        /* open file/pipe */
        if (!setQFout(pset.gfname))
@@ -1136,9 +1134,9 @@ cleanup:
        GETTIMEOFDAY(&before);
 
    /*
-    * We try to close the cursor on either success or failure, but on
-    * failure ignore the result (it's probably just a bleat about
-    * being in an aborted transaction)
+    * We try to close the cursor on either success or failure, but on failure
+    * ignore the result (it's probably just a bleat about being in an aborted
+    * transaction)
     */
    results = PQexec(pset.db, "CLOSE _psql_cursor");
    if (OK)
@@ -1350,9 +1348,9 @@ command_no_begin(const char *query)
    }
 
    /*
-    * Note: these tests will match DROP SYSTEM and REINDEX TABLESPACE,
-    * which aren't really valid commands so we don't care much.
-    * The other four possible matches are correct.
+    * Note: these tests will match DROP SYSTEM and REINDEX TABLESPACE, which
+    * aren't really valid commands so we don't care much. The other four
+    * possible matches are correct.
     */
    if ((wordlen == 4 && pg_strncasecmp(query, "drop", 4) == 0) ||
        (wordlen == 7 && pg_strncasecmp(query, "reindex", 7) == 0))
@@ -1406,7 +1404,7 @@ is_select_command(const char *query)
 
    if (wordlen == 6 && pg_strncasecmp(query, "select", 6) == 0)
        return true;
-   
+
    if (wordlen == 6 && pg_strncasecmp(query, "values", 6) == 0)
        return true;
 
index 6045b7587d8408e78a54719d9e3e09f5dcd4e2fe..3b6d566b33c355ca75d0e2ea491e4c37e918cd53 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.50 2006/06/14 16:49:02 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.51 2006/10/04 00:30:05 momjian Exp $
  */
 #ifndef COMMON_H
 #define COMMON_H
@@ -45,6 +45,7 @@ extern volatile bool sigint_interrupt_enabled;
 extern sigjmp_buf sigint_interrupt_jmp;
 
 extern volatile bool cancel_pressed;
+
 /* Note: cancel_pressed is defined in print.c, see that file for reasons */
 
 extern void setup_cancel_handler(void);
index 6e514c1c0646f85b11c020d5a8026be981cf1401..82d92724e2de10c9f6c2aad933f618f115236ee9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.68 2006/08/30 23:34:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.69 2006/10/04 00:30:05 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "copy.h"
@@ -148,7 +148,7 @@ parse_slash_copy(const char *args)
    /* Handle COPY (SELECT) case */
    if (token[0] == '(')
    {
-       int parens = 1;
+       int         parens = 1;
 
        while (parens > 0)
        {
@@ -318,7 +318,7 @@ parse_slash_copy(const char *args)
                                nonstd_backslash, true, false, pset.encoding);
                if (token && pg_strcasecmp(token, "as") == 0)
                    token = strtokx(NULL, whitespace, NULL, "'",
-                                   nonstd_backslash, true, false, pset.encoding);
+                              nonstd_backslash, true, false, pset.encoding);
                if (token)
                    result->delim = pg_strdup(token);
                else
@@ -330,7 +330,7 @@ parse_slash_copy(const char *args)
                                nonstd_backslash, true, false, pset.encoding);
                if (token && pg_strcasecmp(token, "as") == 0)
                    token = strtokx(NULL, whitespace, NULL, "'",
-                                   nonstd_backslash, true, false, pset.encoding);
+                              nonstd_backslash, true, false, pset.encoding);
                if (token)
                    result->null = pg_strdup(token);
                else
@@ -342,7 +342,7 @@ parse_slash_copy(const char *args)
                                nonstd_backslash, true, false, pset.encoding);
                if (token && pg_strcasecmp(token, "as") == 0)
                    token = strtokx(NULL, whitespace, NULL, "'",
-                                   nonstd_backslash, true, false, pset.encoding);
+                              nonstd_backslash, true, false, pset.encoding);
                if (token)
                    result->quote = pg_strdup(token);
                else
@@ -354,7 +354,7 @@ parse_slash_copy(const char *args)
                                nonstd_backslash, true, false, pset.encoding);
                if (token && pg_strcasecmp(token, "as") == 0)
                    token = strtokx(NULL, whitespace, NULL, "'",
-                                   nonstd_backslash, true, false, pset.encoding);
+                              nonstd_backslash, true, false, pset.encoding);
                if (token)
                    result->escape = pg_strdup(token);
                else
@@ -439,7 +439,7 @@ error:
 
 
 /*
- * Handle one of the "string" options of COPY.  If the user gave a quoted
+ * Handle one of the "string" options of COPY. If the user gave a quoted
  * string, pass it to the backend as-is; if it wasn't quoted then quote
  * and escape it.
  */
@@ -631,10 +631,10 @@ do_copy(const char *args)
 bool
 handleCopyOut(PGconn *conn, FILE *copystream)
 {
-   bool    OK = true;
-   char    *buf;
-   int      ret;
-   PGresult *res;
+   bool        OK = true;
+   char       *buf;
+   int         ret;
+   PGresult   *res;
 
    for (;;)
    {
@@ -677,7 +677,7 @@ handleCopyOut(PGconn *conn, FILE *copystream)
        OK = false;
    }
    PQclear(res);
-   
+
    return OK;
 }
 
@@ -702,11 +702,11 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
    bool        OK;
    const char *prompt;
    char        buf[COPYBUFSIZ];
-   PGresult *res;
+   PGresult   *res;
 
    /*
-    * Establish longjmp destination for exiting from wait-for-input.
-    * (This is only effective while sigint_interrupt_enabled is TRUE.)
+    * Establish longjmp destination for exiting from wait-for-input. (This is
+    * only effective while sigint_interrupt_enabled is TRUE.)
     */
    if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
    {
@@ -748,7 +748,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
 
        for (;;)
        {
-           int buflen;
+           int         buflen;
 
            /* enable longjmp while waiting for input */
            sigint_interrupt_enabled = true;
@@ -772,7 +772,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
        bool        copydone = false;
 
        while (!copydone)
-       {                           /* for each input line ... */
+       {                       /* for each input line ... */
            bool        firstload;
            bool        linedone;
 
@@ -781,14 +781,14 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
                fputs(prompt, stdout);
                fflush(stdout);
            }
-       
+
            firstload = true;
            linedone = false;
 
            while (!linedone)
-           {                       /* for each bufferload in line ... */
-               int     linelen;
-               char   *fgresult;
+           {                   /* for each bufferload in line ... */
+               int         linelen;
+               char       *fgresult;
 
                /* enable longjmp while waiting for input */
                sigint_interrupt_enabled = true;
@@ -806,7 +806,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
                linelen = strlen(buf);
 
                /* current line is done? */
-               if (linelen > 0 && buf[linelen-1] == '\n')
+               if (linelen > 0 && buf[linelen - 1] == '\n')
                    linedone = true;
 
                /* check for EOF marker, but not on a partial line */
@@ -818,10 +818,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
                        copydone = true;
                        break;
                    }
-               
+
                    firstload = false;
                }
-           
+
                if (PQputCopyData(conn, buf, linelen) <= 0)
                {
                    OK = false;
@@ -829,7 +829,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, bool isbinary)
                    break;
                }
            }
-       
+
            pset.lineno++;
        }
    }
index b6fbc135806c3aa64720eef847dd94bf78fd7f50..0adc99091d77df81a1ac5c32943bbded26294772 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.144 2006/08/29 15:19:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.145 2006/10/04 00:30:05 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "describe.h"
@@ -72,7 +72,7 @@ describeAggregates(const char *pattern, bool verbose)
                      "    ELSE\n"
                      "    pg_catalog.array_to_string(ARRAY(\n"
                      "      SELECT\n"
-                     "        pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
+                "        pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
                      "      FROM\n"
                      "        pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
                      "    ), ', ')\n"
@@ -132,7 +132,7 @@ describeTablespaces(const char *pattern, bool verbose)
    if (verbose)
        appendPQExpBuffer(&buf,
                          ",\n  spcacl as \"%s\""
-                         ",\n  pg_catalog.shobj_description(oid, 'pg_tablespace') AS \"%s\"",
+        ",\n  pg_catalog.shobj_description(oid, 'pg_tablespace') AS \"%s\"",
                          _("Access privileges"), _("Description"));
 
    appendPQExpBuffer(&buf,
@@ -175,20 +175,20 @@ 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"
                      "  CASE WHEN proallargtypes IS NOT NULL THEN\n"
                      "    pg_catalog.array_to_string(ARRAY(\n"
                      "      SELECT\n"
                      "        CASE\n"
                      "          WHEN p.proargmodes[s.i] = 'i' THEN ''\n"
                      "          WHEN p.proargmodes[s.i] = 'o' THEN 'OUT '\n"
-                     "          WHEN p.proargmodes[s.i] = 'b' THEN 'INOUT '\n"
+                   "          WHEN p.proargmodes[s.i] = 'b' THEN 'INOUT '\n"
                      "        END ||\n"
                      "        CASE\n"
-                     "          WHEN COALESCE(p.proargnames[s.i], '') = '' THEN ''\n"
+            "          WHEN COALESCE(p.proargnames[s.i], '') = '' THEN ''\n"
                      "          ELSE p.proargnames[s.i] || ' ' \n"
                      "        END ||\n"
-                     "        pg_catalog.format_type(p.proallargtypes[s.i], NULL)\n"
+             "        pg_catalog.format_type(p.proallargtypes[s.i], NULL)\n"
                      "      FROM\n"
                      "        pg_catalog.generate_series(1, pg_catalog.array_upper(p.proallargtypes, 1)) AS s(i)\n"
                      "    ), ', ')\n"
@@ -196,10 +196,10 @@ describeFunctions(const char *pattern, bool verbose)
                      "    pg_catalog.array_to_string(ARRAY(\n"
                      "      SELECT\n"
                      "        CASE\n"
-                     "          WHEN COALESCE(p.proargnames[s.i+1], '') = '' THEN ''\n"
+          "          WHEN COALESCE(p.proargnames[s.i+1], '') = '' THEN ''\n"
                      "          ELSE p.proargnames[s.i+1] || ' '\n"
                      "          END ||\n"
-                     "        pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
+                "        pg_catalog.format_type(p.proargtypes[s.i], NULL)\n"
                      "      FROM\n"
                      "        pg_catalog.generate_series(0, pg_catalog.array_upper(p.proargtypes, 1)) AS s(i)\n"
                      "    ), ', ')\n"
@@ -225,7 +225,7 @@ describeFunctions(const char *pattern, bool verbose)
                          "\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     JOIN pg_catalog.pg_roles r ON r.oid = p.proowner\n");
+               "\n     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
@@ -403,11 +403,11 @@ listAllDbs(bool verbose)
    }
    appendPQExpBuffer(&buf,
                      "\nFROM pg_catalog.pg_database d"
-                 "\n  JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n");
+                     "\n  JOIN pg_catalog.pg_roles r ON d.datdba = r.oid\n");
    if (verbose)
        appendPQExpBuffer(&buf,
-                   "  JOIN pg_catalog.pg_tablespace t on d.dattablespace = t.oid\n");  
-   appendPQExpBuffer(&buf,"ORDER BY 1;");
+          "  JOIN pg_catalog.pg_tablespace t on d.dattablespace = t.oid\n");
+   appendPQExpBuffer(&buf, "ORDER BY 1;");
    res = PSQLexec(buf.data, false);
    termPQExpBuffer(&buf);
    if (!res)
@@ -1460,7 +1460,7 @@ describeRoles(const char *pattern, bool verbose)
 
    if (verbose)
        appendPQExpBuffer(&buf, "\n, pg_catalog.shobj_description(r.oid, 'pg_authid') AS \"%s\"",
-                       _("Description"));
+                         _("Description"));
 
    appendPQExpBuffer(&buf, "\nFROM pg_catalog.pg_roles r\n");
 
@@ -1540,7 +1540,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
 
    appendPQExpBuffer(&buf,
                      "\nFROM pg_catalog.pg_class c"
-              "\n     JOIN pg_catalog.pg_roles r ON r.oid = c.relowner"
+                   "\n     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,
@@ -1782,7 +1782,7 @@ listSchemas(const char *pattern, bool verbose)
                          _("Access privileges"), _("Description"));
 
    appendPQExpBuffer(&buf,
-        "\nFROM pg_catalog.pg_namespace n JOIN pg_catalog.pg_roles r\n"
+             "\nFROM pg_catalog.pg_namespace n 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 */
@@ -1859,8 +1859,8 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
     * we assume this was NOT done by scan_option.  Also, adjust shell-style
     * wildcard characters into regexp notation.
     *
-    * Note: the result of this pass is the actual regexp pattern we want
-    * to execute.  Quoting/escaping it into a SQL literal will be done below.
+    * Note: the result of this pass is the actual regexp pattern we want to
+    * execute.  Quoting/escaping it into a SQL literal will be done below.
     */
    appendPQExpBufferChar(&namebuf, '^');
 
@@ -1929,8 +1929,8 @@ processNamePattern(PQExpBuffer buf, const char *pattern,
    }
 
    /*
-    * Now decide what we need to emit.  Note there will be a leading '^'
-    * in the patterns in any case.
+    * Now decide what we need to emit.  Note there will be a leading '^' in
+    * the patterns in any case.
     */
    if (namebuf.len > 1)
    {
index 323ef573b4070bce5b405ec200410123b2ebacd0..befee8635712c082300ca06f8eedfc300101aeca 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.59 2006/08/29 15:19:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/input.c,v 1.60 2006/10/04 00:30:06 momjian Exp $
  */
 #include "postgres_fe.h"
 
@@ -29,7 +29,7 @@ char     *psql_history;
  * Preserve newlines in saved queries by mapping '\n' to NL_IN_HISTORY
  *
  * It is assumed NL_IN_HISTORY will never be entered by the user
- * nor appear inside a multi-byte string.  0x00 is not properly
+ * nor appear inside a multi-byte string.  0x00 is not properly
  * handled by the readline routines so it can not be used
  * for this purpose.
  */
@@ -58,7 +58,7 @@ gets_interactive(const char *prompt)
 #ifdef USE_READLINE
    if (useReadline)
    {
-       char   *result;
+       char       *result;
 
        /* Enable SIGINT to longjmp to sigint_interrupt_jmp */
        sigint_interrupt_enabled = true;
@@ -91,8 +91,8 @@ pg_append_history(const char *s, PQExpBuffer history_buf)
        appendPQExpBufferStr(history_buf, s);
        if (s[strlen(s) - 1] != '\n')
            appendPQExpBufferChar(history_buf, '\n');
-   }   
-#endif 
+   }
+#endif
 }
 
 
@@ -110,7 +110,7 @@ pg_send_history(PQExpBuffer history_buf)
 #ifdef USE_READLINE
    static char *prev_hist = NULL;
 
-   char   *s = history_buf->data;
+   char       *s = history_buf->data;
 
    if (useHistory && s[0])
    {
@@ -123,10 +123,10 @@ pg_send_history(PQExpBuffer history_buf)
        }
        else
        {
-           int     i;
+           int         i;
 
            /* Trim any trailing \n's (OK to scribble on history_buf) */
-           for (i = strlen(s)-1; i >= 0 && s[i] == '\n'; i--)
+           for (i = strlen(s) - 1; i >= 0 && s[i] == '\n'; i--)
                ;
            s[i + 1] = '\0';
            /* Save each previous line for ignoredups processing */
@@ -151,7 +151,7 @@ pg_send_history(PQExpBuffer history_buf)
  *
  * Caller *must* have set up sigint_interrupt_jmp before calling.
  *
- * Note: we re-use a static PQExpBuffer for each call.  This is to avoid
+ * Note: we re-use a static PQExpBuffer for each call. This is to avoid
  * leaking memory if interrupted by SIGINT.
  */
 char *
@@ -168,7 +168,7 @@ gets_fromFile(FILE *source)
 
    for (;;)
    {
-       char   *result;
+       char       *result;
 
        /* Enable SIGINT to longjmp to sigint_interrupt_jmp */
        sigint_interrupt_enabled = true;
@@ -209,7 +209,7 @@ static void
 encode_history(void)
 {
    HIST_ENTRY *cur_hist;
-   char *cur_ptr;
+   char       *cur_ptr;
 
    history_set_pos(0);
    for (cur_hist = current_history(); cur_hist; cur_hist = next_history())
@@ -228,7 +228,7 @@ static void
 decode_history(void)
 {
    HIST_ENTRY *cur_hist;
-   char *cur_ptr;
+   char       *cur_ptr;
 
    history_set_pos(0);
    for (cur_hist = current_history(); cur_hist; cur_hist = next_history())
@@ -239,7 +239,7 @@ decode_history(void)
                *cur_ptr = '\n';
    }
 }
-#endif /* USE_READLINE */
+#endif   /* USE_READLINE */
 
 
 /*
@@ -296,8 +296,8 @@ initializeInput(int flags)
 
 
 /*
- * This function is for saving the readline history when user 
- * runs \s command or when psql finishes. 
+ * This function is for saving the readline history when user
+ * runs \s command or when psql finishes.
  *
  * We have an argument named encodeFlag to handle the cases differently.
  * In case of call via \s we don't really need to encode \n as \x01,
@@ -307,11 +307,12 @@ bool
 saveHistory(char *fname, bool encodeFlag)
 {
 #ifdef USE_READLINE
+
    /*
-    * Suppressing the write attempt when HISTFILE is set to /dev/null
-    * may look like a negligible optimization, but it's necessary on e.g.
-    * Darwin, where write_history will fail because it tries to chmod
-    * the target file.
+    * Suppressing the write attempt when HISTFILE is set to /dev/null may
+    * look like a negligible optimization, but it's necessary on e.g. Darwin,
+    * where write_history will fail because it tries to chmod the target
+    * file.
     */
    if (useHistory && fname &&
        strcmp(fname, DEVNULL) != 0)
@@ -321,8 +322,8 @@ saveHistory(char *fname, bool encodeFlag)
 
        /*
         * return value of write_history is not standardized across GNU
-        * readline and libedit.  Therefore, check for errno becoming set
-        * to see if the write failed.
+        * readline and libedit.  Therefore, check for errno becoming set to
+        * see if the write failed.
         */
        errno = 0;
        (void) write_history(fname);
index 519230b28aca263aaa73661bbeb0bb8da008279c..d597cb3d75326916c5233d746f0b64e10dd2f8f5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.83 2006/08/29 15:19:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.84 2006/10/04 00:30:06 momjian Exp $
  */
 #include "postgres_fe.h"
 #include "mainloop.h"
@@ -29,8 +29,8 @@ MainLoop(FILE *source)
    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 history_buf;    /* earlier lines of a multi-line command,
-                                * not yet saved to readline history */
+   PQExpBuffer history_buf;    /* earlier lines of a multi-line command, not
+                                * yet saved to readline history */
    char       *line;           /* current line of input */
    int         added_nl_pos;
    bool        success;
@@ -89,9 +89,9 @@ MainLoop(FILE *source)
        }
 
        /*
-        * Establish longjmp destination for exiting from wait-for-input.
-        * We must re-do this each time through the loop for safety, since
-        * the jmpbuf might get changed during command execution.
+        * Establish longjmp destination for exiting from wait-for-input. We
+        * must re-do this each time through the loop for safety, since the
+        * jmpbuf might get changed during command execution.
         */
        if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
        {
@@ -235,7 +235,7 @@ MainLoop(FILE *source)
                 * 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.  Also, in this
+                * line contains only a backslash command.  Also, in this
                 * situation we force out any previous lines as a separate
                 * history entry; we don't want SQL and backslash commands
                 * intermixed in history if at all possible.
index f0e0fa13b8982b2435d2e4f9e620a1817e0a272d..8a25955b5c49157d4e563281ef19da29e322312d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.22 2006/07/14 14:52:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mbprint.c,v 1.23 2006/10/04 00:30:06 momjian Exp $
  */
 
 #include "postgres_fe.h"
@@ -151,18 +151,19 @@ mb_utf_validate(unsigned char *pwcs)
 int
 pg_wcswidth(const unsigned char *pwcs, size_t len, int encoding)
 {
-   int width = 0;
+   int         width = 0;
 
    while (len > 0)
    {
-       int chlen, chwidth;
+       int         chlen,
+                   chwidth;
 
-       chlen = PQmblen((const char*) pwcs, encoding);
+       chlen = PQmblen((const char *) pwcs, encoding);
        if (chlen > len)
-           break;     /* Invalid string */
-           
+           break;              /* Invalid string */
+
        chwidth = PQdsplen((const char *) pwcs, encoding);
-       
+
        if (chwidth > 0)
            width += chwidth;
        pwcs += chlen;
@@ -173,60 +174,62 @@ pg_wcswidth(const unsigned char *pwcs, size_t len, int encoding)
 /*
  * pg_wcssize takes the given string in the given encoding and returns three
  * values:
- *    result_width: Width in display character of longest line in string
- *    result_hieght: Number of lines in display output
- *    result_format_size: Number of bytes required to store formatted representation of string
+ *   result_width: Width in display character of longest line in string
+ *   result_hieght: Number of lines in display output
+ *   result_format_size: Number of bytes required to store formatted representation of string
  */
 int
 pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
-           int *result_height, int *result_format_size)
+          int *result_height, int *result_format_size)
 {
-   int w,
-       chlen = 0,
-       linewidth = 0;
-   int width = 0;
-   int height = 1;
-   int format_size = 0;
+   int         w,
+               chlen = 0,
+               linewidth = 0;
+   int         width = 0;
+   int         height = 1;
+   int         format_size = 0;
 
    for (; *pwcs && len > 0; pwcs += chlen)
    {
        chlen = PQmblen((char *) pwcs, encoding);
-       if (len < (size_t)chlen)
+       if (len < (size_t) chlen)
            break;
        w = PQdsplen((char *) pwcs, encoding);
 
-       if (chlen == 1)   /* ASCII char */
+       if (chlen == 1)         /* ASCII char */
        {
-           if (*pwcs == '\n') /* Newline */
+           if (*pwcs == '\n')  /* Newline */
            {
                if (linewidth > width)
                    width = linewidth;
                linewidth = 0;
                height += 1;
-               format_size += 1;  /* For NUL char */
+               format_size += 1;       /* For NUL char */
            }
-           else if (*pwcs == '\r')   /* Linefeed */
+           else if (*pwcs == '\r')     /* Linefeed */
            {
                linewidth += 2;
                format_size += 2;
            }
-           else if (w <= 0)  /* Other control char */
+           else if (w <= 0)    /* Other control char */
            {
                linewidth += 4;
                format_size += 4;
            }
-           else  /* Output itself */
+           else
+               /* Output itself */
            {
                linewidth++;
                format_size += 1;
            }
        }
-       else if (w <= 0)  /* Non-ascii control char */
+       else if (w <= 0)        /* Non-ascii control char */
        {
-           linewidth += 6;   /* \u0000 */
+           linewidth += 6;     /* \u0000 */
            format_size += 6;
        }
-       else  /* All other chars */
+       else
+           /* All other chars */
        {
            linewidth += w;
            format_size += chlen;
@@ -236,7 +239,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
    if (linewidth > width)
        width = linewidth;
    format_size += 1;
-   
+
    /* Set results */
    if (result_width)
        *result_width = width;
@@ -244,76 +247,81 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *result_width,
        *result_height = height;
    if (result_format_size)
        *result_format_size = format_size;
-       
+
    return width;
 }
 
 void
 pg_wcsformat(unsigned char *pwcs, size_t len, int encoding,
-            struct lineptr *lines, int count)
+            struct lineptr * lines, int count)
 {
    int         w,
                chlen = 0;
-   int linewidth = 0;
-   unsigned char *ptr = lines->ptr;   /* Pointer to data area */
+   int         linewidth = 0;
+   unsigned char *ptr = lines->ptr;    /* Pointer to data area */
 
    for (; *pwcs && len > 0; pwcs += chlen)
    {
-       chlen = PQmblen((char *) pwcs,encoding);
-       if (len < (size_t)chlen)
+       chlen = PQmblen((char *) pwcs, encoding);
+       if (len < (size_t) chlen)
            break;
-       w = PQdsplen((char *) pwcs,encoding);
+       w = PQdsplen((char *) pwcs, encoding);
 
-       if (chlen == 1)   /* single byte char char */
+       if (chlen == 1)         /* single byte char char */
        {
-           if (*pwcs == '\n') /* Newline */
+           if (*pwcs == '\n')  /* Newline */
            {
-               *ptr++ = 0;   /* NULL char */
+               *ptr++ = 0;     /* NULL char */
                lines->width = linewidth;
                linewidth = 0;
                lines++;
                count--;
                if (count == 0)
-                   exit(1);   /* Screwup */    
-                   
+                   exit(1);    /* Screwup */
+
                lines->ptr = ptr;
            }
-           else if (*pwcs == '\r')   /* Linefeed */
+           else if (*pwcs == '\r')     /* Linefeed */
            {
                strcpy((char *) ptr, "\\r");
                linewidth += 2;
                ptr += 2;
            }
-           else if (w <= 0)  /* Other control char */
+           else if (w <= 0)    /* Other control char */
            {
                sprintf((char *) ptr, "\\x%02X", *pwcs);
                linewidth += 4;
                ptr += 4;
            }
-           else  /* Output itself */
+           else
+               /* Output itself */
            {
                linewidth++;
                *ptr++ = *pwcs;
            }
        }
-       else if (w <= 0)  /* Non-ascii control char */
+       else if (w <= 0)        /* Non-ascii control char */
        {
            if (encoding == PG_UTF8)
                sprintf((char *) ptr, "\\u%04X", utf2ucs(pwcs));
            else
-               /* This case cannot happen in the current
-                * code because only UTF-8 signals multibyte
-                * control characters. But we may need to
-                * support it at some stage */
+
+               /*
+                * This case cannot happen in the current code because only
+                * UTF-8 signals multibyte control characters. But we may need
+                * to support it at some stage
+                */
                sprintf((char *) ptr, "\\u????");
-               
+
            ptr += 6;
            linewidth += 6;
        }
-       else  /* All other chars */
+       else
+           /* All other chars */
        {
-           int i;
-           for (i=0; i < chlen; i++)
+           int         i;
+
+           for (i = 0; i < chlen; i++)
                *ptr++ = pwcs[i];
            linewidth += w;
        }
index 3941ce1580d668fde1ea69be5cb1b2ab3b542a4b..61e723cbaef6823b110e08db6b2259939270d13f 100644 (file)
@@ -1,17 +1,18 @@
-/* $PostgreSQL: pgsql/src/bin/psql/mbprint.h,v 1.10 2006/07/14 14:52:26 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/bin/psql/mbprint.h,v 1.11 2006/10/04 00:30:06 momjian Exp $ */
 #ifndef MBPRINT_H
 #define MBPRINT_H
 
 
-struct lineptr {
+struct lineptr
+{
    unsigned char *ptr;
-   int width;
+   int         width;
 };
 
 extern unsigned char *mbvalidate(unsigned char *pwcs, int encoding);
 
 extern int pg_wcswidth(const unsigned char *pwcs, size_t len, int encoding);
-extern void    pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, struct lineptr *lines, int count);
+extern void pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, struct lineptr * lines, int count);
 extern int pg_wcssize(unsigned char *pwcs, size_t len, int encoding, int *width, int *height, int *format_size);
 
 #endif   /* MBPRINT_H */
index 01f47e43b4fea0875bb4134e67e805ff13a21e36..f256212ec5d5473f790e91888a8a1a7a959c3fe5 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.89 2006/08/29 22:25:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/print.c,v 1.90 2006/10/04 00:30:06 momjian Exp $
  *
  * Note: we include postgres.h not postgres_fe.h so that we can include
  * catalog/pg_type.h, and thereby have access to INT4OID and similar macros.
@@ -180,8 +180,8 @@ print_unaligned_text(const char *title, const char *const * headers,
 {
    const char *opt_fieldsep = opt->fieldSep;
    const char *opt_recordsep = opt->recordSep;
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned int col_count = 0;
    unsigned int i;
    const char *const * ptr;
@@ -217,7 +217,8 @@ print_unaligned_text(const char *title, const char *const * headers,
            need_recordsep = true;
        }
    }
-   else                        /* assume continuing printout */
+   else
+       /* assume continuing printout */
        need_recordsep = true;
 
    /* print cells */
@@ -276,8 +277,8 @@ print_unaligned_vertical(const char *title, const char *const * headers,
 {
    const char *opt_fieldsep = opt->fieldSep;
    const char *opt_recordsep = opt->recordSep;
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned int col_count = 0;
    unsigned int i;
    const char *const * ptr;
@@ -304,7 +305,8 @@ print_unaligned_vertical(const char *title, const char *const * headers,
            need_recordsep = true;
        }
    }
-   else                        /* assume continuing printout */
+   else
+       /* assume continuing printout */
        need_recordsep = true;
 
    /* print records */
@@ -402,26 +404,28 @@ print_aligned_text(const char *title, const char *const * headers,
                   const char *opt_align, const printTableOpt *opt,
                   FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
-   int encoding = opt->encoding;
+   int         encoding = opt->encoding;
    unsigned int col_count = 0;
    unsigned int cell_count = 0;
    unsigned int i;
-   int tmp;
+   int         tmp;
    unsigned int *widths,
                total_w;
    unsigned int *heights;
    unsigned int *format_space;
    unsigned char **format_buf;
-   
-   const char *const *ptr;
-   
-   struct lineptr **col_lineptrs;   /* pointers to line pointer for each column */
-   struct lineptr *lineptr_list;    /* complete list of linepointers */
-   
-   int *complete;          /* Array remembering which columns have completed output */
+
+   const char *const * ptr;
+
+   struct lineptr **col_lineptrs;      /* pointers to line pointer for each
+                                        * column */
+   struct lineptr *lineptr_list;       /* complete list of linepointers */
+
+   int        *complete;       /* Array remembering which columns have
+                                * completed output */
 
    if (cancel_pressed)
        return;
@@ -451,7 +455,7 @@ print_aligned_text(const char *title, const char *const * headers,
        format_buf = NULL;
        complete = NULL;
    }
-   
+
    /* count cells (rows * cols) */
    for (ptr = cells; *ptr; ptr++)
        cell_count++;
@@ -460,7 +464,9 @@ print_aligned_text(const char *title, const char *const * headers,
    for (i = 0; i < col_count; i++)
    {
        /* Get width & height */
-       int height, space;
+       int         height,
+                   space;
+
        pg_wcssize((unsigned char *) headers[i], strlen(headers[i]), encoding, &tmp, &height, &space);
        if (tmp > widths[i])
            widths[i] = tmp;
@@ -472,14 +478,15 @@ print_aligned_text(const char *title, const char *const * headers,
 
    for (i = 0, ptr = cells; *ptr; ptr++, i++)
    {
-       int numeric_locale_len;
-       int height, space;
+       int         numeric_locale_len;
+       int         height,
+                   space;
 
        if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
            numeric_locale_len = additional_numeric_locale_len(*ptr);
-       else 
+       else
            numeric_locale_len = 0;
-       
+
        /* Get width, ignore height */
        pg_wcssize((unsigned char *) *ptr, strlen(*ptr), encoding, &tmp, &height, &space);
        tmp += numeric_locale_len;
@@ -501,29 +508,29 @@ print_aligned_text(const char *title, const char *const * headers,
    for (i = 0; i < col_count; i++)
        total_w += widths[i];
 
-   /* At this point:
-    *  widths contains the max width of each column
-    *  heights contains the max height of a cell of each column
-    *  format_space contains maximum space required to store formatted string
-    * so we prepare the formatting structures
+   /*
+    * At this point: widths contains the max width of each column heights
+    * contains the max height of a cell of each column format_space contains
+    * maximum space required to store formatted string so we prepare the
+    * formatting structures
     */
    if (col_count > 0)
    {
-       int heights_total = 0;
+       int         heights_total = 0;
        struct lineptr *lineptr;
-       
+
        for (i = 0; i < col_count; i++)
            heights_total += heights[i];
-           
+
        lineptr = lineptr_list = pg_local_calloc(heights_total, sizeof(*lineptr_list));
-           
+
        for (i = 0; i < col_count; i++)
        {
            col_lineptrs[i] = lineptr;
            lineptr += heights[i];
-           
+
            format_buf[i] = pg_local_malloc(format_space[i]);
-           
+
            col_lineptrs[i]->ptr = format_buf[i];
        }
    }
@@ -536,8 +543,9 @@ print_aligned_text(const char *title, const char *const * headers,
        if (title && !opt_tuples_only)
        {
            /* Get width & height */
-           int height;
-           pg_wcssize((unsigned char *)title, strlen(title), encoding, &tmp, &height, NULL);
+           int         height;
+
+           pg_wcssize((unsigned char *) title, strlen(title), encoding, &tmp, &height, NULL);
            if (tmp >= total_w)
                fprintf(fout, "%s\n", title);
            else
@@ -547,18 +555,18 @@ print_aligned_text(const char *title, const char *const * headers,
        /* print headers */
        if (!opt_tuples_only)
        {
-           int cols_todo;
-           int line_count;
-       
+           int         cols_todo;
+           int         line_count;
+
            if (opt_border == 2)
                _print_horizontal_line(col_count, widths, opt_border, fout);
 
            for (i = 0; i < col_count; i++)
-               pg_wcsformat((unsigned char *)headers[i], strlen(headers[i]), encoding, col_lineptrs[i], heights[i]);
-   
+               pg_wcsformat((unsigned char *) headers[i], strlen(headers[i]), encoding, col_lineptrs[i], heights[i]);
+
            cols_todo = col_count;
            line_count = 0;
-           memset(complete, 0, col_count*sizeof(int));
+           memset(complete, 0, col_count * sizeof(int));
            while (cols_todo)
            {
                if (opt_border == 2)
@@ -571,6 +579,7 @@ print_aligned_text(const char *title, const char *const * headers,
                    unsigned int nbspace;
 
                    struct lineptr *this_line = col_lineptrs[i] + line_count;
+
                    if (!complete[i])
                    {
                        nbspace = widths[i] - this_line->width;
@@ -579,7 +588,7 @@ print_aligned_text(const char *title, const char *const * headers,
                        fprintf(fout, "%-*s%s%-*s",
                                nbspace / 2, "", this_line->ptr, (nbspace + 1) / 2, "");
 
-                       if (line_count == (heights[i]-1) || !(this_line+1)->ptr)
+                       if (line_count == (heights[i] - 1) || !(this_line + 1)->ptr)
                        {
                            cols_todo--;
                            complete[i] = 1;
@@ -609,20 +618,20 @@ print_aligned_text(const char *title, const char *const * headers,
    }
 
    /* print cells */
-   for (i = 0, ptr = cells; *ptr; i+=col_count, ptr+=col_count)
+   for (i = 0, ptr = cells; *ptr; i += col_count, ptr += col_count)
    {
-       int j;
-       int cols_todo = col_count;
-       int line_count;         /* Number of lines output so far in row */
+       int         j;
+       int         cols_todo = col_count;
+       int         line_count; /* Number of lines output so far in row */
 
        if (cancel_pressed)
            break;
 
        for (j = 0; j < col_count; j++)
-           pg_wcsformat((unsigned char*)ptr[j], strlen(ptr[j]), encoding, col_lineptrs[j], heights[j]);
-   
+           pg_wcsformat((unsigned char *) ptr[j], strlen(ptr[j]), encoding, col_lineptrs[j], heights[j]);
+
        line_count = 0;
-       memset(complete, 0, col_count*sizeof(int));
+       memset(complete, 0, col_count * sizeof(int));
        while (cols_todo)
        {
            /* beginning of line */
@@ -634,9 +643,9 @@ print_aligned_text(const char *title, const char *const * headers,
            for (j = 0; j < col_count; j++)
            {
                struct lineptr *this_line = col_lineptrs[j] + line_count;
-               bool    finalspaces = (opt_border == 2 || j != col_count-1);
+               bool        finalspaces = (opt_border == 2 || j != col_count - 1);
 
-               if (complete[j])  /* Just print spaces... */
+               if (complete[j])    /* Just print spaces... */
                {
                    if (finalspaces)
                        fprintf(fout, "%*s", widths[j], "");
@@ -651,10 +660,11 @@ print_aligned_text(const char *title, const char *const * headers,
                            /*
                             * Assumption: This code used only on strings
                             * without multibyte characters, otherwise
-                            * this_line->width < strlen(this_ptr) and we
-                            * get an overflow
+                            * this_line->width < strlen(this_ptr) and we get
+                            * an overflow
                             */
-                           char *my_cell = format_numeric_locale((char *) this_line->ptr);
+                           char       *my_cell = format_numeric_locale((char *) this_line->ptr);
+
                            fprintf(fout, "%*s%s",
                                    (int) (widths[i % col_count] - strlen(my_cell)), "",
                                    my_cell);
@@ -667,15 +677,15 @@ print_aligned_text(const char *title, const char *const * headers,
                    }
                    else
                        fprintf(fout, "%-s%*s", this_line->ptr,
-                               finalspaces ? (widths[j] - this_line->width) : 0, "");
+                       finalspaces ? (widths[j] - this_line->width) : 0, "");
                    /* If at the right height, done this col */
-                   if (line_count == heights[j]-1 || !this_line[1].ptr)
+                   if (line_count == heights[j] - 1 || !this_line[1].ptr)
                    {
                        complete[j] = 1;
                        cols_todo--;
                    }
                }
-   
+
                /* divider */
                if ((j + 1) % col_count)
                {
@@ -684,7 +694,7 @@ print_aligned_text(const char *title, const char *const * headers,
                    else if (line_count == 0)
                        fputs(" | ", fout);
                    else
-                       fprintf(fout, " %c ", complete[j+1] ? ' ' : ':');
+                       fprintf(fout, " %c ", complete[j + 1] ? ' ' : ':');
                }
            }
            if (opt_border == 2)
@@ -705,8 +715,8 @@ print_aligned_text(const char *title, const char *const * headers,
                fprintf(fout, "%s\n", *ptr);
 
        /*
-        * for some reason MinGW (and MSVC) outputs an extra newline,
-        * so this suppresses it
+        * for some reason MinGW (and MSVC) outputs an extra newline, so this
+        * suppresses it
         */
 #ifndef WIN32
        fputc('\n', fout);
@@ -720,7 +730,7 @@ print_aligned_text(const char *title, const char *const * headers,
    free(format_space);
    free(complete);
    free(lineptr_list);
-   for (i= 0; i < col_count; i++)
+   for (i = 0; i < col_count; i++)
        free(format_buf[i]);
    free(format_buf);
 }
@@ -732,10 +742,10 @@ print_aligned_vertical(const char *title, const char *const * headers,
                       const char *opt_align, const printTableOpt *opt,
                       FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
-   int encoding = opt->encoding;
+   int         encoding = opt->encoding;
    unsigned int col_count = 0;
    unsigned long record = opt->prior_records + 1;
    const char *const * ptr;
@@ -746,17 +756,18 @@ print_aligned_vertical(const char *title, const char *const * headers,
                dheight = 1,
                hformatsize = 0,
                dformatsize = 0;
-   int tmp = 0;
+   int         tmp = 0;
    char       *divider;
    unsigned int cell_count = 0;
-   struct lineptr *hlineptr, *dlineptr;
+   struct lineptr *hlineptr,
+              *dlineptr;
 
    if (cancel_pressed)
        return;
 
    if (opt_border > 2)
        opt_border = 2;
-   
+
    if (cells[0] == NULL && opt->start_table && opt->stop_table)
    {
        fprintf(fout, _("(No rows)\n"));
@@ -770,7 +781,9 @@ print_aligned_vertical(const char *title, const char *const * headers,
    /* Find the maximum dimensions for the headers */
    for (i = 0; i < col_count; i++)
    {
-       int height, fs;
+       int         height,
+                   fs;
+
        pg_wcssize((unsigned char *) headers[i], strlen(headers[i]), encoding, &tmp, &height, &fs);
        if (tmp > hwidth)
            hwidth = tmp;
@@ -787,12 +800,13 @@ print_aligned_vertical(const char *title, const char *const * headers,
    /* find longest data cell */
    for (i = 0, ptr = cells; *ptr; ptr++, i++)
    {
-       int numeric_locale_len;
-       int height, fs;
+       int         numeric_locale_len;
+       int         height,
+                   fs;
 
        if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
            numeric_locale_len = additional_numeric_locale_len(*ptr);
-       else 
+       else
            numeric_locale_len = 0;
 
        pg_wcssize((unsigned char *) *ptr, strlen(*ptr), encoding, &tmp, &height, &fs);
@@ -804,11 +818,14 @@ print_aligned_vertical(const char *title, const char *const * headers,
        if (fs > dformatsize)
            dformatsize = fs;
    }
-   
-   /* We now have all the information we need to setup the formatting structures */
+
+   /*
+    * We now have all the information we need to setup the formatting
+    * structures
+    */
    dlineptr = pg_local_malloc(sizeof(*dlineptr) * dheight);
    hlineptr = pg_local_malloc(sizeof(*hlineptr) * hheight);
-   
+
    dlineptr->ptr = pg_local_malloc(dformatsize);
    hlineptr->ptr = pg_local_malloc(hformatsize);
 
@@ -838,8 +855,10 @@ print_aligned_vertical(const char *title, const char *const * headers,
    /* print records */
    for (i = 0, ptr = cells; *ptr; i++, ptr++)
    {
-       int line_count, dcomplete, hcomplete;
-       
+       int         line_count,
+                   dcomplete,
+                   hcomplete;
+
        if (i % col_count == 0)
        {
            if (cancel_pressed)
@@ -877,11 +896,11 @@ print_aligned_vertical(const char *title, const char *const * headers,
        }
 
        /* Format the header */
-       pg_wcsformat((unsigned char*)headers[i % col_count],
-                    strlen(headers[i % col_count]), encoding, hlineptr, hheight);
+       pg_wcsformat((unsigned char *) headers[i % col_count],
+               strlen(headers[i % col_count]), encoding, hlineptr, hheight);
        /* Format the data */
-       pg_wcsformat((unsigned char*)*ptr, strlen(*ptr), encoding, dlineptr, dheight);
-       
+       pg_wcsformat((unsigned char *) *ptr, strlen(*ptr), encoding, dlineptr, dheight);
+
        line_count = 0;
        dcomplete = hcomplete = 0;
        while (!dcomplete || !hcomplete)
@@ -892,51 +911,52 @@ print_aligned_vertical(const char *title, const char *const * headers,
            {
                fprintf(fout, "%-s%*s", hlineptr[line_count].ptr,
                        hwidth - hlineptr[line_count].width, "");
-                       
-               if (line_count == (hheight-1) || !hlineptr[line_count+1].ptr)
+
+               if (line_count == (hheight - 1) || !hlineptr[line_count + 1].ptr)
                    hcomplete = 1;
            }
            else
                fprintf(fout, "%*s", hwidth, "");
-   
+
            if (opt_border > 0)
-               fprintf(fout, " %c ", (line_count==0)?'|':':');
+               fprintf(fout, " %c ", (line_count == 0) ? '|' : ':');
            else
                fputs(" ", fout);
 
            if (!dcomplete)
            {
-               if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
-               {
-                   char *my_cell = format_numeric_locale((char *) dlineptr[line_count].ptr);
-                   if (opt_border < 2)
-                       fprintf(fout, "%s\n", my_cell);
-                   else
-                       fprintf(fout, "%-s%*s |\n", my_cell,
+               if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
+               {
+                   char       *my_cell = format_numeric_locale((char *) dlineptr[line_count].ptr);
+
+                   if (opt_border < 2)
+                       fprintf(fout, "%s\n", my_cell);
+                   else
+                       fprintf(fout, "%-s%*s |\n", my_cell,
                                (int) (dwidth - strlen(my_cell)), "");
-                   free(my_cell);
-               }
-               else
-               {
-                   if (opt_border < 2)
-                       fprintf(fout, "%s\n", dlineptr[line_count].ptr);
-                   else
-                       fprintf(fout, "%-s%*s |\n", dlineptr[line_count].ptr,
+                   free(my_cell);
+               }
+               else
+               {
+                   if (opt_border < 2)
+                       fprintf(fout, "%s\n", dlineptr[line_count].ptr);
+                   else
+                       fprintf(fout, "%-s%*s |\n", dlineptr[line_count].ptr,
                                dwidth - dlineptr[line_count].width, "");
-               }
-               
-               if (line_count == dheight - 1 || !dlineptr[line_count+1].ptr)
-                   dcomplete = 1;
-           }
-           else
-           {
-               if (opt_border < 2)
-                   fputc('\n', fout);
-               else
-                   fprintf(fout, "%*s |\n", dwidth, "");
-           }
-           line_count++;
-       }
+               }
+
+               if (line_count == dheight - 1 || !dlineptr[line_count + 1].ptr)
+                   dcomplete = 1;
+           }
+           else
+           {
+               if (opt_border < 2)
+                   fputc('\n', fout);
+               else
+                   fprintf(fout, "%*s |\n", dwidth, "");
+           }
+           line_count++;
+       }
    }
 
    if (opt->stop_table)
@@ -1016,8 +1036,8 @@ print_html_text(const char *title, const char *const * headers,
                const char *opt_align, const printTableOpt *opt,
                FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
    const char *opt_table_attr = opt->tableAttr;
    unsigned int col_count = 0;
@@ -1117,8 +1137,8 @@ print_html_vertical(const char *title, const char *const * headers,
                    const char *opt_align, const printTableOpt *opt,
                    FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
    const char *opt_table_attr = opt->tableAttr;
    unsigned int col_count = 0;
@@ -1255,8 +1275,8 @@ print_latex_text(const char *title, const char *const * headers,
                 const char *opt_align, const printTableOpt *opt,
                 FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
    unsigned int col_count = 0;
    unsigned int i;
@@ -1368,8 +1388,8 @@ print_latex_vertical(const char *title, const char *const * headers,
                     const char *opt_align, const printTableOpt *opt,
                     FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
    unsigned int col_count = 0;
    unsigned long record = opt->prior_records + 1;
@@ -1495,8 +1515,8 @@ print_troff_ms_text(const char *title, const char *const * headers,
                    const char *opt_align, const printTableOpt *opt,
                    FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
    unsigned int col_count = 0;
    unsigned int i;
@@ -1594,12 +1614,12 @@ 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 *const * cells, const char *const * footers,
                        const char *opt_align, const printTableOpt *opt,
                        FILE *fout)
 {
-   bool opt_tuples_only = opt->tuples_only;
-   bool opt_numeric_locale = opt->numericLocale;
+   bool        opt_tuples_only = opt->tuples_only;
+   bool        opt_numeric_locale = opt->numericLocale;
    unsigned short int opt_border = opt->border;
    unsigned int col_count = 0;
    unsigned long record = opt->prior_records + 1;
@@ -1737,7 +1757,7 @@ PageOutput(int lines, unsigned short int pager)
        )
    {
        const char *pagerprog;
-       FILE *pagerpipe;
+       FILE       *pagerpipe;
 
 #ifdef TIOCGWINSZ
        int         result;
@@ -1779,10 +1799,10 @@ ClosePager(FILE *pagerpipe)
        /*
         * If printing was canceled midstream, warn about it.
         *
-        * Some pagers like less use Ctrl-C as part of their command
-        * set. Even so, we abort our processing and warn the user
-        * what we did.  If the pager quit as a result of the
-        * SIGINT, this message won't go anywhere ...
+        * Some pagers like less use Ctrl-C as part of their command set. Even
+        * so, we abort our processing and warn the user what we did.  If the
+        * pager quit as a result of the SIGINT, this message won't go
+        * anywhere ...
         */
        if (cancel_pressed)
            fprintf(pagerpipe, _("Interrupted\n"));
@@ -1923,8 +1943,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout, FILE *f
    headers = pg_local_calloc(nfields + 1, sizeof(*headers));
 
    for (i = 0; i < nfields; i++)
-       headers[i] = (char*) mbvalidate((unsigned char *) PQfname(result, i),
-                                       opt->topt.encoding);
+       headers[i] = (char *) mbvalidate((unsigned char *) PQfname(result, i),
+                                        opt->topt.encoding);
 
    /* set cells */
    ncells = PQntuples(result) * nfields;
@@ -1935,8 +1955,8 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout, FILE *f
        if (PQgetisnull(result, i / nfields, i % nfields))
            cells[i] = opt->nullPrint ? opt->nullPrint : "";
        else
-           cells[i] = (char*)
-               mbvalidate((unsigned char*) PQgetvalue(result, i / nfields, i % nfields),
+           cells[i] = (char *)
+               mbvalidate((unsigned char *) PQgetvalue(result, i / nfields, i % nfields),
                           opt->topt.encoding);
    }
 
index 3e34f93b95575df4cc5efe267bc2520f53589687..c294c4be2d9fe3a2bc17b7878cc3f27a80717c19 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.30 2006/08/29 22:25:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.31 2006/10/04 00:30:06 momjian Exp $
  */
 #ifndef SETTINGS_H
 #define SETTINGS_H
@@ -87,9 +87,9 @@ typedef struct _psqlSettings
    VariableSpace vars;         /* "shell variable" repository */
 
    /*
-    * The remaining fields are set by assign hooks associated with
-    * entries in "vars".  They should not be set directly except by
-    * those hook functions.
+    * The remaining fields are set by assign hooks associated with entries in
+    * "vars".  They should not be set directly except by those hook
+    * functions.
     */
    bool        autocommit;
    bool        on_error_stop;
index 6cbd95da9ed69863f85303081ee9ebab814fab34..5c790020929a159fe9e1822d363dea3db1ff787a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.137 2006/08/29 22:25:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.138 2006/10/04 00:30:06 momjian Exp $
  */
 #include "postgres_fe.h"
 
@@ -75,7 +75,7 @@ struct adhoc_opts
    char       *action_string;
    bool        no_readline;
    bool        no_psqlrc;
-    bool        single_txn;
+   bool        single_txn;
 };
 
 static int parse_version(const char *versionString);
@@ -760,7 +760,6 @@ checkWin32Codepage(void)
               concp, wincp);
    }
 }
-
 #endif
 
 
index 9b089d84f853b386dc44fc00ad43f0124505a22a..f8060002db27deeeee29e4261b75930a502834ae 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.44 2006/07/14 14:52:27 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.45 2006/10/04 00:30:06 momjian Exp $
  */
 #include "postgres_fe.h"
 
@@ -31,7 +31,7 @@ static void strip_quotes(char *source, char quote, char escape, int encoding);
  * quote -     set of characters that can quote a token (NULL if none)
  * escape -        character that can quote quotes (0 if none)
  * e_strings - if TRUE, treat E'...' syntax as a valid token
- * del_quotes -    if TRUE, strip quotes from the returned token, else return
+ * del_quotes - if TRUE, strip quotes from the returned token, else return
  *             it exactly as found in the string
  * encoding -  the active character-set encoding
  *
index 64b9576a6624ce7b6391ce7a059cdf81eb3f7bf2..b04f2846aa41df060c43aeaf4193f4e31d5b2339 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.155 2006/09/22 21:39:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.156 2006/10/04 00:30:06 momjian Exp $
  */
 
 /*----------------------------------------------------------------------
@@ -480,7 +480,7 @@ static PGresult *exec_query(const char *query);
 
 static char *previous_word(int point, int skip);
 
-static int find_open_parenthesis(int end);
+static int find_open_parenthesis(int end);
 
 #if 0
 static char *quote_file_name(char *text, int match_type, char *quote_pointer);
@@ -767,13 +767,16 @@ psql_completion(char *text, int start, int end)
              pg_strcasecmp(prev_wd, "RENAME") == 0))
        COMPLETE_WITH_ATTR(prev2_wd, " UNION SELECT 'COLUMN'");
 
-   /* If we have TABLE  ALTER COLUMN|RENAME COLUMN, provide list of columns */
+   /*
+    * If we have TABLE  ALTER COLUMN|RENAME COLUMN, provide list of
+    * columns
+    */
    else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
             (pg_strcasecmp(prev2_wd, "ALTER") == 0 ||
              pg_strcasecmp(prev2_wd, "RENAME") == 0) &&
             pg_strcasecmp(prev_wd, "COLUMN") == 0)
        COMPLETE_WITH_ATTR(prev3_wd, "");
-  
+
    /* ALTER TABLE xxx RENAME yyy */
    else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
             pg_strcasecmp(prev2_wd, "RENAME") == 0 &&
@@ -951,7 +954,7 @@ psql_completion(char *text, int start, int end)
        {"CAST", "CONVERSION", "DATABASE", "INDEX", "LANGUAGE", "RULE", "SCHEMA",
            "SEQUENCE", "TABLE", "TYPE", "VIEW", "COLUMN", "AGGREGATE", "FUNCTION",
            "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN", "LARGE OBJECT",
-           "TABLESPACE", "ROLE", NULL};
+       "TABLESPACE", "ROLE", NULL};
 
        COMPLETE_WITH_LIST(list_COMMENT);
    }
@@ -1048,11 +1051,11 @@ psql_completion(char *text, int start, int end)
        if (find_open_parenthesis(end))
            COMPLETE_WITH_ATTR(prev_wd, "");
        else
-           COMPLETE_WITH_CONST("(");      
+           COMPLETE_WITH_CONST("(");
    }
    else if (pg_strcasecmp(prev5_wd, "INDEX") == 0 &&
-           pg_strcasecmp(prev3_wd, "ON") == 0 &&
-           pg_strcasecmp(prev_wd, "(") == 0)
+            pg_strcasecmp(prev3_wd, "ON") == 0 &&
+            pg_strcasecmp(prev_wd, "(") == 0)
        COMPLETE_WITH_ATTR(prev2_wd, "");
    /* same if you put in USING */
    else if (pg_strcasecmp(prev4_wd, "ON") == 0 &&
@@ -1264,7 +1267,8 @@ psql_completion(char *text, int start, int end)
            if (find_open_parenthesis(end))
            {
                static const char func_args_query[] = "select pg_catalog.oidvectortypes(proargtypes)||')' from pg_proc where proname='%s'";
-               char *tmp_buf = malloc(strlen(func_args_query) + strlen(prev_wd));
+               char       *tmp_buf = malloc(strlen(func_args_query) + strlen(prev_wd));
+
                sprintf(tmp_buf, func_args_query, prev_wd);
                COMPLETE_WITH_QUERY(tmp_buf);
                free(tmp_buf);
@@ -1278,16 +1282,17 @@ psql_completion(char *text, int start, int end)
        {
            static const char *const list_DROPCR[] =
            {"CASCADE", "RESTRICT", NULL};
-       
+
            COMPLETE_WITH_LIST(list_DROPCR);
        }
    }
    else if (pg_strcasecmp(prev4_wd, "DROP") == 0 &&
-           pg_strcasecmp(prev3_wd, "FUNCTION") == 0 &&
-           pg_strcasecmp(prev_wd, "(") == 0)
+            pg_strcasecmp(prev3_wd, "FUNCTION") == 0 &&
+            pg_strcasecmp(prev_wd, "(") == 0)
    {
        static const char func_args_query[] = "select pg_catalog.oidvectortypes(proargtypes)||')' from pg_proc where proname='%s'";
-       char *tmp_buf = malloc(strlen(func_args_query) + strlen(prev2_wd));
+       char       *tmp_buf = malloc(strlen(func_args_query) + strlen(prev2_wd));
+
        sprintf(tmp_buf, func_args_query, prev2_wd);
        COMPLETE_WITH_QUERY(tmp_buf);
        free(tmp_buf);
@@ -1376,8 +1381,8 @@ psql_completion(char *text, int start, int end)
    {
        static const char *const list_privileg[] =
        {"SELECT", "INSERT", "UPDATE", "DELETE", "RULE", "REFERENCES",
-        "TRIGGER", "CREATE", "CONNECT", "TEMPORARY", "EXECUTE", "USAGE",
-        "ALL", NULL};
+           "TRIGGER", "CREATE", "CONNECT", "TEMPORARY", "EXECUTE", "USAGE",
+       "ALL", NULL};
 
        COMPLETE_WITH_LIST(list_privileg);
    }
@@ -2394,22 +2399,24 @@ previous_word(int point, int skip)
 /* Find the parenthesis after the last word */
 
 
-static int find_open_parenthesis(int end)
+static int
+find_open_parenthesis(int end)
 {
-   int i = end-1;
-   
-   while((rl_line_buffer[i]!=' ')&&(i>=0))
+   int         i = end - 1;
+
+   while ((rl_line_buffer[i] != ' ') && (i >= 0))
    {
-       if (rl_line_buffer[i]=='(') return 1;
+       if (rl_line_buffer[i] == '(')
+           return 1;
        i--;
    }
-   while((rl_line_buffer[i]==' ')&&(i>=0))
+   while ((rl_line_buffer[i] == ' ') && (i >= 0))
    {
        i--;
    }
-   if (rl_line_buffer[i]=='(')
+   if (rl_line_buffer[i] == '(')
    {
-       return 1;       
+       return 1;
    }
    return 0;
 
index e4dce97a0a7307a9add0d7af2fe65fda9dbfb76d..348b3a0e49cca5b1ee5d3cda3a22a3fa78d5bfa6 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2000-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/bin/psql/variables.h,v 1.19 2006/08/29 15:19:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/variables.h,v 1.20 2006/10/04 00:30:06 momjian Exp $
  */
 #ifndef VARIABLES_H
 #define VARIABLES_H
@@ -39,7 +39,7 @@ typedef struct _variable *VariableSpace;
 VariableSpace CreateVariableSpace(void);
 const char *GetVariable(VariableSpace space, const char *name);
 
-bool ParseVariableBool(const char *val);
+bool       ParseVariableBool(const char *val);
 int ParseVariableNum(const char *val,
                 int defaultval,
                 int faultval,
index d5f026205448dce50d44acd3fee7506d432cf9e9..5190534268bdcbd13ae8326bef676ffdc64f4d77 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.23 2006/10/03 21:45:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.24 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -206,15 +206,18 @@ executeCommand(PGconn *conn, const char *query,
 bool
 yesno_prompt(const char *question)
 {
-   char prompt[256];
+   char        prompt[256];
 
-   /* translator: This is a question followed by the translated options for "yes" and "no". */
+   /*
+    * translator: This is a question followed by the translated options for
+    * "yes" and "no".
+    */
    snprintf(prompt, sizeof(prompt), _("%s (%s/%s) "),
             _(question), _(PG_YESLETTER), _(PG_NOLETTER));
 
    for (;;)
    {
-       char *resp;
+       char       *resp;
 
        resp = simple_prompt(prompt, 1, true);
 
index a3f5747004ee1bc286c310e9d795453ab02b822a..b1351c7693c9e86badddc8d60f6fdf404f334b63 100644 (file)
@@ -5,7 +5,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.33 2006/09/22 18:50:41 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.34 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -17,7 +17,8 @@
 
 static void help(const char *progname);
 
-enum trivalue {
+enum trivalue
+{
    TRI_DEFAULT,
    TRI_NO,
    TRI_YES
@@ -66,13 +67,14 @@ main(int argc, char *argv[])
    char       *conn_limit = NULL;
    bool        pwprompt = false;
    char       *newpassword = NULL;
-   /*  Tri-valued variables.  */
-   enum trivalue   createdb = TRI_DEFAULT,
-                   superuser = TRI_DEFAULT,
-                   createrole = TRI_DEFAULT,
-                   inherit = TRI_DEFAULT,
-                   login = TRI_DEFAULT,
-                   encrypted = TRI_DEFAULT;
+
+   /* Tri-valued variables.  */
+   enum trivalue createdb = TRI_DEFAULT,
+               superuser = TRI_DEFAULT,
+               createrole = TRI_DEFAULT,
+               inherit = TRI_DEFAULT,
+               login = TRI_DEFAULT,
+               encrypted = TRI_DEFAULT;
 
    PQExpBufferData sql;
 
index 8bdb030c208ad6ad93d88f8b1509dd8c678e3042..7035635e68650b6993c1abdd4461fa34749d4789 100644 (file)
@@ -1,9 +1,9 @@
 /*--------------------------------------------------------------------------
  * gin.h
- *    header file for postgres inverted index access method implementation.
+ *   header file for postgres inverted index access method implementation.
  *
- *  Copyright (c) 2006, PostgreSQL Global Development Group
- *  $PostgreSQL: pgsql/src/include/access/gin.h,v 1.7 2006/09/10 20:14:20 tgl Exp $
+ * Copyright (c) 2006, PostgreSQL Global Development Group
+ * $PostgreSQL: pgsql/src/include/access/gin.h,v 1.8 2006/10/04 00:30:06 momjian Exp $
  *--------------------------------------------------------------------------
  */
 
 /*
  * amproc indexes for inverted indexes.
  */
-#define GIN_COMPARE_PROC               1
-#define GIN_EXTRACTVALUE_PROC          2
-#define GIN_EXTRACTQUERY_PROC          3
-#define GIN_CONSISTENT_PROC            4
-#define GINNProcs                      4
+#define GIN_COMPARE_PROC              1
+#define GIN_EXTRACTVALUE_PROC         2
+#define GIN_EXTRACTQUERY_PROC         3
+#define GIN_CONSISTENT_PROC               4
+#define GINNProcs                     4
 
 typedef XLogRecPtr GinNSN;
 
 /*
  * Page opaque data in a inverted index page.
  */
-typedef struct GinPageOpaqueData {
-   uint16          flags;
-   OffsetNumber    maxoff;     /* number entries on GIN_DATA page:
-                              number of heap ItemPointer on GIN_DATA|GIN_LEAF page
-                              and number of records on GIN_DATA & ~GIN_LEAF page
-                            */
-   BlockNumber rightlink;  
+typedef struct GinPageOpaqueData
+{
+   uint16      flags;
+   OffsetNumber maxoff;        /* number entries on GIN_DATA page: number of
+                                * heap ItemPointer on GIN_DATA|GIN_LEAF page
+                                * and number of records on GIN_DATA &
+                                * ~GIN_LEAF page */
+   BlockNumber rightlink;
 } GinPageOpaqueData;
 
 typedef GinPageOpaqueData *GinPageOpaque;
 
 #define GIN_ROOT_BLKNO (0)
 
-typedef struct {
-   BlockIdData child_blkno; /* use it instead of BlockNumber to
-                               save space on page */
-   ItemPointerData key;
+typedef struct
+{
+   BlockIdData child_blkno;    /* use it instead of BlockNumber to save space
+                                * on page */
+   ItemPointerData key;
 } PostingItem;
 
-#define    PostingItemGetBlockNumber(pointer) \
+#define PostingItemGetBlockNumber(pointer) \
    BlockIdGetBlockNumber(&(pointer)->child_blkno)
 
-#define    PostingItemSetBlockNumber(pointer, blockNumber) \
+#define PostingItemSetBlockNumber(pointer, blockNumber) \
    BlockIdSet(&((pointer)->child_blkno), (blockNumber))
 
 /*
  * Page opaque data in a inverted index page.
  */
-#define GIN_DATA          (1 << 0)
-#define GIN_LEAF          (1 << 1)
-#define GIN_DELETED       (1 << 2)
+#define GIN_DATA         (1 << 0)
+#define GIN_LEAF         (1 << 1)
+#define GIN_DELETED          (1 << 2)
 
 /*
- * Works on page 
+ * Works on page
  */
 #define GinPageGetOpaque(page) ( (GinPageOpaque) PageGetSpecialPointer(page) )
 
@@ -103,15 +105,15 @@ typedef struct {
 #define GinSetNPosting(itup,n) ItemPointerSetOffsetNumber(&(itup)->t_tid,(n))
 #define GIN_TREE_POSTING       ((OffsetNumber)0xffff)
 #define GinIsPostingTree(itup) ( GinGetNPosting(itup)==GIN_TREE_POSTING )
-#define GinSetPostingTree(itup, blkno) ( GinSetNPosting((itup),GIN_TREE_POSTING ), ItemPointerSetBlockNumber(&(itup)->t_tid, blkno) ) 
-#define GinGetPostingTree(itup)    GinItemPointerGetBlockNumber(&(itup)->t_tid) 
+#define GinSetPostingTree(itup, blkno) ( GinSetNPosting((itup),GIN_TREE_POSTING ), ItemPointerSetBlockNumber(&(itup)->t_tid, blkno) )
+#define GinGetPostingTree(itup) GinItemPointerGetBlockNumber(&(itup)->t_tid)
 
-#define GinGetOrigSizePosting(itup)    GinItemPointerGetBlockNumber(&(itup)->t_tid)
+#define GinGetOrigSizePosting(itup) GinItemPointerGetBlockNumber(&(itup)->t_tid)
 #define GinSetOrigSizePosting(itup,n)  ItemPointerSetBlockNumber(&(itup)->t_tid,(n))
 #define GinGetPosting(itup)            ( (ItemPointer)(( ((char*)(itup)) + SHORTALIGN(GinGetOrigSizePosting(itup)) )) )
 
 #define GinMaxItemSize \
-    ((BLCKSZ - SizeOfPageHeaderData - \
+   ((BLCKSZ - SizeOfPageHeaderData - \
        MAXALIGN(sizeof(GinPageOpaqueData))) / 3 - sizeof(ItemIdData))
 
 
@@ -121,8 +123,8 @@ typedef struct {
 #define GinDataPageGetData(page)   \
    (PageGetContents(page)+MAXALIGN(sizeof(ItemPointerData)))
 #define GinDataPageGetRightBound(page) ((ItemPointer)PageGetContents(page))
-#define GinSizeOfItem(page)    ( (GinPageIsLeaf(page)) ? sizeof(ItemPointerData) : sizeof(PostingItem) )
-#define GinDataPageGetItem(page,i) ( GinDataPageGetData(page) + ((i)-1) * GinSizeOfItem(page) ) 
+#define GinSizeOfItem(page) ( (GinPageIsLeaf(page)) ? sizeof(ItemPointerData) : sizeof(PostingItem) )
+#define GinDataPageGetItem(page,i) ( GinDataPageGetData(page) + ((i)-1) * GinSizeOfItem(page) )
 
 #define GinDataPageGetFreeSpace(page)  \
    ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GinPageOpaqueData)) - \
@@ -131,11 +133,12 @@ typedef struct {
 
 
 
-#define GIN_UNLOCK     BUFFER_LOCK_UNLOCK
-#define GIN_SHARE      BUFFER_LOCK_SHARE
+#define GIN_UNLOCK BUFFER_LOCK_UNLOCK
+#define GIN_SHARE  BUFFER_LOCK_SHARE
 #define GIN_EXCLUSIVE  BUFFER_LOCK_EXCLUSIVE
 
-typedef struct GinState {
+typedef struct GinState
+{
    FmgrInfo    compareFn;
    FmgrInfo    extractValueFn;
    FmgrInfo    extractQueryFn;
@@ -150,80 +153,88 @@ typedef struct GinState {
 
 #define XLOG_GIN_CREATE_PTREE  0x10
 
-typedef struct ginxlogCreatePostingTree {
-    RelFileNode    node;
-   BlockNumber     blkno;
-   uint32          nitem;
+typedef struct ginxlogCreatePostingTree
+{
+   RelFileNode node;
+   BlockNumber blkno;
+   uint32      nitem;
    /* follows list of heap's ItemPointer */
 } ginxlogCreatePostingTree;
 
 #define XLOG_GIN_INSERT  0x20
 
-typedef struct ginxlogInsert {
-   RelFileNode     node;
-   BlockNumber     blkno;
-   BlockNumber     updateBlkno;
-   OffsetNumber    offset;
-   bool            isDelete;
-   bool            isData;
-   bool            isLeaf;
-   OffsetNumber    nitem;  
-
-   /* follows: tuples or ItemPointerData or PostingItem or list of ItemPointerData*/
+typedef struct ginxlogInsert
+{
+   RelFileNode node;
+   BlockNumber blkno;
+   BlockNumber updateBlkno;
+   OffsetNumber offset;
+   bool        isDelete;
+   bool        isData;
+   bool        isLeaf;
+   OffsetNumber nitem;
+
+   /*
+    * follows: tuples or ItemPointerData or PostingItem or list of
+    * ItemPointerData
+    */
 } ginxlogInsert;
 
-#define XLOG_GIN_SPLIT  0x30
+#define XLOG_GIN_SPLIT 0x30
 
-typedef struct ginxlogSplit {
-   RelFileNode     node;
-   BlockNumber     lblkno;
-   BlockNumber     rootBlkno;
-   BlockNumber     rblkno;
-   BlockNumber     rrlink;
-   OffsetNumber    separator;
-   OffsetNumber    nitem;
+typedef struct ginxlogSplit
+{
+   RelFileNode node;
+   BlockNumber lblkno;
+   BlockNumber rootBlkno;
+   BlockNumber rblkno;
+   BlockNumber rrlink;
+   OffsetNumber separator;
+   OffsetNumber nitem;
 
-   bool            isData;
-   bool            isLeaf;
-   bool            isRootSplit;
+   bool        isData;
+   bool        isLeaf;
+   bool        isRootSplit;
 
-   BlockNumber     leftChildBlkno;
-   BlockNumber     updateBlkno;
+   BlockNumber leftChildBlkno;
+   BlockNumber updateBlkno;
 
-   ItemPointerData rightbound; /* used only in posting tree */
+   ItemPointerData rightbound; /* used only in posting tree */
    /* follows: list of tuple or ItemPointerData or PostingItem */
 } ginxlogSplit;
 
-#define    XLOG_GIN_VACUUM_PAGE    0x40
+#define XLOG_GIN_VACUUM_PAGE   0x40
 
-typedef struct ginxlogVacuumPage {
-   RelFileNode     node;
-   BlockNumber     blkno;
-   OffsetNumber    nitem;
+typedef struct ginxlogVacuumPage
+{
+   RelFileNode node;
+   BlockNumber blkno;
+   OffsetNumber nitem;
    /* follows content of page */
 } ginxlogVacuumPage;
 
-#define XLOG_GIN_DELETE_PAGE   0x50 
+#define XLOG_GIN_DELETE_PAGE   0x50
 
-typedef struct ginxlogDeletePage {
-   RelFileNode     node;
-   BlockNumber     blkno;
-   BlockNumber     parentBlkno;
-   OffsetNumber    parentOffset;
-   BlockNumber     leftBlkno;
-   BlockNumber     rightLink;
+typedef struct ginxlogDeletePage
+{
+   RelFileNode node;
+   BlockNumber blkno;
+   BlockNumber parentBlkno;
+   OffsetNumber parentOffset;
+   BlockNumber leftBlkno;
+   BlockNumber rightLink;
 } ginxlogDeletePage;
 
 /* ginutil.c */
 extern Datum ginoptions(PG_FUNCTION_ARGS);
-extern void initGinState( GinState *state, Relation index );
+extern void initGinState(GinState *state, Relation index);
 extern Buffer GinNewBuffer(Relation index);
 extern void GinInitBuffer(Buffer b, uint32 f);
 extern void GinInitPage(Page page, uint32 f, Size pageSize);
-extern int compareEntries(GinState *ginstate, Datum a, Datum b); 
-extern DatumextractEntriesS(GinState *ginstate, Datum value, uint32 *nentries);
-extern DatumextractEntriesSU(GinState *ginstate, Datum value, uint32 *nentries);
-extern Page GinPageGetCopyPage( Page page );
+extern int compareEntries(GinState *ginstate, Datum a, Datum b);
+extern Datum *extractEntriesS(GinState *ginstate, Datum value, uint32 *nentries);
+extern Datum *extractEntriesSU(GinState *ginstate, Datum value, uint32 *nentries);
+extern Page GinPageGetCopyPage(Page page);
 
 /* gininsert.c */
 extern Datum ginbuild(PG_FUNCTION_ARGS);
@@ -238,147 +249,157 @@ extern bool gin_safe_restartpoint(void);
 
 /* ginbtree.c */
 
-typedef struct GinBtreeStack {
-   BlockNumber         blkno;
-   Buffer              buffer;
-   OffsetNumber        off;
-   /* predictNumber contains prediction number of pages on current level */ 
-   uint32              predictNumber;
+typedef struct GinBtreeStack
+{
+   BlockNumber blkno;
+   Buffer      buffer;
+   OffsetNumber off;
+   /* predictNumber contains prediction number of pages on current level */
+   uint32      predictNumber;
    struct GinBtreeStack *parent;
 } GinBtreeStack;
 
 typedef struct GinBtreeData *GinBtree;
 
-typedef struct GinBtreeData {
+typedef struct GinBtreeData
+{
    /* search methods */
-   BlockNumber     (*findChildPage)(GinBtree, GinBtreeStack *);
-   bool            (*isMoveRight)(GinBtree, Page);
-   bool            (*findItem)(GinBtree, GinBtreeStack *);
+   BlockNumber (*findChildPage) (GinBtree, GinBtreeStack *);
+   bool        (*isMoveRight) (GinBtree, Page);
+   bool        (*findItem) (GinBtree, GinBtreeStack *);
 
    /* insert methods */
-   OffsetNumber    (*findChildPtr)(GinBtree, Page, BlockNumber, OffsetNumber);
-   BlockNumber     (*getLeftMostPage)(GinBtree, Page);
-   bool            (*isEnoughSpace)(GinBtree, Buffer, OffsetNumber);
-   void            (*placeToPage)(GinBtree, Buffer, OffsetNumber, XLogRecData**);
-   Page            (*splitPage)(GinBtree, Buffer, Buffer, OffsetNumber, XLogRecData**);
-   void            (*fillRoot)(GinBtree, Buffer, Buffer, Buffer);
+   OffsetNumber (*findChildPtr) (GinBtree, Page, BlockNumber, OffsetNumber);
+   BlockNumber (*getLeftMostPage) (GinBtree, Page);
+   bool        (*isEnoughSpace) (GinBtree, Buffer, OffsetNumber);
+   void        (*placeToPage) (GinBtree, Buffer, OffsetNumber, XLogRecData **);
+   Page        (*splitPage) (GinBtree, Buffer, Buffer, OffsetNumber, XLogRecData **);
+   void        (*fillRoot) (GinBtree, Buffer, Buffer, Buffer);
 
-   bool            searchMode;
+   bool        searchMode;
 
-   Relation        index;
-   GinState        *ginstate;
-   bool            fullScan;
-   bool            isBuild;
+   Relation    index;
+   GinState   *ginstate;
+   bool        fullScan;
+   bool        isBuild;
 
-   BlockNumber     rightblkno;
+   BlockNumber rightblkno;
 
    /* Entry options */
-   Datum           entryValue;
-   IndexTuple      entry;
-   bool            isDelete;
+   Datum       entryValue;
+   IndexTuple  entry;
+   bool        isDelete;
 
    /* Data (posting tree) option */
-   ItemPointerData *items;
-   uint32          nitem;
-   uint32          curitem;
+   ItemPointerData *items;
+   uint32      nitem;
+   uint32      curitem;
 
-   PostingItem     pitem;
+   PostingItem pitem;
 } GinBtreeData;
 
-extern GinBtreeStackginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno);
-extern GinBtreeStack* ginFindLeafPage(GinBtree btree, GinBtreeStack *stack );
-extern void freeGinBtreeStack( GinBtreeStack *stack );
+extern GinBtreeStack *ginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno);
+extern GinBtreeStack *ginFindLeafPage(GinBtree btree, GinBtreeStack *stack);
+extern void freeGinBtreeStack(GinBtreeStack *stack);
 extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack);
-extern void findParents( GinBtree btree, GinBtreeStack *stack, BlockNumber rootBlkno);
+extern void findParents(GinBtree btree, GinBtreeStack *stack, BlockNumber rootBlkno);
 
 /* ginentrypage.c */
 extern IndexTuple GinFormTuple(GinState *ginstate, Datum key, ItemPointerData *ipd, uint32 nipd);
 extern Datum ginGetHighKey(GinState *ginstate, Page page);
-extern void prepareEntryScan( GinBtree btree, Relation index, Datum value, GinState *ginstate);
+extern void prepareEntryScan(GinBtree btree, Relation index, Datum value, GinState *ginstate);
 extern void entryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
 extern IndexTuple ginPageGetLinkItup(Buffer buf);
 
 /* gindatapage.c */
-extern int compareItemPointers( ItemPointer a, ItemPointer b );
-extern void  MergeItemPointers(
-               ItemPointerData *dst, 
-               ItemPointerData *a, uint32 na, 
-               ItemPointerData *b, uint32 nb
-           );
-
-extern void GinDataPageAddItem( Page page, void *data, OffsetNumber offset );
+extern int compareItemPointers(ItemPointer a, ItemPointer b);
+extern void
+MergeItemPointers(
+                 ItemPointerData *dst,
+                 ItemPointerData *a, uint32 na,
+                 ItemPointerData *b, uint32 nb
+);
+
+extern void GinDataPageAddItem(Page page, void *data, OffsetNumber offset);
 extern void PageDeletePostingItem(Page page, OffsetNumber offset);
 
-typedef struct {
-   GinBtreeData    btree;
-   GinBtreeStack   *stack;
+typedef struct
+{
+   GinBtreeData btree;
+   GinBtreeStack *stack;
 } GinPostingTreeScan;
 
-extern GinPostingTreeScan* prepareScanPostingTree( Relation index, 
-           BlockNumber rootBlkno, bool searchMode);
-extern void insertItemPointer(GinPostingTreeScan *gdi, 
-           ItemPointerData *items, uint32 nitem);
-extern Buffer scanBeginPostingTree( GinPostingTreeScan *gdi );
+extern GinPostingTreeScan *prepareScanPostingTree(Relation index,
+                      BlockNumber rootBlkno, bool searchMode);
+extern void insertItemPointer(GinPostingTreeScan *gdi,
+                 ItemPointerData *items, uint32 nitem);
+extern Buffer scanBeginPostingTree(GinPostingTreeScan *gdi);
 extern void dataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
-extern void prepareDataScan( GinBtree btree, Relation index);
+extern void prepareDataScan(GinBtree btree, Relation index);
+
 /* ginscan.c */
 
 typedef struct GinScanEntryData *GinScanEntry;
 
-typedef struct GinScanEntryData {
+typedef struct GinScanEntryData
+{
    /* link to the equals entry in current scan key */
-   GinScanEntry    master; 
+   GinScanEntry master;
 
-   /* link to values reported to consistentFn,
-      points to GinScanKey->entryRes[i]*/ 
-   bool            *pval; 
+   /*
+    * link to values reported to consistentFn, points to
+    * GinScanKey->entryRes[i]
+    */
+   bool       *pval;
 
-   /* entry, got from extractQueryFn */ 
-   Datum           entry;
+   /* entry, got from extractQueryFn */
+   Datum       entry;
 
    /* current ItemPointer to heap, its offset in buffer and buffer */
-   ItemPointerData     curItem;
-   OffsetNumber        offset;
-   Buffer              buffer;
+   ItemPointerData curItem;
+   OffsetNumber offset;
+   Buffer      buffer;
 
    /* in case of Posing list */
-   ItemPointerData     *list;
-   uint32              nlist;
+   ItemPointerData *list;
+   uint32      nlist;
 
-   bool                isFinished;
-   bool                reduceResult;
-   uint32              predictNumberResult;
+   bool        isFinished;
+   bool        reduceResult;
+   uint32      predictNumberResult;
 } GinScanEntryData;
 
-typedef struct GinScanKeyData {
-   /* Number of entries in query (got by extractQueryFn) */ 
-   uint32          nentries;
+typedef struct GinScanKeyData
+{
+   /* Number of entries in query (got by extractQueryFn) */
+   uint32      nentries;
 
    /* array of ItemPointer result, reported to consistentFn */
-   bool            *entryRes;
+   bool       *entryRes;
 
-   /* array of scans per entry */ 
-   GinScanEntry    scanEntry;
+   /* array of scans per entry */
+   GinScanEntry scanEntry;
 
    /* for calling consistentFn(GinScanKey->entryRes, strategy, query) */
-   StrategyNumber  strategy;
-   Datum           query;
+   StrategyNumber strategy;
+   Datum       query;
 
-   ItemPointerData curItem;
-   bool            firstCall;
-   bool            isFinished;
+   ItemPointerData curItem;
+   bool        firstCall;
+   bool        isFinished;
 } GinScanKeyData;
 
-typedef GinScanKeyData *GinScanKey; 
+typedef GinScanKeyData *GinScanKey;
 
-typedef struct GinScanOpaqueData {
-   MemoryContext   tempCtx;
-   GinState        ginstate;
+typedef struct GinScanOpaqueData
+{
+   MemoryContext tempCtx;
+   GinState    ginstate;
 
-   GinScanKey      keys;
-   uint32          nkeys;
+   GinScanKey  keys;
+   uint32      nkeys;
 
-   GinScanKey      markPos;
+   GinScanKey  markPos;
 } GinScanOpaqueData;
 
 typedef GinScanOpaqueData *GinScanOpaque;
@@ -391,12 +412,12 @@ extern Datum ginrestrpos(PG_FUNCTION_ARGS);
 extern void newScanKey(IndexScanDesc scan);
 
 /* ginget.c */
-extern DLLIMPORT int   GinFuzzySearchLimit;
+extern DLLIMPORT int GinFuzzySearchLimit;
 
-#define ItemPointerSetMax(p)   ItemPointerSet( (p), (BlockNumber)0xffffffff, (OffsetNumber)0xffff ) 
-#define ItemPointerIsMax(p)    ( ItemPointerGetBlockNumber(p) == (BlockNumber)0xffffffff && ItemPointerGetOffsetNumber(p) == (OffsetNumber)0xffff ) 
-#define ItemPointerSetMin(p)   ItemPointerSet( (p), (BlockNumber)0, (OffsetNumber)0) 
-#define ItemPointerIsMin(p)    ( ItemPointerGetBlockNumber(p) == (BlockNumber)0 && ItemPointerGetOffsetNumber(p) == (OffsetNumber)0 ) 
+#define ItemPointerSetMax(p)   ItemPointerSet( (p), (BlockNumber)0xffffffff, (OffsetNumber)0xffff )
+#define ItemPointerIsMax(p) ( ItemPointerGetBlockNumber(p) == (BlockNumber)0xffffffff && ItemPointerGetOffsetNumber(p) == (OffsetNumber)0xffff )
+#define ItemPointerSetMin(p)   ItemPointerSet( (p), (BlockNumber)0, (OffsetNumber)0)
+#define ItemPointerIsMin(p) ( ItemPointerGetBlockNumber(p) == (BlockNumber)0 && ItemPointerGetOffsetNumber(p) == (OffsetNumber)0 )
 
 extern Datum gingetmulti(PG_FUNCTION_ARGS);
 extern Datum gingettuple(PG_FUNCTION_ARGS);
@@ -410,31 +431,33 @@ extern Datum ginarrayextract(PG_FUNCTION_ARGS);
 extern Datum ginarrayconsistent(PG_FUNCTION_ARGS);
 
 /* ginbulk.c */
-typedef struct EntryAccumulator {
-    Datum       value;
-   uint32      length;
-   uint32      number;
+typedef struct EntryAccumulator
+{
+   Datum       value;
+   uint32      length;
+   uint32      number;
    ItemPointerData *list;
    bool        shouldSort;
-   struct EntryAccumulator *left;
-   struct EntryAccumulator *right;
+   struct EntryAccumulator *left;
+   struct EntryAccumulator *right;
 } EntryAccumulator;
 
-typedef struct {
-   GinState    *ginstate;
-    EntryAccumulator    *entries;
+typedef struct
+{
+   GinState   *ginstate;
+   EntryAccumulator *entries;
    uint32      maxdepth;
-   EntryAccumulator    **stack;
-   uint32              stackpos;
-   uint32      allocatedMemory;
+   EntryAccumulator **stack;
+   uint32      stackpos;
+   uint32      allocatedMemory;
 
-   uint32              length;
-   EntryAccumulator    *entryallocator;
+   uint32      length;
+   EntryAccumulator *entryallocator;
 } BuildAccumulator;
 
 extern void ginInitBA(BuildAccumulator *accum);
-extern void ginInsertRecordBA( BuildAccumulator *accum, 
-               ItemPointer heapptr, Datum *entries, uint32 nentry );
-extern ItemPointerDataginGetEntry(BuildAccumulator *accum, Datum *entry, uint32 *n);
+extern void ginInsertRecordBA(BuildAccumulator *accum,
+                 ItemPointer heapptr, Datum *entries, uint32 nentry);
+extern ItemPointerData *ginGetEntry(BuildAccumulator *accum, Datum *entry, uint32 *n);
 
 #endif
index 1b3c042e955772cc3f250966c83de28ac1622359..1502af67ec08063088ea6e3c2236fa9b3a68cd73 100644 (file)
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.55 2006/09/10 00:29:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.56 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -80,7 +80,7 @@ typedef GISTPageOpaqueData *GISTPageOpaque;
  * PickSplit should check spl_(r|l)datum_exists. If it is 'true',
  * that corresponding spl_(r|l)datum already defined and
  * PickSplit should use that value. PickSplit should always set
- * spl_(r|l)datum_exists to false: GiST will check value to 
+ * spl_(r|l)datum_exists to false: GiST will check value to
  * control supportng this feature by PickSplit...
  */
 typedef struct GIST_SPLITVEC
@@ -88,12 +88,12 @@ typedef struct GIST_SPLITVEC
    OffsetNumber *spl_left;     /* array of entries that go left */
    int         spl_nleft;      /* size of this array */
    Datum       spl_ldatum;     /* Union of keys in spl_left */
-   bool        spl_ldatum_exists;  /* true, if spl_ldatum already exists. */
+   bool        spl_ldatum_exists;      /* true, if spl_ldatum already exists. */
 
    OffsetNumber *spl_right;    /* array of entries that go right */
    int         spl_nright;     /* size of the array */
    Datum       spl_rdatum;     /* Union of keys in spl_right */
-   bool        spl_rdatum_exists;  /* true, if spl_rdatum already exists. */
+   bool        spl_rdatum_exists;      /* true, if spl_rdatum already exists. */
 } GIST_SPLITVEC;
 
 /*
index de917c8b83453e91d5ddb666e0b2e619e8543e06..0c17fd4211750f8f9235d8357883bdce0cd454af 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.23 2006/08/07 16:57:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.24 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -144,7 +144,7 @@ typedef struct SplitedPageLayout
    gistxlogPage block;
    IndexTupleData *list;
    int         lenlist;
-   IndexTuple  itup;  /* union key for page */
+   IndexTuple  itup;           /* union key for page */
    Page        page;           /* to operate */
    Buffer      buffer;         /* to write after all proceed */
 
@@ -180,19 +180,22 @@ typedef struct GISTInsertStack
    struct GISTInsertStack *next;
 } GISTInsertStack;
 
-typedef struct GistSplitVector {
-   GIST_SPLITVEC   splitVector;  /* to/from PickSplit method */
+typedef struct GistSplitVector
+{
+   GIST_SPLITVEC splitVector;  /* to/from PickSplit method */
 
-   Datum       spl_lattr[INDEX_MAX_KEYS];      /* Union of subkeys in spl_left */
-   bool        spl_lisnull[INDEX_MAX_KEYS];
-   bool        spl_leftvalid;
+   Datum       spl_lattr[INDEX_MAX_KEYS];      /* Union of subkeys in
+                                                * spl_left */
+   bool        spl_lisnull[INDEX_MAX_KEYS];
+   bool        spl_leftvalid;
 
-   Datum       spl_rattr[INDEX_MAX_KEYS];      /* Union of subkeys in spl_right */
-   bool        spl_risnull[INDEX_MAX_KEYS];
-   bool        spl_rightvalid;
+   Datum       spl_rattr[INDEX_MAX_KEYS];      /* Union of subkeys in
+                                                * spl_right */
+   bool        spl_risnull[INDEX_MAX_KEYS];
+   bool        spl_rightvalid;
 
-   bool        *spl_equiv; /* equivalent tuples which can be freely 
-                            * distributed between left and right pages */ 
+   bool       *spl_equiv;      /* equivalent tuples which can be freely
+                                * distributed between left and right pages */
 } GistSplitVector;
 
 #define XLogRecPtrIsInvalid( r )   ( (r).xlogid == 0 && (r).xrecoff == 0 )
@@ -255,7 +258,7 @@ extern bool gist_safe_restartpoint(void);
 extern IndexTuple gist_form_invalid_tuple(BlockNumber blkno);
 
 extern XLogRecData *formUpdateRdata(RelFileNode node, Buffer buffer,
-               OffsetNumber *todelete, int ntodelete, 
+               OffsetNumber *todelete, int ntodelete,
                IndexTuple *itup, int ituplen, ItemPointer key);
 
 extern XLogRecData *formSplitRdata(RelFileNode node,
@@ -271,7 +274,7 @@ extern Datum gistgetmulti(PG_FUNCTION_ARGS);
 /* gistutil.c */
 
 #define GiSTPageSize   \
-    ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) ) 
+   ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GISTPageOpaqueData)) )
 
 #define GIST_MIN_FILLFACTOR            10
 #define GIST_DEFAULT_FILLFACTOR        90
@@ -287,7 +290,7 @@ extern IndexTuple *gistextractpage(Page page, int *len /* out */ );
 extern IndexTuple *gistjoinvector(
               IndexTuple *itvec, int *len,
               IndexTuple *additvec, int addlen);
-extern IndexTupleDatagistfillitupvec(IndexTuple *vec, int veclen, int *memlen);
+extern IndexTupleData *gistfillitupvec(IndexTuple *vec, int veclen, int *memlen);
 
 extern IndexTuple gistunion(Relation r, IndexTuple *itvec,
          int len, GISTSTATE *giststate);
@@ -312,27 +315,27 @@ extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
               bool l, bool isNull);
 
 extern float gistpenalty(GISTSTATE *giststate, int attno,
-                       GISTENTRY *key1, bool isNull1,
-                       GISTENTRY *key2, bool isNull2);
+           GISTENTRY *key1, bool isNull1,
+           GISTENTRY *key2, bool isNull2);
 extern bool gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, int startkey,
-                    Datum *attr, bool *isnull );
+                  Datum *attr, bool *isnull);
 extern bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b);
 extern void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
-               OffsetNumber o, GISTENTRY *attdata, bool *isnull);
+                 OffsetNumber o, GISTENTRY *attdata, bool *isnull);
 
-extern void gistMakeUnionKey( GISTSTATE *giststate, int attno,
-                    GISTENTRY   *entry1, bool isnull1,
-                   GISTENTRY   *entry2, bool isnull2,
-                   Datum   *dst, bool *dstisnull );
+extern void gistMakeUnionKey(GISTSTATE *giststate, int attno,
+                GISTENTRY *entry1, bool isnull1,
+                GISTENTRY *entry2, bool isnull2,
+                Datum *dst, bool *dstisnull);
 
 /* gistvacuum.c */
 extern Datum gistbulkdelete(PG_FUNCTION_ARGS);
 extern Datum gistvacuumcleanup(PG_FUNCTION_ARGS);
 
 /* gistsplit.c */
-extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup, 
-                           int len, GISTSTATE *giststate,
-                           GistSplitVector *v, GistEntryVector *entryvec, 
-                           int attno);
+extern void gistSplitByKey(Relation r, Page page, IndexTuple *itup,
+              int len, GISTSTATE *giststate,
+              GistSplitVector *v, GistEntryVector *entryvec,
+              int attno);
 
 #endif   /* GIST_PRIVATE_H */
index 772a6588faefbeb7d4ba36527c0f97ea51ed2b73..b2dd0f3390d3412413f0f70c92403a08ed855a22 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.115 2006/08/18 16:09:10 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.116 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -220,7 +220,7 @@ extern void heap_deformtuple(HeapTuple tuple, TupleDesc tupleDesc,
                 Datum *values, char *nulls);
 extern void heap_freetuple(HeapTuple htup);
 extern MinimalTuple heap_form_minimal_tuple(TupleDesc tupleDescriptor,
-               Datum *values, bool *isnull);
+                       Datum *values, bool *isnull);
 extern void heap_free_minimal_tuple(MinimalTuple mtup);
 extern MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup);
 extern HeapTuple heap_tuple_from_minimal_tuple(MinimalTuple mtup);
index 8cb8f8925f04b965e01dd3db6bf698aa0715c6ed..d93c27a26dd23d6b232bc89ed06417bb8c58260b 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/hio.h,v 1.32 2006/07/13 17:47:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/hio.h,v 1.33 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,6 +21,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 */
index caac3229f35c8ac7864aa487cd2ac342d5bdaf45..edfce82bc044dfd1bb65cbfee2959293c09a4589 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.85 2006/07/13 17:47:01 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.86 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -356,7 +356,7 @@ do { \
  * MinimalTuple is an alternate representation that is used for transient
  * tuples inside the executor, in places where transaction status information
  * is not required, the tuple rowtype is known, and shaving off a few bytes
- * is worthwhile because we need to store many tuples.  The representation
+ * is worthwhile because we need to store many tuples. The representation
  * is chosen so that tuple access routines can work with either full or
  * minimal tuples via a HeapTupleData pointer structure.  The access routines
  * see no difference, except that they must not access the transaction status
@@ -367,7 +367,7 @@ do { \
  * and thereby prevent accidental use of the nonexistent fields.
  *
  * MinimalTupleData contains a length word, some padding, and fields matching
- * HeapTupleHeaderData beginning with t_natts.  The padding is chosen so that
+ * HeapTupleHeaderData beginning with t_natts. The padding is chosen so that
  * offsetof(t_natts) is the same modulo MAXIMUM_ALIGNOF in both structs.
  * This makes data alignment rules equivalent in both cases.
  *
@@ -431,7 +431,7 @@ typedef MinimalTupleData *MinimalTuple;
  *  limited contexts where the code knows that case #1 will never apply.)
  *
  * * Separately allocated minimal tuple: t_data points MINIMAL_TUPLE_OFFSET
- *  bytes before the start of a MinimalTuple.  As with the previous case,
+ *  bytes before the start of a MinimalTuple.  As with the previous case,
  *  this can't be told apart from case #1 by inspection; code setting up
  *  or destroying this representation has to know what it's doing.
  *
index 33d295a71b24b034e26d3117f567e61e9704780d..3350a057b2fd4b0f54d69e929f96b4c7e2ac7916 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.104 2006/08/24 01:18:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.105 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,10 +35,10 @@ typedef uint16 BTCycleId;
  * and status.  If the page is deleted, we replace the level with the
  * next-transaction-ID value indicating when it is safe to reclaim the page.
  *
- * We also store a "vacuum cycle ID".  When a page is split while VACUUM is
+ * We also store a "vacuum cycle ID".  When a page is split while VACUUM is
  * processing the index, a nonzero value associated with the VACUUM run is
- * stored into both halves of the split page.  (If VACUUM is not running,
- * both pages receive zero cycleids.)  This allows VACUUM to detect whether
+ * stored into both halves of the split page.  (If VACUUM is not running,
+ * both pages receive zero cycleids.)  This allows VACUUM to detect whether
  * a page was split since it started, with a small probability of false match
  * if the page was last split some exact multiple of 65536 VACUUMs ago.
  * Also, during a split, the BTP_SPLIT_END flag is cleared in the left
@@ -71,7 +71,7 @@ typedef BTPageOpaqueData *BTPageOpaque;
 #define BTP_META       (1 << 3)    /* meta-page */
 #define BTP_HALF_DEAD  (1 << 4)    /* empty, but still in tree */
 #define BTP_SPLIT_END  (1 << 5)    /* rightmost page of split group */
-#define BTP_HAS_GARBAGE    (1 << 6)    /* page has LP_DELETEd tuples */
+#define BTP_HAS_GARBAGE (1 << 6)   /* page has LP_DELETEd tuples */
 
 
 /*
@@ -140,7 +140,7 @@ typedef struct BTMetaPageData
    ( (i1).ip_blkid.bi_hi == (i2).ip_blkid.bi_hi && \
      (i1).ip_blkid.bi_lo == (i2).ip_blkid.bi_lo && \
      (i1).ip_posid == (i2).ip_posid )
-#define BTEntrySame(i1, i2)    \
+#define BTEntrySame(i1, i2) \
    BTTidSame((i1)->t_tid, (i2)->t_tid)
 
 
@@ -203,7 +203,7 @@ typedef struct BTMetaPageData
 #define XLOG_BTREE_SPLIT_R_ROOT 0x60   /* as above, new item on right */
 #define XLOG_BTREE_DELETE      0x70    /* delete leaf index tuple */
 #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 */
 
 /*
@@ -368,17 +368,17 @@ typedef BTStackData *BTStack;
  * BTScanOpaqueData is the btree-private state needed for an indexscan.
  * This consists of preprocessed scan keys (see _bt_preprocess_keys() for
  * details of the preprocessing), information about the current location
- * of the scan, and information about the marked location, if any.  (We use
+ * of the scan, and information about the marked location, if any. (We use
  * BTScanPosData to represent the data needed for each of current and marked
- * locations.)  In addition we can remember some known-killed index entries
+ * locations.) In addition we can remember some known-killed index entries
  * that must be marked before we can move off the current page.
  *
  * Index scans work a page at a time: we pin and read-lock the page, identify
  * all the matching items on the page and save them in BTScanPosData, then
  * release the read-lock while returning the items to the caller for
- * processing.  This approach minimizes lock/unlock traffic.  Note that we
+ * processing. This approach minimizes lock/unlock traffic.  Note that we
  * keep the pin on the index page until the caller is done with all the items
- * (this is needed for VACUUM synchronization, see nbtree/README).  When we
+ * (this is needed for VACUUM synchronization, see nbtree/README). When we
  * are ready to step to the next page, if the caller has told us any of the
  * items were killed, we re-lock the page to mark them killed, then unlock.
  * Finally we drop the pin and step to the next page in the appropriate
@@ -420,7 +420,7 @@ typedef struct BTScanPosData
    int         lastItem;       /* last valid index in items[] */
    int         itemIndex;      /* current index in items[] */
 
-   BTScanPosItem items[MaxIndexTuplesPerPage];     /* MUST BE LAST */
+   BTScanPosItem items[MaxIndexTuplesPerPage]; /* MUST BE LAST */
 } BTScanPosData;
 
 typedef BTScanPosData *BTScanPos;
@@ -439,11 +439,11 @@ typedef struct BTScanOpaqueData
    int         numKilled;      /* number of currently stored items */
 
    /*
-    * If the marked position is on the same page as current position,
-    * we don't use markPos, but just keep the marked itemIndex in
-    * markItemIndex (all the rest of currPos is valid for the mark position).
-    * Hence, to determine if there is a mark, first look at markItemIndex,
-    * then at markPos.
+    * If the marked position is on the same page as current position, we
+    * don't use markPos, but just keep the marked itemIndex in markItemIndex
+    * (all the rest of currPos is valid for the mark position). Hence, to
+    * determine if there is a mark, first look at markItemIndex, then at
+    * markPos.
     */
    int         markItemIndex;  /* itemIndex, or -1 if not valid */
 
@@ -457,8 +457,8 @@ typedef BTScanOpaqueData *BTScanOpaque;
 /*
  * We use these private sk_flags bits in preprocessed scan keys
  */
-#define SK_BT_REQFWD   0x00010000  /* required to continue forward scan */
-#define SK_BT_REQBKWD  0x00020000  /* required to continue backward scan */
+#define SK_BT_REQFWD   0x00010000      /* required to continue forward scan */
+#define SK_BT_REQBKWD  0x00020000      /* required to continue backward scan */
 
 
 /*
@@ -528,8 +528,8 @@ extern void _bt_freeskey(ScanKey skey);
 extern void _bt_freestack(BTStack stack);
 extern void _bt_preprocess_keys(IndexScanDesc scan);
 extern bool _bt_checkkeys(IndexScanDesc scan,
-                         Page page, OffsetNumber offnum,
-                         ScanDirection dir, bool *continuescan);
+             Page page, OffsetNumber offnum,
+             ScanDirection dir, bool *continuescan);
 extern void _bt_killitems(IndexScanDesc scan, bool haveLock);
 extern BTCycleId _bt_vacuum_cycleid(Relation rel);
 extern BTCycleId _bt_start_vacuum(Relation rel);
index 82474f4707a737823b12581338593f2f9c4593b1..2664069767747364b896fcb4db450d65699e368c 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.1 2006/07/03 22:45:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.2 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "nodes/pg_list.h"
 
 extern Datum transformRelOptions(Datum oldOptions, List *defList,
-                                bool ignoreOids, bool isReset);
+                   bool ignoreOids, bool isReset);
 
 extern void parseRelOptions(Datum options, int numkeywords,
-                           const char * const *keywords,
-                           char **values, bool validate);
+               const char *const * keywords,
+               char **values, bool validate);
 
 extern bytea *default_reloptions(Datum reloptions, bool validate,
-                                int minFillfactor, int defaultFillfactor);
+                  int minFillfactor, int defaultFillfactor);
 
 extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate);
 
 extern bytea *index_reloptions(RegProcedure amoptions, Datum reloptions,
-                              bool validate);
+                bool validate);
 
 #endif   /* RELOPTIONS_H */
index d32ab6d524e0836e2af3381ab64b4d32d11890c3..45ac9b8265046b99addddf634ead61278b151f3e 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.49 2006/07/31 20:09:05 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.50 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,12 +27,12 @@ typedef struct HeapScanDescData
    int         rs_nkeys;       /* number of scan keys */
    ScanKey     rs_key;         /* array of scan key descriptors */
    BlockNumber rs_nblocks;     /* number of blocks to scan */
-   bool        rs_pageatatime; /* verify visibility page-at-a-time? */
+   bool        rs_pageatatime; /* verify visibility page-at-a-time? */
 
    /* scan current state */
    bool        rs_inited;      /* false = scan not init'd yet */
    HeapTupleData rs_ctup;      /* current tuple in scan, if any */
-   BlockNumber rs_cblock;      /* current block # in scan, if any */
+   BlockNumber rs_cblock;      /* current block # in scan, if any */
    Buffer      rs_cbuf;        /* current buffer in scan, if any */
    /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
    ItemPointerData rs_mctid;   /* marked scan position, if any */
index 7a846723df046693810ba4abac09aa5abb843ce4..d81b6fd9a9065d8c8e2430d2aeda0f892b38265b 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/skey.h,v 1.32 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/skey.h,v 1.33 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -89,7 +89,7 @@ typedef ScanKeyData *ScanKey;
  * must be sorted according to the leading column number.
  *
  * The subsidiary ScanKey array appears in logical column order of the row
- * comparison, which may be different from index column order.  The array
+ * comparison, which may be different from index column order. The array
  * elements are like a normal ScanKey array except that:
  *     sk_flags must include SK_ROW_MEMBER, plus SK_ROW_END in the last
  *             element (needed since row header does not include a count)
index 7836224db40a3acc2a6d8de849e06bea344672af..48576c2b41bef0ad06781c39c9db0c6959f25012 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/slru.h,v 1.18 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/slru.h,v 1.19 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -111,8 +111,8 @@ extern void SimpleLruInit(SlruCtl ctl, const char *name, int nslots,
              LWLockId ctllock, const char *subdir);
 extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
 extern int SimpleLruReadPage(SlruCtl ctl, int pageno, TransactionId xid);
-extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
-                                      TransactionId xid);
+extern int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int pageno,
+                          TransactionId xid);
 extern void SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata);
 extern void SimpleLruFlush(SlruCtl ctl, bool checkpoint);
 extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
index 035a0a85e528daf80743a6116ecc30e29ac7c648..cb1c375cff14f90a5d16541d4b3bd9d7e3385c9a 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/tupdesc.h,v 1.50 2006/06/16 18:42:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/tupdesc.h,v 1.51 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -104,7 +104,7 @@ extern void DecrTupleDescRefCount(TupleDesc tupdesc);
        if ((tupdesc)->tdrefcount >= 0) \
            DecrTupleDescRefCount(tupdesc); \
    } while (0)
-  
+
 extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
 
 extern void TupleDescInitEntry(TupleDesc desc,
index 773e85fbcdb3be92f6934603f9322f7b77c1a8f5..83feb38ad70c9ef1119607645214b2460d3b0a63 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.16 2006/08/17 23:04:08 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.17 2006/10/04 00:30:07 momjian Exp $
  */
 #ifndef XLOG_INTERNAL_H
 #define XLOG_INTERNAL_H
@@ -239,7 +239,7 @@ typedef struct RmgrData
 
 extern const RmgrData RmgrTable[];
 
-/* 
+/*
  * Exported to support xlog switching from bgwriter
  */
 extern time_t GetLastSegSwitchTime(void);
index 6713b6df6788c3265ba005469f5b1d1607293a90..8e3378d9a0bcae6eeea47c2b4d1b89a4f386031f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.43 2006/08/15 22:36:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.44 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,13 +51,13 @@ extern int  EnterString(char *str);
 extern void build_indices(void);
 
 extern void boot_get_type_io_data(Oid typid,
-                                 int16 *typlen,
-                                 bool *typbyval,
-                                 char *typalign,
-                                 char *typdelim,
-                                 Oid *typioparam,
-                                 Oid *typinput,
-                                 Oid *typoutput);
+                     int16 *typlen,
+                     bool *typbyval,
+                     char *typalign,
+                     char *typdelim,
+                     Oid *typioparam,
+                     Oid *typinput,
+                     Oid *typoutput);
 
 extern int boot_yyparse(void);
 
index db9983b4624d38688e13daae1ca58d53755476b4..a7281dab8290dde8fc65ac1a3c6ea5812a4522a1 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/c.h,v 1.213 2006/10/03 20:33:20 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/c.h,v 1.214 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -52,7 +52,8 @@
 
 #include "pg_config.h"
 #include "pg_config_manual.h"  /* must be after pg_config.h */
-#if !defined(WIN32) && !defined(__CYGWIN__) /* win32 will include further down */
+#if !defined(WIN32) && !defined(__CYGWIN__)        /* win32 will include further
+                                                * down */
 #include "pg_config_os.h"      /* must be before any system header files */
 #endif
 #include "postgres_ext.h"
@@ -470,7 +471,7 @@ typedef NameData *Name;
 
 /*
  * Support macros for escaping strings.  escape_backslash should be TRUE
- * if generating a non-standard-conforming string.  Prefixing a string
+ * if generating a non-standard-conforming string. Prefixing a string
  * with ESCAPE_STRING_SYNTAX guarantees it is non-standard-conforming.
  * Beware of multiple evaluation of the "ch" argument!
  */
index 243648b4aaed799c7b412c1b8187c595aa55f851..5e154aecc35b76b7ea0c7972fa4fdab718da4657 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.57 2006/07/28 18:33:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.58 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -145,9 +145,9 @@ DATA(insert ( 2147  int8inc_any     -               0       20      "0" ));
 DATA(insert ( 2803 int8inc         -               0       20      "0" ));
 
 /* var_pop */
-DATA(insert ( 2718 int8_accum  numeric_var_pop 0   1231    "{0,0,0}" ));
-DATA(insert ( 2719 int4_accum  numeric_var_pop 0   1231    "{0,0,0}" ));
-DATA(insert ( 2720 int2_accum  numeric_var_pop 0   1231    "{0,0,0}" ));
+DATA(insert ( 2718 int8_accum  numeric_var_pop 0   1231    "{0,0,0}" ));
+DATA(insert ( 2719 int4_accum  numeric_var_pop 0   1231    "{0,0,0}" ));
+DATA(insert ( 2720 int2_accum  numeric_var_pop 0   1231    "{0,0,0}" ));
 DATA(insert ( 2721 float4_accum    float8_var_pop 0    1022    "{0,0,0}" ));
 DATA(insert ( 2722 float8_accum    float8_var_pop 0    1022    "{0,0,0}" ));
 DATA(insert ( 2723 numeric_accum  numeric_var_pop 0    1231    "{0,0,0}" ));
@@ -182,7 +182,7 @@ DATA(insert ( 2713  int4_accum  numeric_stddev_samp     0   1231    "{0,0,0}" ));
 DATA(insert ( 2714 int2_accum  numeric_stddev_samp     0   1231    "{0,0,0}" ));
 DATA(insert ( 2715 float4_accum    float8_stddev_samp  0   1022    "{0,0,0}" ));
 DATA(insert ( 2716 float8_accum    float8_stddev_samp  0   1022    "{0,0,0}" ));
-DATA(insert ( 2717 numeric_accum   numeric_stddev_samp 0   1231    "{0,0,0}" ));
+DATA(insert ( 2717 numeric_accum   numeric_stddev_samp 0   1231    "{0,0,0}" ));
 
 /* stddev: historical Postgres syntax for stddev_samp */
 DATA(insert ( 2154 int8_accum  numeric_stddev_samp     0   1231    "{0,0,0}" ));
@@ -190,7 +190,7 @@ DATA(insert ( 2155  int4_accum  numeric_stddev_samp     0   1231    "{0,0,0}" ));
 DATA(insert ( 2156 int2_accum  numeric_stddev_samp     0   1231    "{0,0,0}" ));
 DATA(insert ( 2157 float4_accum    float8_stddev_samp  0   1022    "{0,0,0}" ));
 DATA(insert ( 2158 float8_accum    float8_stddev_samp  0   1022    "{0,0,0}" ));
-DATA(insert ( 2159 numeric_accum   numeric_stddev_samp 0   1231    "{0,0,0}" ));
+DATA(insert ( 2159 numeric_accum   numeric_stddev_samp 0   1231    "{0,0,0}" ));
 
 /* SQL2003 binary regression aggregates */
 DATA(insert ( 2818 int8inc_float8_float8       -               0   20      "0" ));
index b0da3c0382051dddac16eb901af7ed7700cf9116..1203434727fe19ad358d7b0d5ba7e7d5c46045c8 100644 (file)
@@ -23,7 +23,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.74 2006/09/10 00:29:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.75 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *  the genbki.sh script reads this file and generates .bki
@@ -671,225 +671,225 @@ DATA(insert (   2746    0 4  t  1070 ));
 /*
  * gin _abstime_ops
  */
-DATA(insert (  2753    0 1  f  2750 ));
-DATA(insert (  2753    0 2  f  2751 ));
-DATA(insert (  2753    0 3  t  2752 ));
+DATA(insert (  2753    0 1  f  2750 ));
+DATA(insert (  2753    0 2  f  2751 ));
+DATA(insert (  2753    0 3  t  2752 ));
 DATA(insert (  2753    0 4  t  1070 ));
 
 /*
  * gin _bit_ops
  */
-DATA(insert (  2754    0 1  f  2750 ));
-DATA(insert (  2754    0 2  f  2751 ));
-DATA(insert (  2754    0 3  t  2752 ));
+DATA(insert (  2754    0 1  f  2750 ));
+DATA(insert (  2754    0 2  f  2751 ));
+DATA(insert (  2754    0 3  t  2752 ));
 DATA(insert (  2754    0 4  t  1070 ));
 
 /*
  * gin _bool_ops
  */
-DATA(insert (  2755    0 1  f  2750 ));
-DATA(insert (  2755    0 2  f  2751 ));
-DATA(insert (  2755    0 3  t  2752 ));
+DATA(insert (  2755    0 1  f  2750 ));
+DATA(insert (  2755    0 2  f  2751 ));
+DATA(insert (  2755    0 3  t  2752 ));
 DATA(insert (  2755    0 4  t  1070 ));
 
 /*
  * gin _bpchar_ops
  */
-DATA(insert (  2756    0 1  f  2750 ));
-DATA(insert (  2756    0 2  f  2751 ));
-DATA(insert (  2756    0 3  t  2752 ));
+DATA(insert (  2756    0 1  f  2750 ));
+DATA(insert (  2756    0 2  f  2751 ));
+DATA(insert (  2756    0 3  t  2752 ));
 DATA(insert (  2756    0 4  t  1070 ));
 
 /*
  * gin _bytea_ops
  */
-DATA(insert (  2757    0 1  f  2750 ));
-DATA(insert (  2757    0 2  f  2751 ));
-DATA(insert (  2757    0 3  t  2752 ));
+DATA(insert (  2757    0 1  f  2750 ));
+DATA(insert (  2757    0 2  f  2751 ));
+DATA(insert (  2757    0 3  t  2752 ));
 DATA(insert (  2757    0 4  t  1070 ));
 
 /*
  * gin _char_ops
  */
-DATA(insert (  2758    0 1  f  2750 ));
-DATA(insert (  2758    0 2  f  2751 ));
-DATA(insert (  2758    0 3  t  2752 ));
+DATA(insert (  2758    0 1  f  2750 ));
+DATA(insert (  2758    0 2  f  2751 ));
+DATA(insert (  2758    0 3  t  2752 ));
 DATA(insert (  2758    0 4  t  1070 ));
 
 /*
  * gin _cidr_ops
  */
-DATA(insert (  2759    0 1  f  2750 ));
-DATA(insert (  2759    0 2  f  2751 ));
-DATA(insert (  2759    0 3  t  2752 ));
+DATA(insert (  2759    0 1  f  2750 ));
+DATA(insert (  2759    0 2  f  2751 ));
+DATA(insert (  2759    0 3  t  2752 ));
 DATA(insert (  2759    0 4  t  1070 ));
 
 /*
  * gin _date_ops
  */
-DATA(insert (  2760    0 1  f  2750 ));
-DATA(insert (  2760    0 2  f  2751 ));
-DATA(insert (  2760    0 3  t  2752 ));
+DATA(insert (  2760    0 1  f  2750 ));
+DATA(insert (  2760    0 2  f  2751 ));
+DATA(insert (  2760    0 3  t  2752 ));
 DATA(insert (  2760    0 4  t  1070 ));
 
 /*
  * gin _float4_ops
  */
-DATA(insert (  2761    0 1  f  2750 ));
-DATA(insert (  2761    0 2  f  2751 ));
-DATA(insert (  2761    0 3  t  2752 ));
+DATA(insert (  2761    0 1  f  2750 ));
+DATA(insert (  2761    0 2  f  2751 ));
+DATA(insert (  2761    0 3  t  2752 ));
 DATA(insert (  2761    0 4  t  1070 ));
 
 /*
  * gin _float8_ops
  */
-DATA(insert (  2762    0 1  f  2750 ));
-DATA(insert (  2762    0 2  f  2751 ));
-DATA(insert (  2762    0 3  t  2752 ));
+DATA(insert (  2762    0 1  f  2750 ));
+DATA(insert (  2762    0 2  f  2751 ));
+DATA(insert (  2762    0 3  t  2752 ));
 DATA(insert (  2762    0 4  t  1070 ));
 
 /*
  * gin _inet_ops
  */
-DATA(insert (  2763    0 1  f  2750 ));
-DATA(insert (  2763    0 2  f  2751 ));
-DATA(insert (  2763    0 3  t  2752 ));
+DATA(insert (  2763    0 1  f  2750 ));
+DATA(insert (  2763    0 2  f  2751 ));
+DATA(insert (  2763    0 3  t  2752 ));
 DATA(insert (  2763    0 4  t  1070 ));
 
 /*
  * gin _int2_ops
  */
-DATA(insert (  2764    0 1  f  2750 ));
-DATA(insert (  2764    0 2  f  2751 ));
-DATA(insert (  2764    0 3  t  2752 ));
+DATA(insert (  2764    0 1  f  2750 ));
+DATA(insert (  2764    0 2  f  2751 ));
+DATA(insert (  2764    0 3  t  2752 ));
 DATA(insert (  2764    0 4  t  1070 ));
 
 /*
  * gin _int8_ops
  */
-DATA(insert (  2765    0 1  f  2750 ));
-DATA(insert (  2765    0 2  f  2751 ));
-DATA(insert (  2765    0 3  t  2752 ));
+DATA(insert (  2765    0 1  f  2750 ));
+DATA(insert (  2765    0 2  f  2751 ));
+DATA(insert (  2765    0 3  t  2752 ));
 DATA(insert (  2765    0 4  t  1070 ));
 
 /*
  * gin _interval_ops
  */
-DATA(insert (  2766    0 1  f  2750 ));
-DATA(insert (  2766    0 2  f  2751 ));
-DATA(insert (  2766    0 3  t  2752 ));
+DATA(insert (  2766    0 1  f  2750 ));
+DATA(insert (  2766    0 2  f  2751 ));
+DATA(insert (  2766    0 3  t  2752 ));
 DATA(insert (  2766    0 4  t  1070 ));
 
 /*
  * gin _macaddr_ops
  */
-DATA(insert (  2767    0 1  f  2750 ));
-DATA(insert (  2767    0 2  f  2751 ));
-DATA(insert (  2767    0 3  t  2752 ));
+DATA(insert (  2767    0 1  f  2750 ));
+DATA(insert (  2767    0 2  f  2751 ));
+DATA(insert (  2767    0 3  t  2752 ));
 DATA(insert (  2767    0 4  t  1070 ));
 
 /*
  * gin _name_ops
  */
-DATA(insert (  2768    0 1  f  2750 ));
-DATA(insert (  2768    0 2  f  2751 ));
-DATA(insert (  2768    0 3  t  2752 ));
+DATA(insert (  2768    0 1  f  2750 ));
+DATA(insert (  2768    0 2  f  2751 ));
+DATA(insert (  2768    0 3  t  2752 ));
 DATA(insert (  2768    0 4  t  1070 ));
 
 /*
  * gin _numeric_ops
  */
-DATA(insert (  2769    0 1  f  2750 ));
-DATA(insert (  2769    0 2  f  2751 ));
-DATA(insert (  2769    0 3  t  2752 ));
+DATA(insert (  2769    0 1  f  2750 ));
+DATA(insert (  2769    0 2  f  2751 ));
+DATA(insert (  2769    0 3  t  2752 ));
 DATA(insert (  2769    0 4  t  1070 ));
 
 /*
  * gin _oid_ops
  */
-DATA(insert (  2770    0 1  f  2750 ));
-DATA(insert (  2770    0 2  f  2751 ));
-DATA(insert (  2770    0 3  t  2752 ));
+DATA(insert (  2770    0 1  f  2750 ));
+DATA(insert (  2770    0 2  f  2751 ));
+DATA(insert (  2770    0 3  t  2752 ));
 DATA(insert (  2770    0 4  t  1070 ));
 
 /*
  * gin _oidvector_ops
  */
-DATA(insert (  2771    0 1  f  2750 ));
-DATA(insert (  2771    0 2  f  2751 ));
-DATA(insert (  2771    0 3  t  2752 ));
+DATA(insert (  2771    0 1  f  2750 ));
+DATA(insert (  2771    0 2  f  2751 ));
+DATA(insert (  2771    0 3  t  2752 ));
 DATA(insert (  2771    0 4  t  1070 ));
 
 /*
  * gin _time_ops
  */
-DATA(insert (  2772    0 1  f  2750 ));
-DATA(insert (  2772    0 2  f  2751 ));
-DATA(insert (  2772    0 3  t  2752 ));
+DATA(insert (  2772    0 1  f  2750 ));
+DATA(insert (  2772    0 2  f  2751 ));
+DATA(insert (  2772    0 3  t  2752 ));
 DATA(insert (  2772    0 4  t  1070 ));
 
 /*
  * gin _timestamptz_ops
  */
-DATA(insert (  2773    0 1  f  2750 ));
-DATA(insert (  2773    0 2  f  2751 ));
-DATA(insert (  2773    0 3  t  2752 ));
+DATA(insert (  2773    0 1  f  2750 ));
+DATA(insert (  2773    0 2  f  2751 ));
+DATA(insert (  2773    0 3  t  2752 ));
 DATA(insert (  2773    0 4  t  1070 ));
 
 /*
  * gin _timetz_ops
  */
-DATA(insert (  2774    0 1  f  2750 ));
-DATA(insert (  2774    0 2  f  2751 ));
-DATA(insert (  2774    0 3  t  2752 ));
+DATA(insert (  2774    0 1  f  2750 ));
+DATA(insert (  2774    0 2  f  2751 ));
+DATA(insert (  2774    0 3  t  2752 ));
 DATA(insert (  2774    0 4  t  1070 ));
 
 /*
  * gin _varbit_ops
  */
-DATA(insert (  2775    0 1  f  2750 ));
-DATA(insert (  2775    0 2  f  2751 ));
-DATA(insert (  2775    0 3  t  2752 ));
+DATA(insert (  2775    0 1  f  2750 ));
+DATA(insert (  2775    0 2  f  2751 ));
+DATA(insert (  2775    0 3  t  2752 ));
 DATA(insert (  2775    0 4  t  1070 ));
 
 /*
  * gin _varchar_ops
  */
-DATA(insert (  2776    0 1  f  2750 ));
-DATA(insert (  2776    0 2  f  2751 ));
-DATA(insert (  2776    0 3  t  2752 ));
+DATA(insert (  2776    0 1  f  2750 ));
+DATA(insert (  2776    0 2  f  2751 ));
+DATA(insert (  2776    0 3  t  2752 ));
 DATA(insert (  2776    0 4  t  1070 ));
 
 /*
  * gin _timestamp_ops
  */
-DATA(insert (  2777    0 1  f  2750 ));
-DATA(insert (  2777    0 2  f  2751 ));
-DATA(insert (  2777    0 3  t  2752 ));
+DATA(insert (  2777    0 1  f  2750 ));
+DATA(insert (  2777    0 2  f  2751 ));
+DATA(insert (  2777    0 3  t  2752 ));
 DATA(insert (  2777    0 4  t  1070 ));
 
 /*
  * gin _money_ops
  */
-DATA(insert (  2778    0 1  f  2750 ));
-DATA(insert (  2778    0 2  f  2751 ));
-DATA(insert (  2778    0 3  t  2752 ));
+DATA(insert (  2778    0 1  f  2750 ));
+DATA(insert (  2778    0 2  f  2751 ));
+DATA(insert (  2778    0 3  t  2752 ));
 DATA(insert (  2778    0 4  t  1070 ));
 
 /*
  * gin _reltime_ops
  */
-DATA(insert (  2779    0 1  f  2750 ));
-DATA(insert (  2779    0 2  f  2751 ));
-DATA(insert (  2779    0 3  t  2752 ));
+DATA(insert (  2779    0 1  f  2750 ));
+DATA(insert (  2779    0 2  f  2751 ));
+DATA(insert (  2779    0 3  t  2752 ));
 DATA(insert (  2779    0 4  t  1070 ));
 
 /*
  * gin _tinterval_ops
  */
-DATA(insert (  2780    0 1  f  2750 ));
-DATA(insert (  2780    0 2  f  2751 ));
-DATA(insert (  2780    0 3  t  2752 ));
+DATA(insert (  2780    0 1  f  2750 ));
+DATA(insert (  2780    0 2  f  2751 ));
+DATA(insert (  2780    0 3  t  2752 ));
 DATA(insert (  2780    0 4  t  1070 ));
 
 #endif   /* PG_AMOP_H */
index 17884fa41943d2ff413b0061389df4fbd41f3879..291931b707bc10371c3a501080ec75289cc114f7 100644 (file)
@@ -19,7 +19,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.59 2006/07/21 20:51:33 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.60 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -124,7 +124,7 @@ DATA(insert (   2098    0 1 2187 ));
 DATA(insert (  2099    0 1  377 ));
 DATA(insert (  2233    0 1  380 ));
 DATA(insert (  2234    0 1  381 ));
-DATA(insert (  2789    0 1 2794 ));
+DATA(insert (  2789    0 1 2794 ));
 
 
 /* hash */
index 68d7eae7ab52accd0f8685c9a3744ca0961c2fd7..b96a5b83404dcf9ecd5a0d827c59989caec6b317 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.124 2006/08/25 04:06:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.125 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -404,7 +404,7 @@ DATA(insert ( 1249 tableoid         26 0  4  -7 0 -1 -1 t p i t f f t 0));
 { 1259, {"relhaspkey"},    16, -1, 1, 22, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \
 { 1259, {"relhasrules"},   16, -1, 1, 23, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \
 { 1259, {"relhassubclass"},16, -1, 1, 24, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \
-{ 1259, {"relminxid"},     28, -1, 4, 25, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \
+{ 1259, {"relminxid"},    28, -1,  4, 25, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \
 { 1259, {"relvacuumxid"},  28, -1, 4, 26, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \
 { 1259, {"relacl"},         1034, -1, -1, 27, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
 { 1259, {"reloptions"},  1009, -1, -1, 28, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }
index 931875a4c50f15d544886ea44f66206e726e06b4..aa0c02ca1d9ae88fc8efce1503b5e8a6549cec14 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.95 2006/07/10 16:20:51 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.96 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -66,7 +66,7 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP
    bool        relhasrules;    /* has associated rules */
    bool        relhassubclass; /* has derived classes */
    TransactionId relminxid;    /* minimum Xid present in table */
-   TransactionId relvacuumxid; /* Xid used as last vacuum OldestXmin */
+   TransactionId relvacuumxid; /* Xid used as last vacuum OldestXmin */
 
    /*
     * VARIABLE LENGTH FIELDS start here.  These fields may be NULL, too.
index 2b109f2d5ac1b232dc083adafe8ffa64db07b769..0e1132052e79626542a40bd207777e30e3701766 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.32 2006/08/21 16:16:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.33 2006/10/04 00:30:07 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -109,7 +109,7 @@ typedef struct ControlFileData
 
    CheckPoint  checkPointCopy; /* copy of last check point record */
 
-   XLogRecPtr  minRecoveryPoint;   /* must replay xlog to here */
+   XLogRecPtr  minRecoveryPoint;       /* must replay xlog to here */
 
    /*
     * This data is used to check for hardware-architecture compatibility of
index 506fbc293d2f237abf2302949acef308bb20ce88..8891b9521b155bf8488da2365fe4015488587f58 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.40 2006/08/25 04:06:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.41 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -41,7 +41,7 @@ CATALOG(pg_index,2610) BKI_WITHOUT_OIDS
    bool        indisunique;    /* is this a unique index? */
    bool        indisprimary;   /* is this index for primary key? */
    bool        indisclustered; /* is this the index last clustered by? */
-   bool        indisvalid;     /* is this index valid for use by queries? */
+   bool        indisvalid;     /* is this index valid for use by queries? */
 
    /* VARIABLE LENGTH FIELDS: */
    int2vector  indkey;         /* column numbers of indexed cols, or 0 */
index 9072380e0e3a2173cc79aec4fcc41f3fd5d20563..b64b3c5136ff2af4483d37a23bc429447240aaf4 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.145 2006/09/10 00:29:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.146 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -132,11 +132,11 @@ DATA(insert OID = 386 (  "="     PGNSP PGUID b t  22  22  16 386   0   0   0   0   0 int2
 DATA(insert OID = 387 (  "="      PGNSP PGUID b f  27  27  16 387 402 2799 2799 2799 2800 tideq eqsel eqjoinsel ));
 #define TIDEqualOperator   387
 DATA(insert OID = 402 (  "<>"     PGNSP PGUID b f  27  27  16 402 387 0 0 0 0 tidne neqsel neqjoinsel ));
-DATA(insert OID = 2799 (  "<"      PGNSP PGUID b f  27  27  16 2800 2802 0 0 0 0 tidlt scalarltsel scalarltjoinsel ));
+DATA(insert OID = 2799 (  "<"     PGNSP PGUID b f  27  27  16 2800 2802 0 0 0 0 tidlt scalarltsel scalarltjoinsel ));
 #define TIDLessOperator    2799
-DATA(insert OID = 2800 (  ">"      PGNSP PGUID b f  27  27  16 2799 2801 0 0 0 0 tidgt scalargtsel scalargtjoinsel ));
-DATA(insert OID = 2801 (  "<="     PGNSP PGUID b f  27  27  16 2802 2800 0 0 0 0 tidle scalarltsel scalarltjoinsel ));
-DATA(insert OID = 2802 (  ">="     PGNSP PGUID b f  27  27  16 2801 2799 0 0 0 0 tidge scalargtsel scalargtjoinsel ));
+DATA(insert OID = 2800 (  ">"     PGNSP PGUID b f  27  27  16 2799 2801 0 0 0 0 tidgt scalargtsel scalargtjoinsel ));
+DATA(insert OID = 2801 (  "<="    PGNSP PGUID b f  27  27  16 2802 2800 0 0 0 0 tidle scalarltsel scalarltjoinsel ));
+DATA(insert OID = 2802 (  ">="    PGNSP PGUID b f  27  27  16 2801 2799 0 0 0 0 tidge scalargtsel scalargtjoinsel ));
 
 DATA(insert OID = 410 ( "="           PGNSP PGUID b t  20  20  16 410 411 412 412 412 413 int8eq eqsel eqjoinsel ));
 DATA(insert OID = 411 ( "<>"      PGNSP PGUID b f  20  20  16 411 410 0 0 0 0 int8ne neqsel neqjoinsel ));
@@ -879,19 +879,19 @@ DATA(insert OID = 2589 (  "&<|"    PGNSP PGUID b f 718 718    16   0   0   0   0   0   0
 DATA(insert OID = 2590 (  "|&>"    PGNSP PGUID b f 718 718 16   0   0   0   0   0   0 circle_overabove positionsel positionjoinsel ));
 
 /* overlap/contains/contained for arrays */
-DATA(insert OID = 2750 (  "&&"    PGNSP PGUID b f 2277 2277    16 2750  0   0   0   0   0 arrayoverlap areasel areajoinsel ));
-DATA(insert OID = 2751 (  "@>"    PGNSP PGUID b f 2277 2277    16 2752  0   0   0   0   0 arraycontains contsel contjoinsel ));
-DATA(insert OID = 2752 (  "<@"    PGNSP PGUID b f 2277 2277    16 2751  0   0   0   0   0 arraycontained contsel contjoinsel ));
+DATA(insert OID = 2750 (  "&&"    PGNSP PGUID b f 2277 2277    16 2750  0   0   0   0   0 arrayoverlap areasel areajoinsel ));
+DATA(insert OID = 2751 (  "@>"    PGNSP PGUID b f 2277 2277    16 2752  0   0   0   0   0 arraycontains contsel contjoinsel ));
+DATA(insert OID = 2752 (  "<@"    PGNSP PGUID b f 2277 2277    16 2751  0   0   0   0   0 arraycontained contsel contjoinsel ));
 
 /* obsolete names for contains/contained-by operators; remove these someday */
-DATA(insert OID = 2860 (  "@"     PGNSP PGUID b f 604 604  16 2861  0   0   0   0   0 poly_contained contsel contjoinsel ));
-DATA(insert OID = 2861 (  "~"     PGNSP PGUID b f 604 604  16 2860  0   0   0   0   0 poly_contain contsel contjoinsel ));
-DATA(insert OID = 2862 (  "@"     PGNSP PGUID b f 603 603  16 2863  0   0   0   0   0 box_contained contsel contjoinsel ));
-DATA(insert OID = 2863 (  "~"     PGNSP PGUID b f 603 603  16 2862  0   0   0   0   0 box_contain contsel contjoinsel ));
+DATA(insert OID = 2860 (  "@"     PGNSP PGUID b f 604 604  16 2861  0   0   0   0   0 poly_contained contsel contjoinsel ));
+DATA(insert OID = 2861 (  "~"     PGNSP PGUID b f 604 604  16 2860  0   0   0   0   0 poly_contain contsel contjoinsel ));
+DATA(insert OID = 2862 (  "@"     PGNSP PGUID b f 603 603  16 2863  0   0   0   0   0 box_contained contsel contjoinsel ));
+DATA(insert OID = 2863 (  "~"     PGNSP PGUID b f 603 603  16 2862  0   0   0   0   0 box_contain contsel contjoinsel ));
 DATA(insert OID = 2864 (  "@"     PGNSP PGUID b f 718 718  16 2865  0   0   0   0   0 circle_contained contsel contjoinsel ));
 DATA(insert OID = 2865 (  "~"     PGNSP PGUID b f 718 718  16 2864  0   0   0   0   0 circle_contain contsel contjoinsel ));
 DATA(insert OID = 2866 (  "@"     PGNSP PGUID b f 600 603  16   0   0   0   0   0   0 on_pb - - ));
-DATA(insert OID = 2867 (  "@"     PGNSP PGUID b f 600 602  16 2868  0   0   0   0   0 on_ppath - - ));
+DATA(insert OID = 2867 (  "@"     PGNSP PGUID b f 600 602  16 2868  0   0   0   0   0 on_ppath - - ));
 DATA(insert OID = 2868 (  "~"     PGNSP PGUID b f 602 600   16  2867  0 0 0 0 0 path_contain_pt - - ));
 DATA(insert OID = 2869 (  "@"     PGNSP PGUID b f 600 604   16  2870  0 0 0 0 0 pt_contained_poly - - ));
 DATA(insert OID = 2870 (  "~"     PGNSP PGUID b f 604 600   16  2869  0 0 0 0 0 poly_contain_pt - - ));
index 1e0dc4b13f5e40c32f3f116bf94f39a317248929..9299d63ab8ec913c0efa1c7e8ffe1574aeaea2d0 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.426 2006/09/18 22:40:38 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.427 2006/10/04 00:30:07 momjian Exp $
  *
  * NOTES
  *   The script catalog/genbki.sh reads this file and generates .bki
@@ -1534,7 +1534,7 @@ 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_ ));
 DESCR("increment");
-DATA(insert OID = 2804 (  int8inc_any     PGNSP PGUID 12 f f t f i 2 20 "20 2276" _null_ _null_ _null_ int8inc_any - _null_ ));
+DATA(insert OID = 2804 (  int8inc_any     PGNSP PGUID 12 f f t f i 2 20 "20 2276" _null_ _null_ _null_ int8inc_any - _null_ ));
 DESCR("increment, ignores second argument");
 DATA(insert OID = 1230 (  int8abs         PGNSP PGUID 12 f f t f i 1 20 "20" _null_ _null_ _null_  int8abs - _null_ ));
 DESCR("absolute value");
@@ -1628,11 +1628,11 @@ DATA(insert OID = 1298 (  timetzdate_pl    PGNSP PGUID 14 f f t f i 2 1184 "1266
 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_ ));
 DESCR("current transaction time");
-DATA(insert OID = 2647 (  transaction_timestamp    PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ now - _null_ ));
+DATA(insert OID = 2647 (  transaction_timestamp PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ now - _null_ ));
 DESCR("current transaction time");
-DATA(insert OID = 2648 (  statement_timestamp  PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ statement_timestamp - _null_ ));
+DATA(insert OID = 2648 (  statement_timestamp  PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ statement_timestamp - _null_ ));
 DESCR("current statement time");
-DATA(insert OID = 2649 (  clock_timestamp  PGNSP PGUID 12 f f t f v 0 1184 "" _null_ _null_ _null_ clock_timestamp - _null_ ));
+DATA(insert OID = 2649 (  clock_timestamp  PGNSP PGUID 12 f f t f v 0 1184 "" _null_ _null_ _null_ clock_timestamp - _null_ ));
 DESCR("current clock time");
 
 /* OIDS 1300 - 1399 */
@@ -2694,7 +2694,7 @@ DATA(insert OID = 1831 (  float8_var_samp  PGNSP PGUID 12 f f t f i 1 701 "1022"
 DESCR("VAR_SAMP aggregate final function");
 DATA(insert OID = 2513 (  float8_stddev_pop PGNSP PGUID 12 f f t f i 1 701 "1022" _null_ _null_ _null_ float8_stddev_pop - _null_ ));
 DESCR("STDDEV_POP aggregate final function");
-DATA(insert OID = 1832 (  float8_stddev_samp    PGNSP PGUID 12 f f t f i 1 701 "1022" _null_ _null_ _null_ float8_stddev_samp - _null_ ));
+DATA(insert OID = 1832 (  float8_stddev_samp   PGNSP PGUID 12 f f t f i 1 701 "1022" _null_ _null_ _null_ float8_stddev_samp - _null_ ));
 DESCR("STDDEV_SAMP 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_ ));
 DESCR("aggregate transition function");
@@ -2712,7 +2712,7 @@ DATA(insert OID = 1838 (  numeric_var_samp PGNSP PGUID 12 f f t f i 1 1700 "1231
 DESCR("VAR_SAMP aggregate final function");
 DATA(insert OID = 2596 (  numeric_stddev_pop PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_   numeric_stddev_pop - _null_ ));
 DESCR("STDDEV_POP aggregate final function");
-DATA(insert OID = 1839 (  numeric_stddev_samp   PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_    numeric_stddev_samp - _null_ ));
+DATA(insert OID = 1839 (  numeric_stddev_samp  PGNSP PGUID 12 f f t f i 1 1700 "1231" _null_ _null_ _null_ numeric_stddev_samp - _null_ ));
 DESCR("STDDEV_SAMP 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");
@@ -3933,7 +3933,7 @@ DATA(insert OID = 2788 (  ginoptions     PGNSP PGUID 12 f f t f s 2 17 "1009 16"
 DESCR("gin(internal)");
 
 /* GIN array support */
-DATA(insert OID = 2743 (  ginarrayextract    PGNSP PGUID 12 f f t f i 2 2281 "2277 2281" _null_ _null_ _null_  ginarrayextract - _null_ ));
+DATA(insert OID = 2743 (  ginarrayextract   PGNSP PGUID 12 f f t f i 2 2281 "2277 2281" _null_ _null_ _null_   ginarrayextract - _null_ ));
 DESCR("GIN array support");
 DATA(insert OID = 2744 (  ginarrayconsistent PGNSP PGUID 12 f f t f i 3 16 "2281 21 2281" _null_ _null_ _null_ ginarrayconsistent - _null_ ));
 DESCR("GIN array support");
index 0879fa68f58cdefde8356713801bd17f70866742..6738da1fda2f98e33899a90269b0e1268c82a037 100644 (file)
@@ -7,7 +7,7 @@
  * NOTE: an object is identified by the OID of the row that primarily
  * defines the object, plus the OID of the table that that row appears in.
  * For example, a database is identified by the OID of its pg_database row
- * plus the pg_class OID of table pg_database.  This allows unique
+ * plus the pg_class OID of table pg_database. This allows unique
  * identification of objects without assuming that OIDs are unique
  * across tables.
  *
@@ -15,7 +15,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_shdescription.h,v 1.2 2006/03/05 15:58:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_shdescription.h,v 1.3 2006/10/04 00:30:08 momjian Exp $
  *
  * NOTES
  *     the genbki.sh script reads this file and generates .bki
@@ -61,7 +61,7 @@ typedef FormData_pg_shdescription *Form_pg_shdescription;
  *     compiler constants for pg_shdescription
  * ----------------
  */
-#define Natts_pg_shdescription         3   
+#define Natts_pg_shdescription         3
 #define Anum_pg_shdescription_objoid       1
 #define Anum_pg_shdescription_classoid 2
 #define Anum_pg_shdescription_description 3
index b9aeec1e3cbe7a9753a074979fb70121c8f38060..488ff66beddbb5f05e50bfb5bf2e5736e5d95481 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.171 2006/04/05 22:11:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.172 2006/10/04 00:30:08 momjian Exp $
  *
  * NOTES
  *   the genbki.sh script reads this file and generates .bki
@@ -516,7 +516,7 @@ DATA(insert OID = 2208 ( _regoper      PGNSP PGUID -1 f b t \054 0 2203 array_in a
 DATA(insert OID = 2209 ( _regoperator  PGNSP PGUID -1 f b t \054 0 2204 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ ));
 DATA(insert OID = 2210 ( _regclass    PGNSP PGUID -1 f b t \054 0 2205 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ ));
 DATA(insert OID = 2211 ( _regtype     PGNSP PGUID -1 f b t \054 0 2206 array_in array_out array_recv array_send - i x f 0 -1 0 _null_ _null_ ));
-#define REGTYPEARRAYOID    2211
+#define REGTYPEARRAYOID 2211
 
 /*
  * pseudo-types
index 25a84b3f8801d92f1deeda7c872b0463c47d38a9..f5d54af112db3fb79de55c71c04337cbc2e98b34 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.1 2006/07/31 01:16:37 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.2 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -19,7 +19,7 @@
  */
 extern void AlterTableCreateToastTable(Oid relOid);
 extern void BootstrapToastTable(char *relName,
-                               Oid toastOid, Oid toastIndexOid);
+                   Oid toastOid, Oid toastIndexOid);
 
 
 /*
@@ -40,21 +40,21 @@ extern void BootstrapToastTable(char *relName,
  */
 
 /* normal catalogs */
-DECLARE_TOAST(pg_attrdef,2830,2831);
-DECLARE_TOAST(pg_constraint,2832,2833);
-DECLARE_TOAST(pg_description,2834,2835);
-DECLARE_TOAST(pg_proc,2836,2837);
-DECLARE_TOAST(pg_rewrite,2838,2839);
-DECLARE_TOAST(pg_statistic,2840,2841);
+DECLARE_TOAST(pg_attrdef, 2830, 2831);
+DECLARE_TOAST(pg_constraint, 2832, 2833);
+DECLARE_TOAST(pg_description, 2834, 2835);
+DECLARE_TOAST(pg_proc, 2836, 2837);
+DECLARE_TOAST(pg_rewrite, 2838, 2839);
+DECLARE_TOAST(pg_statistic, 2840, 2841);
 
 /* shared catalogs */
-DECLARE_TOAST(pg_authid,2842,2843);
+DECLARE_TOAST(pg_authid, 2842, 2843);
 #define PgAuthidToastTable 2842
 #define PgAuthidToastIndex 2843
-DECLARE_TOAST(pg_database,2844,2845);
+DECLARE_TOAST(pg_database, 2844, 2845);
 #define PgDatabaseToastTable 2844
 #define PgDatabaseToastIndex 2845
-DECLARE_TOAST(pg_shdescription,2846,2847);
+DECLARE_TOAST(pg_shdescription, 2846, 2847);
 #define PgShdescriptionToastTable 2846
 #define PgShdescriptionToastIndex 2847
 
index 525a2b9c387f509dfacde72b292fcc505436c922..da9fc1c7f152d9dbb39359bece8350684c8013da 100644 (file)
@@ -21,7 +21,7 @@
  * related routines.  CommentObject() implements the SQL "COMMENT ON"
  * command.  DeleteComments() deletes all comments for an object.
  * CreateComments creates (or deletes, if comment is NULL) a comment
- * for a specific key.  There are versions of these two methods for
+ * for a specific key. There are versions of these two methods for
  * both normal and shared objects.
  *------------------------------------------------------------------
  */
index 26983fc1988006f8b96e0ce9d333f4ded1042ab4..7b45ea57358f9d5d856b981e3c36c7795267f667 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.76 2006/08/25 04:06:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.77 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -72,7 +72,7 @@ extern void AlterOperatorOwner_oid(Oid operOid, Oid newOwnerId);
 
 /* commands/aggregatecmds.c */
 extern void DefineAggregate(List *name, List *args, bool oldstyle,
-                           List *parameters);
+               List *parameters);
 extern void RemoveAggregate(RemoveFuncStmt *stmt);
 extern void RenameAggregate(List *name, List *args, const char *newname);
 extern void AlterAggregateOwner(List *name, List *args, Oid newOwnerId);
index 8814102bfc49a4696120b3d9f96a2bfaa2cdb5d7..7417e8cfdde6903512aa051857d30aaa8be1be48 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994-5, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.27 2006/07/13 16:49:19 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.28 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -17,7 +17,7 @@
 
 
 extern void ExplainQuery(ExplainStmt *stmt, ParamListInfo params,
-                        DestReceiver *dest);
+            DestReceiver *dest);
 
 extern TupleDesc ExplainResultDesc(ExplainStmt *stmt);
 
index bd831c2e609e73232129e5f8275d36da02ff2371..2a7d2b2c8d1c8039f5d29b494b76903e640b7198 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 2002-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.21 2006/07/13 16:49:19 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.22 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 typedef struct
 {
    /* dynahash.c requires key to be first field */
-   char            stmt_name[NAMEDATALEN];
-   char           *query_string;   /* text of query, or NULL */
-   const char     *commandTag;     /* command tag (a constant!), or NULL */
-   List           *query_list;     /* list of queries, rewritten */
-   List           *plan_list;      /* list of plans */
-   List           *argtype_list;   /* list of parameter type OIDs */
-   TimestampTz     prepare_time;   /* the time when the stmt was prepared */
-   bool            from_sql;       /* stmt prepared via SQL, not
-                                    * FE/BE protocol? */
-   MemoryContext   context;        /* context containing this query */
+   char        stmt_name[NAMEDATALEN];
+   char       *query_string;   /* text of query, or NULL */
+   const char *commandTag;     /* command tag (a constant!), or NULL */
+   List       *query_list;     /* list of queries, rewritten */
+   List       *plan_list;      /* list of plans */
+   List       *argtype_list;   /* list of parameter type OIDs */
+   TimestampTz prepare_time;   /* the time when the stmt was prepared */
+   bool        from_sql;       /* stmt prepared via SQL, not FE/BE protocol? */
+   MemoryContext context;      /* context containing this query */
 } PreparedStatement;
 
 
 /* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
 extern void PrepareQuery(PrepareStmt *stmt);
 extern void ExecuteQuery(ExecuteStmt *stmt, ParamListInfo params,
-                        DestReceiver *dest, char *completionTag);
+            DestReceiver *dest, char *completionTag);
 extern void DeallocateQuery(DeallocateStmt *stmt);
 extern void ExplainExecuteQuery(ExplainStmt *stmt, ParamListInfo params,
-                               TupOutputState *tstate);
+                   TupOutputState *tstate);
 
 /* Low-level access to stored prepared statements */
 extern void StorePreparedStatement(const char *stmt_name,
index 4c9063f13ca853816f4aabdd4472a8433904b6c6..3a9aad7375d710e9fbae3a7224b155a49454c68b 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.30 2006/07/31 01:16:38 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.31 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -45,8 +45,8 @@ extern void renameatt(Oid myrelid,
 extern void renamerel(Oid myrelid,
          const char *newrelname);
 
-extern AttrNumber * varattnos_map(TupleDesc old, TupleDesc new);
-extern AttrNumber * varattnos_map_schema(TupleDesc old, List *schema);
+extern AttrNumber *varattnos_map(TupleDesc old, TupleDesc new);
+extern AttrNumber *varattnos_map_schema(TupleDesc old, List *schema);
 extern void change_varattnos_of_a_node(Node *node, const AttrNumber *newattno);
 
 extern void register_on_commit_action(Oid relid, OnCommitAction action);
index 86199669bdc0dd2819b25e412a09288eb6d596a8..01fb92c354619db4d58d2d55f4cf524596dfc484 100644 (file)
@@ -4,7 +4,7 @@
  *   Commands for manipulating roles (formerly called users).
  *
  *
- * $PostgreSQL: pgsql/src/include/commands/user.h,v 1.29 2005/11/22 18:17:30 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/user.h,v 1.30 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,7 +20,7 @@ extern void AlterRoleSet(AlterRoleSetStmt *stmt);
 extern void DropRole(DropRoleStmt *stmt);
 extern void GrantRole(GrantRoleStmt *stmt);
 extern void RenameRole(const char *oldname, const char *newname);
-extern void DropOwnedObjects(DropOwnedStmt * stmt);
-extern void ReassignOwnedObjects(ReassignOwnedStmt * stmt);
+extern void DropOwnedObjects(DropOwnedStmt *stmt);
+extern void ReassignOwnedObjects(ReassignOwnedStmt *stmt);
 
 #endif   /* USER_H */
index d5b6213a3510dee70fb73712217f17a3a1f60a74..d030b4deea4724a6df02af4739a8ea8a98605e70 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.129 2006/08/12 02:52:06 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.130 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,7 +35,7 @@
  * REWIND indicates that the plan node should try to efficiently support
  * rescans without parameter changes.  (Nodes must support ExecReScan calls
  * in any case, but if this flag was not given, they are at liberty to do it
- * through complete recalculation.  Note that a parameter change forces a
+ * through complete recalculation. Note that a parameter change forces a
  * full recalculation in any case.)
  *
  * BACKWARD indicates that the plan node must respect the es_direction flag.
  * MARK indicates that the plan node must support Mark/Restore calls.
  * When this is not passed, no Mark/Restore will occur.
  */
-#define EXEC_FLAG_EXPLAIN_ONLY 0x0001      /* EXPLAIN, no ANALYZE */
-#define EXEC_FLAG_REWIND       0x0002      /* need efficient rescan */
-#define EXEC_FLAG_BACKWARD     0x0004      /* need backward scan */
-#define EXEC_FLAG_MARK         0x0008      /* need mark/restore */
+#define EXEC_FLAG_EXPLAIN_ONLY 0x0001  /* EXPLAIN, no ANALYZE */
+#define EXEC_FLAG_REWIND       0x0002  /* need efficient rescan */
+#define EXEC_FLAG_BACKWARD     0x0004  /* need backward scan */
+#define EXEC_FLAG_MARK         0x0008  /* need mark/restore */
 
 
 /*
index db25839b204e20b1f9ed91527874269ccf414177..f5f0cc6c22a51bc8ed502c0ae105cb2fba5d6b42 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/executor/nodeIndexscan.h,v 1.28 2006/03/05 15:58:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/executor/nodeIndexscan.h,v 1.29 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,9 +31,9 @@ extern void ExecIndexBuildScanKeys(PlanState *planstate, Relation index,
                       IndexRuntimeKeyInfo **runtimeKeys, int *numRuntimeKeys,
                       IndexArrayKeyInfo **arrayKeys, int *numArrayKeys);
 extern void ExecIndexEvalRuntimeKeys(ExprContext *econtext,
-                        IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys);
+                      IndexRuntimeKeyInfo *runtimeKeys, int numRuntimeKeys);
 extern bool ExecIndexEvalArrayKeys(ExprContext *econtext,
-                        IndexArrayKeyInfo *arrayKeys, int numArrayKeys);
+                      IndexArrayKeyInfo *arrayKeys, int numArrayKeys);
 extern bool ExecIndexAdvanceArrayKeys(IndexArrayKeyInfo *arrayKeys, int numArrayKeys);
 
 #endif   /* NODEINDEXSCAN_H */
index 5a952bdd322073b7b980b586ff75c8e06f6d08ed..d8a8b5a7cb535e9fe91f70fc486b3f37f4765323 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/executor/nodeValuesscan.h,v 1.1 2006/08/02 01:59:47 joe Exp $
+ * $PostgreSQL: pgsql/src/include/executor/nodeValuesscan.h,v 1.2 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,7 +16,7 @@
 
 #include "nodes/execnodes.h"
 
-extern int ExecCountSlotsValuesScan(ValuesScan *node);
+extern int ExecCountSlotsValuesScan(ValuesScan *node);
 extern ValuesScanState *ExecInitValuesScan(ValuesScan *node, EState *estate, int eflags);
 extern TupleTableSlot *ExecValuesScan(ValuesScanState *node);
 extern void ExecEndValuesScan(ValuesScanState *node);
index 361fe7c8d1ee7f0303e2ba8999249a293ae05dab..9cbbc035dcc7b859eb20bf9de1d887c8d101a2bd 100644 (file)
@@ -2,7 +2,7 @@
  *
  * spi.h
  *
- * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.57 2006/09/03 03:19:45 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.58 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -71,9 +71,9 @@ typedef struct
 #define SPI_OK_DELETE          8
 #define SPI_OK_UPDATE          9
 #define SPI_OK_CURSOR          10
-#define SPI_OK_INSERT_RETURNING    11
-#define SPI_OK_DELETE_RETURNING    12
-#define SPI_OK_UPDATE_RETURNING    13
+#define SPI_OK_INSERT_RETURNING 11
+#define SPI_OK_DELETE_RETURNING 12
+#define SPI_OK_UPDATE_RETURNING 13
 
 extern DLLIMPORT uint32 SPI_processed;
 extern DLLIMPORT Oid SPI_lastoid;
index 32f34e6fb7467f1944359e435e907f11ba6369cc..c34234c836d4d0449bc534b76d80dbe573724d71 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/executor/tuptable.h,v 1.35 2006/07/13 17:47:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/executor/tuptable.h,v 1.36 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,7 +34,7 @@
  *
  * A "minimal" tuple is handled similarly to a palloc'd regular tuple.
  * At present, minimal tuples never are stored in buffers, so there is no
- * parallel to case 1.  Note that a minimal tuple has no "system columns".
+ * parallel to case 1. Note that a minimal tuple has no "system columns".
  * (Actually, it could have an OID, but we have no need to access the OID.)
  *
  * A "virtual" tuple is an optimization used to minimize physical data
@@ -94,7 +94,7 @@
  * object (the thing to be pfree'd if tts_shouldFree is true).  In this case
  * tts_tuple points at tts_minhdr and the fields of that are set correctly
  * for access to the minimal tuple; in particular, tts_minhdr.t_data points
- * MINIMAL_TUPLE_OFFSET bytes before tts_mintuple.  (tts_mintuple is therefore
+ * MINIMAL_TUPLE_OFFSET bytes before tts_mintuple. (tts_mintuple is therefore
  * redundant, but for code simplicity we store it explicitly anyway.)  This
  * case otherwise behaves identically to the regular-physical-tuple case.
  *
@@ -151,8 +151,8 @@ extern TupleTableSlot *ExecStoreTuple(HeapTuple tuple,
               Buffer buffer,
               bool shouldFree);
 extern TupleTableSlot *ExecStoreMinimalTuple(MinimalTuple mtup,
-              TupleTableSlot *slot,
-              bool shouldFree);
+                     TupleTableSlot *slot,
+                     bool shouldFree);
 extern TupleTableSlot *ExecClearTuple(TupleTableSlot *slot);
 extern TupleTableSlot *ExecStoreVirtualTuple(TupleTableSlot *slot);
 extern TupleTableSlot *ExecStoreAllNullTuple(TupleTableSlot *slot);
index 4055fe715b04a6151c662deee599a45d6006744f..b9164f06d7818312a37fd3acf26e8a7ac521346a 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/fmgr.h,v 1.47 2006/08/16 04:32:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/fmgr.h,v 1.48 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,6 +20,7 @@
 
 /* We don't want to include primnodes.h here, so make a stub reference */
 typedef struct Node *fmNodePtr;
+
 /* Likewise, avoid including stringinfo.h here */
 typedef struct StringInfoData *fmStringInfo;
 
@@ -322,7 +323,7 @@ extern int no_such_variable
  * To compile with versions of PostgreSQL that do not support this,
  * you may put an #ifdef/#endif test around it.  Note that in a multiple-
  * source-file module, the macro call should only appear once.
- * 
+ *
  * The specific items included in the magic block are intended to be ones that
  * are custom-configurable and especially likely to break dynamically loaded
  * modules if they were compiled with other values.  Also, the length field
@@ -333,11 +334,11 @@ extern int no_such_variable
 /* Definition of the magic block structure */
 typedef struct
 {
-   int     len;                /* sizeof(this struct) */
-   int     version;            /* PostgreSQL major version */
-   int     funcmaxargs;        /* FUNC_MAX_ARGS */
-   int     indexmaxkeys;       /* INDEX_MAX_KEYS */
-   int     namedatalen;        /* NAMEDATALEN */
+   int         len;            /* sizeof(this struct) */
+   int         version;        /* PostgreSQL major version */
+   int         funcmaxargs;    /* FUNC_MAX_ARGS */
+   int         indexmaxkeys;   /* INDEX_MAX_KEYS */
+   int         namedatalen;    /* NAMEDATALEN */
 } Pg_magic_struct;
 
 /* The actual data block contents */
@@ -457,15 +458,15 @@ extern Datum OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2,
 
 /* Special cases for convenient invocation of datatype I/O functions. */
 extern Datum InputFunctionCall(FmgrInfo *flinfo, char *str,
-                              Oid typioparam, int32 typmod);
+                 Oid typioparam, int32 typmod);
 extern Datum OidInputFunctionCall(Oid functionId, char *str,
-                                 Oid typioparam, int32 typmod);
+                    Oid typioparam, int32 typmod);
 extern char *OutputFunctionCall(FmgrInfo *flinfo, Datum val);
 extern char *OidOutputFunctionCall(Oid functionId, Datum val);
 extern Datum ReceiveFunctionCall(FmgrInfo *flinfo, fmStringInfo buf,
-                                Oid typioparam, int32 typmod);
+                   Oid typioparam, int32 typmod);
 extern Datum OidReceiveFunctionCall(Oid functionId, fmStringInfo buf,
-                                   Oid typioparam, int32 typmod);
+                      Oid typioparam, int32 typmod);
 extern bytea *SendFunctionCall(FmgrInfo *flinfo, Datum val);
 extern bytea *OidSendFunctionCall(Oid functionId, Datum val);
 
index 91130117b181dbe0c0ba0f8eb0c586e4ffa4466e..1698b1de860b28bb25a2f7dad6a03c8a96795e8e 100644 (file)
@@ -9,7 +9,7 @@
  *
  * Copyright (c) 2002-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.23 2006/03/05 15:58:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.24 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -169,9 +169,9 @@ extern bool resolve_polymorphic_argtypes(int numargs, Oid *argtypes,
                             char *argmodes,
                             Node *call_expr);
 
-extern int get_func_arg_info(HeapTuple procTup,
-                             Oid **p_argtypes, char ***p_argnames,
-                             char **p_argmodes);
+extern int get_func_arg_info(HeapTuple procTup,
+                 Oid **p_argtypes, char ***p_argnames,
+                 char **p_argmodes);
 
 extern char *get_func_result_name(Oid functionId);
 
index ee60b71d840704949b9d96888d46c0cb5314fb05..dbd411412e3c38220829bdbf205a88574e43e53f 100644 (file)
@@ -15,7 +15,7 @@
  *
  * Copyright (c) 2003-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.21 2006/07/06 02:12:32 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/getaddrinfo.h,v 1.22 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,9 +42,9 @@
 #else                          /* WIN32 */
 #ifdef WIN32_ONLY_COMPILER
 #ifndef WSA_NOT_ENOUGH_MEMORY
-#define WSA_NOT_ENOUGH_MEMORY   (WSAENOBUFS)
+#define WSA_NOT_ENOUGH_MEMORY  (WSAENOBUFS)
 #endif
-#define WSATYPE_NOT_FOUND       (WSABASEERR+109)
+#define WSATYPE_NOT_FOUND      (WSABASEERR+109)
 #endif
 #define EAI_AGAIN      WSATRY_AGAIN
 #define EAI_BADFLAGS   WSAEINVAL
index a50b3ca0a9ba273cd99ef15b3a7c7a69b9ab6690..eb8539f1399b3949c4e1a77e410adfe45b414b4b 100644 (file)
@@ -4,7 +4,7 @@
  *   Interface to hba.c
  *
  *
- * $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.43 2006/07/10 16:20:52 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.44 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,7 +27,7 @@ typedef enum UserAuth
    ,uaPAM
 #endif   /* USE_PAM */
 #ifdef USE_LDAP
-    ,uaLDAP
+   ,uaLDAP
 #endif
 } UserAuth;
 
index de85ce10d637a05e959c472105981489702d7909..dd39731cbd8df51de7b6bf147ca8c454fd304f56 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.56 2006/06/20 22:52:00 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/libpq/libpq-be.h,v 1.57 2006/10/04 00:30:08 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -81,8 +81,8 @@ typedef 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.
     */
-   TimestampTz SessionStartTime;   /* backend start time */
-   time_t      session_start;      /* same, in time_t format */
+   TimestampTz SessionStartTime;       /* backend start time */
+   time_t      session_start;  /* same, in time_t format */
 
    /*
     * TCP keepalive settings.
index 1bb8042344de3f54b65e5674d464f52aaeaf605f..2d465a1b38be38af206fdbfddd8bdd57e2aa71a5 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.68 2006/05/21 20:05:21 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.69 2006/10/04 00:30:09 momjian Exp $ */
 
 #ifndef PG_WCHAR_H
 #define PG_WCHAR_H
@@ -92,32 +92,32 @@ typedef unsigned int pg_wchar;
 #define LC_JISX0208_1978   0x90    /* Japanese Kanji, old JIS (not supported) */
 /* #define FREE                0x90    free (unused) */
 #define LC_GB2312_80       0x91    /* Chinese */
-#define LC_JISX0208        0x92        /* Japanese Kanji (JIS X 0208) */
-#define LC_KS5601          0x93        /* Korean */
-#define LC_JISX0212        0x94        /* Japanese Kanji (JIS X 0212) */
+#define LC_JISX0208            0x92    /* Japanese Kanji (JIS X 0208) */
+#define LC_KS5601          0x93    /* Korean */
+#define LC_JISX0212            0x94    /* Japanese Kanji (JIS X 0212) */
 #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
+#define LC_SISHENG         0xa0/* Chinese SiSheng characters for
                                 * PinYin/ZhuYin (not supported) */
-#define LC_IPA             0xa1        /* IPA (International Phonetic Association)
+#define LC_IPA             0xa1/* IPA (International Phonetic Association)
                                 * (not supported) */
-#define LC_VISCII_LOWER    0xa2    /* Vietnamese VISCII1.1 lower-case (not
+#define LC_VISCII_LOWER        0xa2/* Vietnamese VISCII1.1 lower-case (not
                                 * supported) */
-#define LC_VISCII_UPPER    0xa3    /* Vietnamese VISCII1.1 upper-case (not
+#define LC_VISCII_UPPER        0xa3/* Vietnamese VISCII1.1 upper-case (not
                                 * supported) */
-#define LC_ARABIC_DIGIT    0xa4    /* Arabic digit (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
+#define LC_LAO             0xa7/* Lao characters (ISO10646 0E80..0EDF) (not
                                 * supported) */
 #define LC_ARABIC_2_COLUMN 0xa8    /* Arabic 1-column (not supported) */
 
@@ -127,7 +127,7 @@ typedef unsigned int pg_wchar;
 #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_ETHIOPIC            0xf5    /* Ethiopic characters (not supported) */
 #define LC_CNS11643_3      0xf6    /* CNS 11643-1992 Plane 3 */
 #define LC_CNS11643_4      0xf7    /* CNS 11643-1992 Plane 4 */
 #define LC_CNS11643_5      0xf8    /* CNS 11643-1992 Plane 5 */
@@ -135,7 +135,7 @@ typedef unsigned int pg_wchar;
 #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_TIBETAN         0xfc        /* Tibetan (not supported) */
+#define LC_TIBETAN         0xfc    /* Tibetan (not supported) */
 /* #define FREE                0xfd    free (unused) */
 /* #define FREE                0xfe    free (unused) */
 /* #define FREE                0xff    free (unused) */
@@ -188,7 +188,7 @@ typedef enum pg_enc
    PG_WIN1255,                 /* windows-1255 */
    PG_WIN1257,                 /* windows-1257 */
    /* PG_ENCODING_BE_LAST points to the above entry */
-   
+
    /* followings are for client encoding only */
    PG_SJIS,                    /* Shift JIS (Winindows-932) */
    PG_BIG5,                    /* Big5 (Windows-950) */
@@ -343,24 +343,24 @@ extern void UtfToLocal(const unsigned char *utf, unsigned char *iso,
 
 extern bool pg_verifymbstr(const char *mbstr, int len, bool noError);
 extern bool pg_verify_mbstr(int encoding, const char *mbstr, int len,
-                           bool noError);
+               bool noError);
 
 extern void report_invalid_encoding(int encoding, const char *mbstr, int len);
 extern void report_untranslatable_char(int src_encoding, int dest_encoding,
-                                      const char *mbstr, int len);
+                          const char *mbstr, int len);
 
 extern void pg_ascii2mic(const unsigned char *l, unsigned char *p, int len);
 extern void pg_mic2ascii(const unsigned char *mic, unsigned char *p, int len);
 extern void latin2mic(const unsigned char *l, unsigned char *p, int len,
-                     int lc, int encoding);
+         int lc, int encoding);
 extern void mic2latin(const unsigned char *mic, unsigned char *p, int len,
-                     int lc, int encoding);
+         int lc, int encoding);
 extern void latin2mic_with_table(const unsigned char *l, unsigned char *p,
-                                int len, int lc, int encoding,
-                                const unsigned char *tab);
+                    int len, int lc, int encoding,
+                    const unsigned char *tab);
 extern void mic2latin_with_table(const unsigned char *mic, unsigned char *p,
-                                int len, int lc, int encoding,
-                                const unsigned char *tab);
+                    int len, int lc, int encoding,
+                    const unsigned char *tab);
 
 extern bool pg_utf8_islegal(const unsigned char *source, int length);
 
index 3a93d75f30186c6712aa51ed9ec6a7ace58882ee..48ac42ef3af82202439d341013e81262439f7f10 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/nodes/params.h,v 1.32 2006/09/06 20:40:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/params.h,v 1.33 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,7 +35,7 @@
  * ----------------
  */
 
-#define PARAM_FLAG_CONST   0x0001          /* parameter is constant */
+#define PARAM_FLAG_CONST   0x0001      /* parameter is constant */
 
 typedef struct ParamExternData
 {
index 0b9de4905d10c85fc0477ed771fc2839f6ab66bb..29f68f7fff3d453496fe497b2d6fcaf57d61562e 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.330 2006/09/05 21:08:36 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.331 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -57,7 +57,7 @@ typedef uint32 AclMode;           /* a bitmask of privilege bits */
 #define ACL_USAGE      (1<<8)  /* for languages and namespaces */
 #define ACL_CREATE     (1<<9)  /* for namespaces and databases */
 #define ACL_CREATE_TEMP (1<<10) /* for databases */
-#define ACL_CONNECT        (1<<11) /* for databases */
+#define ACL_CONNECT        (1<<11) /* for databases */
 #define N_ACL_RIGHTS   12      /* 1 plus the last 1<
 #define ACL_NO_RIGHTS  0
 /* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */
@@ -93,9 +93,9 @@ typedef struct Query
                                 * INSERT/UPDATE/DELETE; 0 for SELECT */
 
    RangeVar   *into;           /* target relation for SELECT INTO */
-   List       *intoOptions;        /* options from WITH clause */
+   List       *intoOptions;    /* options from WITH clause */
    OnCommitAction intoOnCommit;    /* what do we do at COMMIT? */
-   char       *intoTableSpaceName; /* table space to use, or NULL */
+   char       *intoTableSpaceName;     /* table space to use, or NULL */
 
    bool        hasAggs;        /* has aggregates in tlist or havingQual */
    bool        hasSubLinks;    /* has subquery SubLink */
@@ -134,17 +134,17 @@ typedef struct Query
    List       *resultRelations;    /* integer list of RT indexes, or NIL */
 
    /*
-    * If the query has a returningList then the planner will store a list
-    * of processed targetlists (one per result relation) here.  We must
-    * have a separate RETURNING targetlist for each result rel because
-    * column numbers may vary within an inheritance tree.  In the targetlists,
-    * Vars referencing the result relation will have their original varno
-    * and varattno, while Vars referencing other rels will be converted
-    * to have varno OUTER and varattno referencing a resjunk entry in the
-    * top plan node's targetlist.  XXX This field ought to go in some sort of
-    * TopPlan plan node, not in the Query.
+    * If the query has a returningList then the planner will store a list of
+    * processed targetlists (one per result relation) here.  We must have a
+    * separate RETURNING targetlist for each result rel because column
+    * numbers may vary within an inheritance tree.  In the targetlists, Vars
+    * referencing the result relation will have their original varno and
+    * varattno, while Vars referencing other rels will be converted to have
+    * varno OUTER and varattno referencing a resjunk entry in the top plan
+    * node's targetlist.  XXX This field ought to go in some sort of TopPlan
+    * plan node, not in the Query.
     */
-   List       *returningLists;     /* list of lists of TargetEntry, or NIL */
+   List       *returningLists; /* list of lists of TargetEntry, or NIL */
 } Query;
 
 
@@ -375,8 +375,8 @@ typedef struct RangeFunction
    NodeTag     type;
    Node       *funccallnode;   /* untransformed function call tree */
    Alias      *alias;          /* table alias & optional column aliases */
-   List       *coldeflist;     /* list of ColumnDef nodes to describe
-                                * result of function returning RECORD */
+   List       *coldeflist;     /* list of ColumnDef nodes to describe result
+                                * of function returning RECORD */
 } RangeFunction;
 
 /*
@@ -414,7 +414,7 @@ typedef struct InhRelation
 {
    NodeTag     type;
    RangeVar   *relation;
-   List       *options;
+   List       *options;
 } InhRelation;
 
 /*
@@ -563,7 +563,7 @@ typedef struct RangeTblEntry
     */
    Node       *funcexpr;       /* expression tree for func call */
    List       *funccoltypes;   /* OID list of column type OIDs */
-   List       *funccoltypmods; /* integer list of column typmods */
+   List       *funccoltypmods; /* integer list of column typmods */
 
    /*
     * Fields valid for a values RTE (else NIL):
@@ -717,15 +717,15 @@ typedef struct SelectStmt
    /*
     * These fields are used only in "leaf" SelectStmts.
     *
-    * into, intoColNames, intoOptions, intoOnCommit, and
-    * intoTableSpaceName are a kluge; they belong somewhere else...
+    * into, intoColNames, intoOptions, intoOnCommit, and intoTableSpaceName
+    * are a kluge; they belong somewhere else...
     */
    List       *distinctClause; /* NULL, list of DISTINCT ON exprs, or
                                 * lcons(NIL,NIL) for all (SELECT DISTINCT) */
    RangeVar   *into;           /* target table (for select into table) */
    List       *intoColNames;   /* column names for into table */
    List       *intoOptions;    /* options from WITH clause */
-   OnCommitAction  intoOnCommit;       /* what do we do at COMMIT? */
+   OnCommitAction intoOnCommit;    /* what do we do at COMMIT? */
    char       *intoTableSpaceName;     /* table space to use, or NULL */
    List       *targetList;     /* the target list (of ResTarget) */
    List       *fromClause;     /* the FROM clause */
@@ -735,11 +735,11 @@ typedef struct SelectStmt
 
    /*
     * In a "leaf" node representing a VALUES list, the above fields are all
-    * null, and instead this field is set.  Note that the elements of
-    * the sublists are just expressions, without ResTarget decoration.
-    * Also note that a list element can be DEFAULT (represented as a
-    * SetToDefault node), regardless of the context of the VALUES list.
-    * It's up to parse analysis to reject that where not valid.
+    * null, and instead this field is set.  Note that the elements of the
+    * sublists are just expressions, without ResTarget decoration. Also note
+    * that a list element can be DEFAULT (represented as a SetToDefault
+    * node), regardless of the context of the VALUES list. It's up to parse
+    * analysis to reject that where not valid.
     */
    List       *valuesLists;    /* untransformed list of expression lists */
 
@@ -1014,7 +1014,7 @@ typedef struct GrantRoleStmt
  *     Copy Statement
  *
  * We support "COPY relation FROM file", "COPY relation TO file", and
- * "COPY (query) TO file".  In any given CopyStmt, exactly one of "relation"
+ * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
  * and "query" must be non-NULL.  Note: "query" is a SelectStmt before
  * parse analysis, and a Query afterwards.
  * ----------------------
@@ -1055,7 +1055,8 @@ typedef struct CreateStmt
    char       *tablespacename; /* table space to use, or NULL */
 } CreateStmt;
 
-typedef enum CreateStmtLikeOption {
+typedef enum CreateStmtLikeOption
+{
    CREATE_TABLE_LIKE_INCLUDING_DEFAULTS,
    CREATE_TABLE_LIKE_EXCLUDING_DEFAULTS,
    CREATE_TABLE_LIKE_INCLUDING_CONSTRAINTS,
@@ -1917,13 +1918,13 @@ typedef struct PrepareStmt
 
 typedef struct ExecuteStmt
 {
-   NodeTag         type;
-   char           *name;               /* The name of the plan to execute */
-   RangeVar       *into;               /* Optional table to store results in */
-   List           *intoOptions;        /* Options from WITH clause */
-   OnCommitAction  into_on_commit;     /* What do we do at COMMIT? */
-   char           *into_tbl_space;     /* Tablespace to use, or NULL */
-   List           *params;             /* Values to assign to parameters */
+   NodeTag     type;
+   char       *name;           /* The name of the plan to execute */
+   RangeVar   *into;           /* Optional table to store results in */
+   List       *intoOptions;    /* Options from WITH clause */
+   OnCommitAction into_on_commit;      /* What do we do at COMMIT? */
+   char       *into_tbl_space; /* Tablespace to use, or NULL */
+   List       *params;         /* Values to assign to parameters */
 } ExecuteStmt;
 
 
index c84bab9287e8207881e7333c06d277266a52c868..841d85336e75d1f983aee106e81a0bf76be5e920 100644 (file)
@@ -10,7 +10,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.116 2006/09/28 20:51:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.117 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -155,7 +155,7 @@ typedef struct Const
  *             For historical reasons, such parameters are numbered from 0.
  *             These numbers are independent of PARAM_EXTERN numbers.
  *
- *     PARAM_SUBLINK:  The parameter represents an output column of a SubLink
+ *     PARAM_SUBLINK:  The parameter represents an output column of a SubLink
  *             node's sub-select.  The column number is contained in the
  *             `paramid' field.  (This type of Param is converted to
  *             PARAM_EXEC during planning.)
@@ -366,7 +366,7 @@ typedef struct BoolExpr
  *
  * NOTE: in the raw output of gram.y, testexpr contains just the raw form
  * of the lefthand expression (if any), and operName is the String name of
- * the combining operator.  Also, subselect is a raw parsetree.  During parse
+ * the combining operator. Also, subselect is a raw parsetree.  During parse
  * analysis, the parser transforms testexpr into a complete boolean expression
  * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the
  * output columns of the subselect.  And subselect is transformed to a Query.
index 471d8e209e232dce4a2cc2278e20028b935fc47d..d39e924227f5716c57f775b234b8d90013493c9a 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.127 2006/09/19 22:49:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.128 2006/10/04 00:30:09 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 modifies
+ * original Query. Note that at present the planner extensively modifies
  * the passed-in Query data structure; someday that should stop.
  *----------
  */
@@ -69,8 +69,8 @@ typedef struct PlannerInfo
     * does not correspond to a base relation, such as a join RTE or an
     * unreferenced view RTE; or if the RelOptInfo hasn't been made yet.
     */
-   struct RelOptInfo **simple_rel_array;   /* All 1-relation RelOptInfos */
-   int         simple_rel_array_size;      /* allocated size of array */
+   struct RelOptInfo **simple_rel_array;       /* All 1-relation RelOptInfos */
+   int         simple_rel_array_size;  /* allocated size of array */
 
    /*
     * join_rel_list is a list of all join-relation RelOptInfos we have
@@ -101,7 +101,7 @@ typedef struct PlannerInfo
 
    List       *in_info_list;   /* list of InClauseInfos */
 
-   List       *append_rel_list;        /* list of AppendRelInfos */
+   List       *append_rel_list;    /* list of AppendRelInfos */
 
    List       *query_pathkeys; /* desired pathkeys for query_planner(), and
                                 * actual pathkeys afterwards */
@@ -109,14 +109,14 @@ typedef struct PlannerInfo
    List       *group_pathkeys; /* groupClause pathkeys, if any */
    List       *sort_pathkeys;  /* sortClause pathkeys, if any */
 
-   double      total_table_pages;  /* # of pages in all tables of query */
+   double      total_table_pages;      /* # of pages in all tables of query */
 
    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 */
    bool        hasHavingQual;  /* true if havingQual was non-null */
-   bool        hasPseudoConstantQuals; /* true if any RestrictInfo has
+   bool        hasPseudoConstantQuals; /* true if any RestrictInfo has
                                         * pseudoconstant = true */
 } PlannerInfo;
 
@@ -144,7 +144,7 @@ typedef struct PlannerInfo
  * Currently the only kind of otherrels are those made for member relations
  * of an "append relation", that is an inheritance set or UNION ALL subquery.
  * An append relation has a parent RTE that is a base rel, which represents
- * the entire append relation.  The member RTEs are otherrels.  The parent
+ * the entire append relation. The member RTEs are otherrels.  The parent
  * is present in the query join tree but the members are not.  The member
  * RTEs and otherrels are used to plan the scans of the individual tables or
  * subqueries of the append set; then the parent baserel is given an Append
@@ -736,7 +736,7 @@ typedef struct HashPath
  *
  * The pseudoconstant flag is set true if the clause contains no Vars of
  * the current query level and no volatile functions.  Such a clause can be
- * pulled out and used as a one-time qual in a gating Result node.  We keep
+ * pulled out and used as a one-time qual in a gating Result node. We keep
  * pseudoconstant clauses in the same lists as other RestrictInfos so that
  * the regular clause-pushing machinery can assign them to the correct join
  * level, but they need to be treated specially for cost and selectivity
@@ -757,7 +757,7 @@ typedef struct RestrictInfo
 
    bool        can_join;       /* see comment above */
 
-   bool        pseudoconstant; /* see comment above */
+   bool        pseudoconstant; /* see comment above */
 
    /* The set of relids (varnos) actually referenced in the clause: */
    Relids      clause_relids;
@@ -836,7 +836,7 @@ typedef struct InnerIndexscanInfo
  * Outer join info.
  *
  * One-sided outer joins constrain the order of joining partially but not
- * completely.  We flatten such joins into the planner's top-level list of
+ * completely. We flatten such joins into the planner's top-level list of
  * relations to join, but record information about each outer join in an
  * OuterJoinInfo struct.  These structs are kept in the PlannerInfo node's
  * oj_info_list.
@@ -925,57 +925,60 @@ typedef struct InClauseInfo
 typedef struct AppendRelInfo
 {
    NodeTag     type;
+
    /*
-    * These fields uniquely identify this append relationship.  There
-    * can be (in fact, always should be) multiple AppendRelInfos for the
-    * same parent_relid, but never more than one per child_relid, since
-    * a given RTE cannot be a child of more than one append parent.
+    * These fields uniquely identify this append relationship.  There can be
+    * (in fact, always should be) multiple AppendRelInfos for the same
+    * parent_relid, but never more than one per child_relid, since a given
+    * RTE cannot be a child of more than one append parent.
     */
    Index       parent_relid;   /* RT index of append parent rel */
    Index       child_relid;    /* RT index of append child rel */
+
    /*
     * For an inheritance appendrel, the parent and child are both regular
     * relations, and we store their rowtype OIDs here for use in translating
-    * whole-row Vars.  For a UNION-ALL appendrel, the parent and child are
+    * whole-row Vars.  For a UNION-ALL appendrel, the parent and child are
     * both subqueries with no named rowtype, and we store InvalidOid here.
     */
-   Oid         parent_reltype; /* OID of parent's composite type */
+   Oid         parent_reltype; /* OID of parent's composite type */
    Oid         child_reltype;  /* OID of child's composite type */
 
    /*
-    * The N'th element of this list is the integer column number of
-    * the child column corresponding to the N'th column of the parent.
-    * A list element is zero if it corresponds to a dropped column of the
-    * parent (this is only possible for inheritance cases, not UNION ALL).
+    * The N'th element of this list is the integer column number of the child
+    * column corresponding to the N'th column of the parent. A list element
+    * is zero if it corresponds to a dropped column of the parent (this is
+    * only possible for inheritance cases, not UNION ALL).
     */
    List       *col_mappings;   /* list of child attribute numbers */
 
    /*
-    * The N'th element of this list is a Var or expression representing
-    * the child column corresponding to the N'th column of the parent.
-    * This is used to translate Vars referencing the parent rel into
-    * references to the child.  A list element is NULL if it corresponds
-    * to a dropped column of the parent (this is only possible for
-    * inheritance cases, not UNION ALL).
+    * The N'th element of this list is a Var or expression representing the
+    * child column corresponding to the N'th column of the parent. This is
+    * used to translate Vars referencing the parent rel into references to
+    * the child.  A list element is NULL if it corresponds to a dropped
+    * column of the parent (this is only possible for inheritance cases, not
+    * UNION ALL).
     *
     * This might seem redundant with the col_mappings data, but it is handy
-    * because flattening of sub-SELECTs that are members of a UNION ALL
-    * will cause changes in the expressions that need to be substituted
-    * for a parent Var.  Adjusting this data structure lets us track what
-    * really needs to be substituted.
+    * because flattening of sub-SELECTs that are members of a UNION ALL will
+    * cause changes in the expressions that need to be substituted for a
+    * parent Var.  Adjusting this data structure lets us track what really
+    * needs to be substituted.
     *
     * Notice we only store entries for user columns (attno > 0).  Whole-row
-    * Vars are special-cased, and system columns (attno < 0) need no
-    * special translation since their attnos are the same for all tables.
+    * Vars are special-cased, and system columns (attno < 0) need no special
+    * translation since their attnos are the same for all tables.
     *
-    * Caution: the Vars have varlevelsup = 0.  Be careful to adjust
-    * as needed when copying into a subquery.
+    * Caution: the Vars have varlevelsup = 0.  Be careful to adjust as needed
+    * when copying into a subquery.
     */
-   List       *translated_vars; /* Expressions in the child's Vars */
+   List       *translated_vars;    /* Expressions in the child's Vars */
+
    /*
-    * We store the parent table's OID here for inheritance, or InvalidOid
-    * for UNION ALL.  This is only needed to help in generating error
-    * messages if an attempt is made to reference a dropped parent column.
+    * We store the parent table's OID here for inheritance, or InvalidOid for
+    * UNION ALL.  This is only needed to help in generating error messages if
+    * an attempt is made to reference a dropped parent column.
     */
    Oid         parent_reloid;  /* OID of parent relation */
 } AppendRelInfo;
index ce61e261a95968281dde3d0fdac94888049b48ac..63acf6b088d3a841717a5d01b04deed16789744c 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/optimizer/cost.h,v 1.81 2006/09/25 22:12:24 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/cost.h,v 1.82 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,7 +27,7 @@
 #define DEFAULT_CPU_INDEX_TUPLE_COST 0.005
 #define DEFAULT_CPU_OPERATOR_COST  0.0025
 
-#define DEFAULT_EFFECTIVE_CACHE_SIZE  16384    /* measured in pages */
+#define DEFAULT_EFFECTIVE_CACHE_SIZE  16384        /* measured in pages */
 
 
 /*
@@ -56,7 +56,7 @@ extern bool constraint_exclusion;
 
 extern double clamp_row_est(double nrows);
 extern double index_pages_fetched(double tuples_fetched, BlockNumber pages,
-                                 double index_pages, PlannerInfo *root);
+                   double index_pages, PlannerInfo *root);
 extern void cost_seqscan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
 extern void cost_index(IndexPath *path, PlannerInfo *root, IndexOptInfo *index,
           List *indexQuals, RelOptInfo *outer_rel);
@@ -71,7 +71,7 @@ extern void cost_subqueryscan(Path *path, RelOptInfo *baserel);
 extern void cost_functionscan(Path *path, PlannerInfo *root,
                  RelOptInfo *baserel);
 extern void cost_valuesscan(Path *path, PlannerInfo *root,
-                 RelOptInfo *baserel);
+               RelOptInfo *baserel);
 extern void cost_sort(Path *path, PlannerInfo *root,
          List *pathkeys, Cost input_cost, double tuples, int width);
 extern void cost_material(Path *path,
index e6005094b78ae84947f8aa0504f375c50ced51ed..f8aebd6a53ad02acf1afae3c863fd56492d24a43 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.71 2006/08/02 01:59:48 joe Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.72 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -86,7 +86,7 @@ extern HashPath *create_hashjoin_path(PlannerInfo *root,
  * prototypes for relnode.c
  */
 extern RelOptInfo *build_simple_rel(PlannerInfo *root, int relid,
-                                   RelOptKind reloptkind);
+                RelOptKind reloptkind);
 extern RelOptInfo *find_base_rel(PlannerInfo *root, int relid);
 extern RelOptInfo *find_join_rel(PlannerInfo *root, Relids relids);
 extern RelOptInfo *build_join_rel(PlannerInfo *root,
index 173c7f846beee6bc65c8faa675711f4cb2701f20..50ff6ac286d25fdafd2a570895be26181cbc3ef8 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/optimizer/plancat.h,v 1.41 2006/09/19 22:49:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/plancat.h,v 1.42 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 
 extern void get_relation_info(PlannerInfo *root, Oid relationObjectId,
-                             bool inhparent, RelOptInfo *rel);
+                 bool inhparent, RelOptInfo *rel);
 
 extern bool relation_excluded_by_constraints(RelOptInfo *rel,
-                                            RangeTblEntry *rte);
+                                RangeTblEntry *rte);
 
 extern List *build_physical_tlist(PlannerInfo *root, RelOptInfo *rel);
 
index 88e4aa56a7968b6b7b4b559541c136dedab3bdfe..544dc766e8cd05e341bf9bb4f775bc7874d0670f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/optimizer/prep.h,v 1.56 2006/03/05 15:58:57 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/prep.h,v 1.57 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -51,8 +51,8 @@ extern void expand_inherited_tables(PlannerInfo *root);
 extern Node *adjust_appendrel_attrs(Node *node, AppendRelInfo *appinfo);
 
 extern Relids *adjust_appendrel_attr_needed(RelOptInfo *oldrel,
-                                           AppendRelInfo *appinfo,
-                                           AttrNumber new_min_attr,
-                                           AttrNumber new_max_attr);
+                            AppendRelInfo *appinfo,
+                            AttrNumber new_min_attr,
+                            AttrNumber new_max_attr);
 
 #endif   /* PREP_H */
index 86add7916047a7a58356745b4fefddd861006c55..db24c4989db1a8f0bcbb43dec87246691798c634 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.37 2006/07/01 18:38:33 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/restrictinfo.h,v 1.38 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,7 +28,7 @@ extern List *make_restrictinfo_from_bitmapqual(Path *bitmapqual,
 extern bool restriction_is_or_clause(RestrictInfo *restrictinfo);
 extern List *get_actual_clauses(List *restrictinfo_list);
 extern List *extract_actual_clauses(List *restrictinfo_list,
-                                   bool pseudoconstant);
+                      bool pseudoconstant);
 extern void extract_actual_join_clauses(List *restrictinfo_list,
                            List **joinquals,
                            List **otherquals);
index 0b245c77e8390b36f0b27cb859d655aa85a2205b..7866472f79ea72f7809f8e888666381b649f7d78 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.33 2006/04/30 18:30:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.34 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 
 extern List *parse_analyze(Node *parseTree, const char *sourceText,
-                          Oid *paramTypes, int numParams);
+             Oid *paramTypes, int numParams);
 extern List *parse_analyze_varparams(Node *parseTree, const char *sourceText,
-                                    Oid **paramTypes, int *numParams);
+                       Oid **paramTypes, int *numParams);
 extern List *parse_sub_analyze(Node *parseTree, ParseState *parentParseState);
 extern List *analyzeCreateSchemaStmt(CreateSchemaStmt *stmt);
 extern void CheckSelectLocking(Query *qry);
 extern void applyLockingClause(Query *qry, Index rtindex,
-                              bool forUpdate, bool noWait);
+                  bool forUpdate, bool noWait);
 
 #endif   /* ANALYZE_H */
index 84d119df7624819833629da71926f0f009b02473..e29a64d48f479a4be154e80bde596b5c0b50b3d8 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/parser/parse_coerce.h,v 1.65 2006/07/26 19:31:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_coerce.h,v 1.66 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -58,7 +58,7 @@ extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
 extern Node *coerce_to_integer(ParseState *pstate, Node *node,
                  const char *constructName);
 extern Node *coerce_to_bigint(ParseState *pstate, Node *node,
-                             const char *constructName);
+                const char *constructName);
 
 extern Oid select_common_type(List *typeids, const char *context);
 extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
index 486e5ea44da88f0fb879ced55b92ba96b231ea22..a27c1249fff1d4324ea5403d6f50fe244d8c327a 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/parser/parse_func.h,v 1.56 2006/04/15 17:45:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_func.h,v 1.57 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -77,6 +77,6 @@ extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes,
 extern Oid LookupFuncNameTypeNames(List *funcname, List *argtypes,
                        bool noError);
 extern Oid LookupAggNameTypeNames(List *aggname, List *argtypes,
-                       bool noError);
+                      bool noError);
 
 #endif   /* PARSE_FUNC_H */
index 1a28d099546f170b81fe50d03065d0e5bc7c92ef..2425022be61b066755347ca38852bc922847f341 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/parser/parse_node.h,v 1.49 2006/04/30 18:30:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_node.h,v 1.50 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -24,7 +24,7 @@
  * links to current parse state of outer query.
  *
  * p_sourcetext: source string that generated the raw parsetree being
- * analyzed, or NULL if not available.  (The string is used only to
+ * analyzed, or NULL if not available. (The string is used only to
  * generate cursor positions in error messages: we need it to convert
  * byte-wise locations in parse structures to character-wise cursor
  * positions.)
@@ -71,8 +71,8 @@ typedef struct ParseState
    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 */
-   List       *p_locking_clause;   /* raw FOR UPDATE/FOR SHARE info */
-   Node       *p_value_substitute; /* what to replace VALUE with, if any */
+   List       *p_locking_clause;       /* raw FOR UPDATE/FOR SHARE info */
+   Node       *p_value_substitute;     /* what to replace VALUE with, if any */
    bool        p_variableparams;
    bool        p_hasAggs;
    bool        p_hasSubLinks;
index 33e54ef01e07950ca22604b267e3c53bc7276a08..1141b07c1bef4b7d6be75704edd1f8208134afda 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/parser/parse_oper.h,v 1.39 2006/03/14 22:48:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_oper.h,v 1.40 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,26 +22,26 @@ typedef HeapTuple Operator;
 
 /* Routines to look up an operator given name and exact input type(s) */
 extern Oid LookupOperName(ParseState *pstate, List *opername,
-                         Oid oprleft, Oid oprright,
-                         bool noError, int location);
+              Oid oprleft, Oid oprright,
+              bool noError, int location);
 extern Oid LookupOperNameTypeNames(ParseState *pstate, List *opername,
-                                  TypeName *oprleft, TypeName *oprright,
-                                  bool noError, int location);
+                       TypeName *oprleft, TypeName *oprright,
+                       bool noError, int location);
 
 /* Routines to find operators matching a name and given input types */
 /* NB: the selected operator may require coercion of the input types! */
 extern Operator oper(ParseState *pstate, List *op, Oid arg1, Oid arg2,
-                    bool noError, int location);
+    bool noError, int location);
 extern Operator right_oper(ParseState *pstate, List *op, Oid arg,
-                          bool noError, int location);
+          bool noError, int location);
 extern Operator left_oper(ParseState *pstate, List *op, Oid arg,
-                         bool noError, int location);
+         bool noError, int location);
 
 /* Routines to find operators that DO NOT require coercion --- ie, their */
 /* input types are either exactly as given, or binary-compatible */
 extern Operator compatible_oper(ParseState *pstate, List *op,
-                               Oid arg1, Oid arg2,
-                               bool noError, int location);
+               Oid arg1, Oid arg2,
+               bool noError, int location);
 
 /* currently no need for compatible_left_oper/compatible_right_oper */
 
index 9e2df63c54a4104ac36674929d0c5c1d44e8719d..fdd4cf5fe1d3da4bb2ab0baa467754bcc7c6bd8c 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/parser/parse_relation.h,v 1.54 2006/08/02 01:59:48 joe Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_relation.h,v 1.55 2006/10/04 00:30:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,7 +33,7 @@ extern RangeTblEntry *GetRTEByRangeTablePosn(ParseState *pstate,
 extern Node *scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte,
                 char *colname, int location);
 extern Node *colNameToVar(ParseState *pstate, char *colname, bool localonly,
-                         int location);
+            int location);
 extern Node *qualifiedNameToVar(ParseState *pstate,
                   char *schemaname,
                   char *refname,
@@ -73,7 +73,7 @@ extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
              bool addToJoinList,
              bool addToRelNameSpace, bool addToVarNameSpace);
 extern RangeTblEntry *addImplicitRTE(ParseState *pstate, RangeVar *relation,
-                                    int location);
+              int location);
 extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
          bool include_dropped,
          List **colnames, List **colvars);
index 6c35cb2e8ddd3924c2d9cafcaa5962954cd44120..77862ff0e370478107ce25cf539b39720b6547e4 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/pg_trace.h,v 1.1 2006/07/24 16:32:45 petere Exp $
+ * $PostgreSQL: pgsql/src/include/pg_trace.h,v 1.2 2006/10/04 00:30:06 momjian Exp $
  * ----------
  */
 
@@ -21,7 +21,7 @@
  *
  * Only one DTrace provider called "postgresql" will be used for PostgreSQL,
  * so the name is hard-coded here to avoid having to specify it in the
- * source code. 
+ * source code.
  */
 
 #define PG_TRACE(name) \
@@ -36,8 +36,7 @@
    DTRACE_PROBE4(postgresql, name, arg1, arg2, arg3, arg4)
 #define PG_TRACE5(name, arg1, arg2, arg3, arg4, arg5) \
    DTRACE_PROBE5(postgresql, name, arg1, arg2, arg3, arg4, arg5)
-
-#else /* not ENABLE_DTRACE */
+#else                          /* not ENABLE_DTRACE */
 
 /*
  * Unless DTrace is explicitly enabled with --enable-dtrace, the PG_TRACE
@@ -50,7 +49,6 @@
 #define PG_TRACE3(name, arg1, arg2, arg3)
 #define PG_TRACE4(name, arg1, arg2, arg3, arg4)
 #define PG_TRACE5(name, arg1, arg2, arg3, arg4, arg5)
+#endif   /* not ENABLE_DTRACE */
 
-#endif /* not ENABLE_DTRACE */
-
-#endif /* PG_TRACE_H */
+#endif   /* PG_TRACE_H */
index 35614eaa2d29078c47e2e59b9470dd08c7965d32..8f5db7707957bcf94cfe55fdbc91a0a30c367f10 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 2001-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.49 2006/08/19 01:36:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.50 2006/10/04 00:30:06 momjian Exp $
  * ----------
  */
 #ifndef PGSTAT_H
@@ -205,8 +205,8 @@ typedef struct PgStat_MsgAnalyze
    PgStat_MsgHdr m_hdr;
    Oid         m_databaseid;
    Oid         m_tableoid;
-   bool        m_autovacuum; 
-   TimestampTz m_analyzetime; 
+   bool        m_autovacuum;
+   TimestampTz m_analyzetime;
    PgStat_Counter m_live_tuples;
    PgStat_Counter m_dead_tuples;
 } PgStat_MsgAnalyze;
@@ -285,10 +285,10 @@ typedef struct PgStat_StatTabEntry
    PgStat_Counter blocks_fetched;
    PgStat_Counter blocks_hit;
 
-   TimestampTz vacuum_timestamp; /* user initiated vacuum */
-   TimestampTz autovac_vacuum_timestamp; /* autovacuum initiated */
-   TimestampTz analyze_timestamp; /* user initiated */
-   TimestampTz autovac_analyze_timestamp; /* autovacuum initiated */
+   TimestampTz vacuum_timestamp;       /* user initiated vacuum */
+   TimestampTz autovac_vacuum_timestamp;       /* autovacuum initiated */
+   TimestampTz analyze_timestamp;      /* user initiated */
+   TimestampTz autovac_analyze_timestamp;      /* autovacuum initiated */
 } PgStat_StatTabEntry;
 
 
@@ -314,8 +314,8 @@ typedef struct PgBackendStatus
    /*
     * To avoid locking overhead, we use the following protocol: a backend
     * increments st_changecount before modifying its entry, and again after
-    * finishing a modification.  A would-be reader should note the value
-    * of st_changecount, copy the entry into private memory, then check
+    * finishing a modification.  A would-be reader should note the value of
+    * st_changecount, copy the entry into private memory, then check
     * st_changecount again.  If the value hasn't changed, and if it's even,
     * the copy is valid; otherwise start over.  This makes updates cheap
     * while reads are potentially expensive, but that's the tradeoff we want.
index cf3694f4f526f7dd25011e8d565067a11e9c104f..c3204184769397116cc45a7be6b796a68bb874ea 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/port.h,v 1.103 2006/10/03 22:18:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.104 2006/10/04 00:30:06 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -97,22 +97,22 @@ extern int find_other_exec(const char *argv0, const char *target,
  *
  * Generated using Win32 "CMD /?":
  *
- *  1. If all of the following conditions are met, then quote characters
- *  on the command line are preserved:
+ * 1. If all of the following conditions are met, then quote characters
+ * on the command line are preserved:
  *
- *   - no /S switch
- *   - exactly two quote characters
- *   - no special characters between the two quote characters, where special
- *     is one of: &<>()@^|
- *   - there are one or more whitespace characters between the the two quote
- *     characters
- *   - the string between the two quote characters is the name of an
- *     executable file.
+ *  - no /S switch
+ *  - exactly two quote characters
+ *  - no special characters between the two quote characters, where special
+ *    is one of: &<>()@^|
+ *  - there are one or more whitespace characters between the the two quote
+ *    characters
+ *  - the string between the two quote characters is the name of an
+ *    executable file.
  *
- *   2. Otherwise, old behavior is to see if the first character is a quote
- *   character and if so, strip the leading character and remove the last
- *   quote character on the command line, preserving any text after the last
- *   quote character.
+ *  2. Otherwise, old behavior is to see if the first character is a quote
+ *  character and if so, strip the leading character and remove the last
+ *  quote character on the command line, preserving any text after the last
+ *  quote character.
  */
 #if defined(WIN32) && !defined(__CYGWIN__)
 #define SYSTEMQUOTE "\""
@@ -133,7 +133,7 @@ extern unsigned char pg_tolower(unsigned char ch);
 
 /*
  * Versions of libintl >= 0.13 try to replace printf() and friends with
- * macros to their own versions that understand the %$ format.  We do the
+ * macros to their own versions that understand the %$ format. We do the
  * same, so disable their macros, if they exist.
  */
 #ifdef vsnprintf
@@ -188,8 +188,7 @@ __attribute__((format(printf, 1, 2)));
 #define fprintf            pg_fprintf
 #define printf         pg_printf
 #endif
-
-#endif /* USE_REPL_SNPRINTF */
+#endif   /* USE_REPL_SNPRINTF */
 
 /* Portable prompt handling */
 extern char *simple_prompt(const char *prompt, int maxlen, bool echo);
@@ -272,7 +271,7 @@ extern int  pgwin32_open(const char *, int,...);
 extern FILE *pgwin32_fopen(const char *, const char *);
 
 #ifndef FRONTEND
-#define        open(a,b,c) pgwin32_open(a,b,c)
+#define        open(a,b,c) pgwin32_open(a,b,c)
 #define        fopen(a,b) pgwin32_fopen(a,b)
 #endif
 
@@ -367,6 +366,6 @@ extern int pqGethostbyname(const char *name,
 typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg);
 
 extern void qsort_arg(void *base, size_t nel, size_t elsize,
-                     qsort_arg_comparator cmp, void *arg);
+         qsort_arg_comparator cmp, void *arg);
 
-#endif /* PG_PORT_H */
+#endif   /* PG_PORT_H */
index e52a8726817ed17cbf21ab7a40903c567e394d35..ff3e2193230b91a7856e4c1e33b249edf4b7c2c1 100644 (file)
@@ -1,7 +1,8 @@
-/* $PostgreSQL: pgsql/src/include/port/darwin.h,v 1.10 2006/03/11 04:38:38 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/darwin.h,v 1.11 2006/10/04 00:30:09 momjian Exp $ */
 
 #define __darwin__ 1
 
 #if HAVE_DECL_F_FULLFSYNC      /* not present before OS X 10.3 */
 #define HAVE_FSYNC_WRITETHROUGH
+
 #endif
index a4d8f247bc28f0c961e8ae6e6c96c5a7ca95c326..05cba063a9177965687bc02f3966e82539c20f19 100644 (file)
@@ -1,2 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/linux.h,v 1.41 2006/03/11 04:38:38 momjian Exp $ */
-
+/* $PostgreSQL: pgsql/src/include/port/linux.h,v 1.42 2006/10/04 00:30:09 momjian Exp $ */
index 59b78cccd3c2575e79697d141191425fbb0c96aa..9f1666b71a2826d15aa9c3f8fcb6e384505eb403 100644 (file)
@@ -1,2 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/netbsd.h,v 1.15 2006/03/11 04:38:38 momjian Exp $ */
-
+/* $PostgreSQL: pgsql/src/include/port/netbsd.h,v 1.16 2006/10/04 00:30:10 momjian Exp $ */
index f5e17aae3ecb285aec816e949b1acd78e980eb15..e3bc767689a502631bf090f5a466d0b4b8a539e1 100644 (file)
@@ -1,7 +1,7 @@
-/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.61 2006/10/03 20:33:20 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.62 2006/10/04 00:30:10 momjian Exp $ */
 
 #if defined(_MSC_VER) || defined(__BORLANDC__)
-#define    WIN32_ONLY_COMPILER
+#define WIN32_ONLY_COMPILER
 #endif
 
 /* undefine and redefine after #include */
@@ -17,7 +17,7 @@
 #include 
 #include 
 #include 
-#include  /* for non-unicode version */
+#include          /* for non-unicode version */
 #undef near
 
 /* Must be here to avoid conflicting with prototype in windows.h */
@@ -46,7 +46,6 @@
 #else                          /* not BUILDING_DLL */
 #define DLLIMPORT __declspec (dllimport)
 #endif
-
 #else                          /* not CYGWIN, not MSVC, not MingW */
 
 #define DLLIMPORT
@@ -166,7 +165,7 @@ struct itimerval
    struct timeval it_interval;
    struct timeval it_value;
 };
-int            setitimer(int which, const struct itimerval *value, struct itimerval *ovalue);
+int            setitimer(int which, const struct itimerval * value, struct itimerval * ovalue);
 
 
 /*
@@ -293,4 +292,5 @@ typedef unsigned short mode_t;
 
 /* Pulled from Makefile.port in mingw */
 #define DLSUFFIX ".dll"
+
 #endif
index 55a59c202bd093079bbe00bc92cc0654295355bf..e508867a6f702b36f2959fce63bf3994cb904158 100644 (file)
@@ -1,3 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32/dlfcn.h,v 1.3 2006/03/11 04:38:38 momjian Exp $ */
-
-
+/* $PostgreSQL: pgsql/src/include/port/win32/dlfcn.h,v 1.4 2006/10/04 00:30:10 momjian Exp $ */
index 162734f4408d3955d70b2afbc746105f07d888e1..c9bc172547f849644a40f36ab56ef2d51e922d33 100644 (file)
@@ -1,3 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32/grp.h,v 1.3 2006/03/11 04:38:38 momjian Exp $ */
-
-
+/* $PostgreSQL: pgsql/src/include/port/win32/grp.h,v 1.4 2006/10/04 00:30:10 momjian Exp $ */
index 0243e3eefbf8bdfcad480ab9a7e955753bbee9b5..e88e30f8e66c67520406181cea158c81dc999476 100644 (file)
@@ -1,2 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32/netdb.h,v 1.3 2006/03/11 04:38:38 momjian Exp $ */
-
+/* $PostgreSQL: pgsql/src/include/port/win32/netdb.h,v 1.4 2006/10/04 00:30:10 momjian Exp $ */
index beec4e2f8606e6e753abe8c2d19ac14dd28f0660..97a504179918761a9324e8747236768ce6f98ffa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/src/include/port/win32/sys/socket.h,v 1.6 2006/07/16 01:35:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/port/win32/sys/socket.h,v 1.7 2006/10/04 00:30:10 momjian Exp $
  */
 #ifndef WIN32_SYS_SOCKET_H
 #define WIN32_SYS_SOCKET_H
@@ -29,4 +29,4 @@
  */
 #undef gai_strerror
 
-#endif /* WIN32_SYS_SOCKET_H */
+#endif   /* WIN32_SYS_SOCKET_H */
index e44a602c3b6ae73bc7e40b90cc21d28c31d86db8..422691aca2d8a8ab9f73c33f067cacc0730f5e9f 100644 (file)
@@ -1,21 +1,23 @@
 /*
  * Headers for port/dirent.c, win32 native implementation of dirent functions
  *
- * $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.2 2006/06/26 12:59:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.3 2006/10/04 00:30:10 momjian Exp $
  */
 
 #ifndef _WIN32VC_DIRENT_H
 #define _WIN32VC_DIRENT_H
-struct dirent {
-   long d_ino;
+struct dirent
+{
+   long        d_ino;
    unsigned short d_reclen;
    unsigned short d_namlen;
-   char d_name[MAX_PATH];
+   char        d_name[MAX_PATH];
 };
 
 typedef struct DIR DIR;
 
-DIR* opendir(const char *);
-struct dirent* readdir(DIR *);
-int closedir(DIR*);
+DIR           *opendir(const char *);
+struct dirent *readdir(DIR *);
+int            closedir(DIR *);
+
 #endif
index 8adc35c6e087f42bb0f413ed3edf9cdb661a0001..c9c080f958313a49bda8d02941ac2d4c9a7b6eaa 100644 (file)
@@ -1 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/file.h,v 1.2 2006/06/26 12:52:12 momjian Exp $ */ 
+/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/file.h,v 1.3 2006/10/04 00:30:10 momjian Exp $ */
index 02282288806c9e1c6e6f6bf3703f459d0e0c4357..a09b35a16954ad8837f72dc1f6a7c7df43bb97f3 100644 (file)
@@ -1 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/param.h,v 1.2 2006/06/26 12:52:12 momjian Exp $ */ 
+/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/param.h,v 1.3 2006/10/04 00:30:10 momjian Exp $ */
index cb1a65a9798256945639bdea186aed4975c9556a..6fc2ab7f536963f4271bcc874395ae63d1f1ed14 100644 (file)
@@ -1 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/time.h,v 1.2 2006/06/26 12:52:12 momjian Exp $ */ 
+/* $PostgreSQL: pgsql/src/include/port/win32_msvc/sys/time.h,v 1.3 2006/10/04 00:30:10 momjian Exp $ */
index d3214b57ee9afb160b37ea0973ee9da1c8470cf8..f5290aeafaed212bf698cfcbfd78e0c334f3cbf0 100644 (file)
@@ -1 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32_msvc/unistd.h,v 1.2 2006/06/26 12:52:12 momjian Exp $ */ 
+/* $PostgreSQL: pgsql/src/include/port/win32_msvc/unistd.h,v 1.3 2006/10/04 00:30:10 momjian Exp $ */
index b13c26023b7f8aa6aa48560d26c30febeba368c4..006c6a8396faf2e68216146a7795eebe96d34660 100644 (file)
@@ -1 +1 @@
-/* $PostgreSQL: pgsql/src/include/port/win32_msvc/utime.h,v 1.2 2006/06/26 12:52:12 momjian Exp $ */ 
+/* $PostgreSQL: pgsql/src/include/port/win32_msvc/utime.h,v 1.3 2006/10/04 00:30:10 momjian Exp $ */
index ff0e0bb71019b0964990d30323cd78e7f46475bb..404fb2f9558da775e763a46ea33c2b5b2e16e90f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.22 2006/09/21 20:31:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.23 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -115,7 +115,7 @@ struct FSMRelation
    FSMRelation *priorPhysical; /* prior rel in arena-storage order */
    bool        isIndex;        /* if true, we store only page numbers */
    Size        avgRequest;     /* moving average of space requests */
-   BlockNumber interestingPages;   /* # of pages with useful free space */
+   BlockNumber interestingPages;       /* # of pages with useful free space */
    int         firstChunk;     /* chunk # of my first chunk in arena */
    int         storedPages;    /* # of pages stored in arena */
    int         nextPage;       /* index (from 0) to start next search at */
@@ -142,15 +142,15 @@ extern BlockNumber RecordAndGetPageWithFreeSpace(RelFileNode *rel,
                              Size spaceNeeded);
 extern Size GetAvgFSMRequestSize(RelFileNode *rel);
 extern void RecordRelationFreeSpace(RelFileNode *rel,
-                                   BlockNumber interestingPages,
-                                   int nPages,
-                                   PageFreeSpaceInfo *pageSpaces);
+                       BlockNumber interestingPages,
+                       int nPages,
+                       PageFreeSpaceInfo *pageSpaces);
 
 extern BlockNumber GetFreeIndexPage(RelFileNode *rel);
 extern void RecordIndexFreeSpace(RelFileNode *rel,
-                                BlockNumber interestingPages,
-                                int nPages,
-                                BlockNumber *pages);
+                    BlockNumber interestingPages,
+                    int nPages,
+                    BlockNumber *pages);
 
 extern void FreeSpaceMapTruncateRel(RelFileNode *rel, BlockNumber nblocks);
 extern void FreeSpaceMapForgetRel(RelFileNode *rel);
index 9717c3f2558b35fe667bad1d2f2f6da851ff034a..6b91acc3eaadcea74a02161cc95a91ae1cdcb3d0 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.100 2006/09/22 23:20:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.101 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -82,7 +82,7 @@ typedef struct LockMethodData
    int         numLockModes;
    bool        transactional;
    const LOCKMASK *conflictTab;
-   const char * const *lockModeNames;
+   const char *const * lockModeNames;
    const bool *trace_flag;
 } LockMethodData;
 
index 65a482468d371be3fd5aad1a4b109af6cc22db5c..91f6cf78ed9619dba3f00878648fd7c51c6a97d7 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/pg_sema.h,v 1.9 2006/04/29 16:34:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/pg_sema.h,v 1.10 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -56,7 +56,7 @@ typedef struct PGSemaphoreData
 
 #ifdef USE_WIN32_SEMAPHORES
 
-typedef HANDLE PGSemaphoreData;
+typedef HANDLE PGSemaphoreData;
 #endif
 
 typedef PGSemaphoreData *PGSemaphore;
index 47f6709a674f0297af8ae10d2d78192381d83871..52de6a940480523ca2521145ff27021364d7d1ec 100644 (file)
@@ -17,7 +17,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.19 2006/08/01 19:03:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.20 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -54,7 +54,7 @@ extern void PGSharedMemoryDetach(void);
 
 extern void RegisterAddinContext(const char *name, Size size);
 extern Size AddinShmemSize(void);
-extern void InitAddinContexts(void * start);
+extern void InitAddinContexts(void *start);
 extern void *ShmemAllocFromContext(Size size, const char *name);
 extern void ShmemResetContext(const char *name);
 
index 0345b42f977eb60116b5d85a72d5dd6adfe5f891..005716dc09d1527c784809353032c4c94fe961ad 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.90 2006/07/30 02:07:18 alvherre Exp $
+ * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.91 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -75,7 +75,7 @@ struct PGPROC
    Oid         roleId;         /* OID of role using this backend */
 
    bool        inVacuum;       /* true if current xact is a LAZY VACUUM */
-   
+
    /* Info about LWLock the process is currently waiting for, if any. */
    bool        lwWaiting;      /* true if waiting for an LW lock */
    bool        lwExclusive;    /* true if waiting for exclusive access */
index a2913e95a159113b8038ffaef4085ee720568d7e..e6637edeb7f4e34e26449bc6c80d0eac1c6d77aa 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.83 2006/09/08 15:55:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.84 2006/10/04 00:30:10 momjian Exp $
  *
  * OLD COMMENTS
  *   This file was created so that other c files could get the two
@@ -68,7 +68,7 @@ extern int    check_log_duration(char *msec_str, bool was_logged);
 extern void set_debug_options(int debug_flag,
                  GucContext context, GucSource source);
 extern bool set_plan_disabling_options(const char *arg,
-                                     GucContext context, GucSource source);
+                          GucContext context, GucSource source);
 extern const char *get_stats_option_name(const char *arg);
 
 #endif   /* TCOPPROT_H */
index 56226b42162473e2b10423beb3cac9b78c73257e..5232b2b40a2016b8d7e6e3f48bdfb9c4b7f20e30 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.97 2006/09/05 21:08:36 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/acl.h,v 1.98 2006/10/04 00:30:10 momjian Exp $
  *
  * NOTES
  *   An ACL array is simply an array of AclItems, representing the union
@@ -193,13 +193,13 @@ typedef enum AclObjectKind
  */
 typedef struct
 {
-   bool    is_grant;
+   bool        is_grant;
    GrantObjectType objtype;
-   List   *objects;
-   bool    all_privs;
-   AclMode privileges;
-   List   *grantees;
-   bool    grant_option;
+   List       *objects;
+   bool        all_privs;
+   AclMode     privileges;
+   List       *grantees;
+   bool        grant_option;
    DropBehavior behavior;
 } InternalGrant;
 
index 6c1ad164e331bb145f8b259a16feb223cc872bca..cbd6d9945a426ae6db17e803a45b117d947eafa7 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.61 2006/07/13 18:01:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.62 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,7 +76,7 @@ typedef struct catctup
 
    /*
     * Each tuple in a cache is a member of a Dllist that stores the elements
-    * of its hash bucket.  We keep each Dllist in LRU order to speed repeated
+    * of its hash bucket.  We keep each Dllist in LRU order to speed repeated
     * lookups.
     */
    Dlelem      cache_elem;     /* list member of per-bucket list */
index c682cf032959de84b397dc6810c33b72a2a2c3fa..5582b88ee666f069605ce7a21d6a66a7662c5287 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.44 2006/07/22 23:04:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.45 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,7 +64,7 @@ typedef struct HTAB HTAB;
 /* Only those fields indicated by hash_flags need be set */
 typedef struct HASHCTL
 {
-   long        num_partitions; /* # partitions (must be power of 2) */
+   long        num_partitions; /* # partitions (must be power of 2) */
    long        ssize;          /* segment size */
    long        dsize;          /* (initial) directory size */
    long        max_dsize;      /* limit to dsize if dir size is limited */
@@ -125,8 +125,8 @@ extern void *hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action,
            bool *foundPtr);
 extern uint32 get_hash_value(HTAB *hashp, const void *keyPtr);
 extern void *hash_search_with_hash_value(HTAB *hashp, const void *keyPtr,
-           uint32 hashvalue, HASHACTION action,
-           bool *foundPtr);
+                           uint32 hashvalue, HASHACTION action,
+                           bool *foundPtr);
 extern long hash_get_num_entries(HTAB *hashp);
 extern void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp);
 extern void *hash_seq_search(HASH_SEQ_STATUS *status);
index 208cba30476db4cc0543858d2a339653afdd6b66..69eb31bcc559d7fda7a3ff530f439853d9e1a637 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.106 2006/09/28 20:51:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.107 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,7 +34,7 @@ extern void get_op_opclass_properties(Oid opno, Oid opclass,
 extern Oid get_opclass_member(Oid opclass, Oid subtype, int16 strategy);
 extern Oid get_op_hash_function(Oid opno);
 extern void get_op_btree_interpretation(Oid opno,
-                                       List **opclasses, List **opstrats);
+                           List **opclasses, List **opstrats);
 extern Oid get_opclass_proc(Oid opclass, Oid subtype, int16 procnum);
 extern char *get_attname(Oid relid, AttrNumber attnum);
 extern char *get_relid_attribute_name(Oid relid, AttrNumber attnum);
index a377b0ca21abe52eed2cfd1a8cba6e3e2a7b54e0..3a4e9f4e478b80197acab0c72f37be2319a0b1e1 100644 (file)
@@ -39,7 +39,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.70 2006/09/07 22:52:01 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.71 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -176,7 +176,7 @@ typedef struct PortalData
    long        portalPos;
 
    /* Presentation data, primarily used by the pg_cursors system view */
-   TimestampTz creation_time;  /* time at which this portal was defined */
+   TimestampTz creation_time;  /* time at which this portal was defined */
    bool        visible;        /* include this portal in pg_cursors? */
 } PortalData;
 
index 7bb1b270a495dffdf8f09371ca1ef8012b38d9c5..1f7347c9cdce8a6c032194b72123d1b18597efd1 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.91 2006/07/03 22:45:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.92 2006/10/04 00:30:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -156,8 +156,8 @@ typedef struct RelationData
 
    /*
     * rd_options is set whenever rd_rel is loaded into the relcache entry.
-    * Note that you can NOT look into rd_rel for this data.  NULL means
-    * "use defaults".
+    * Note that you can NOT look into rd_rel for this data.  NULL means "use
+    * defaults".
     */
    bytea      *rd_options;     /* parsed pg_class.reloptions */
 
@@ -179,7 +179,7 @@ typedef struct RelationData
     * Note: rd_amcache is available for index AMs to cache private data about
     * an index.  This must be just a cache since it may get reset at any time
     * (in particular, it will get reset by a relcache inval message for the
-    * index).  If used, it must point to a single memory chunk palloc'd in
+    * index).  If used, it must point to a single memory chunk palloc'd in
     * rd_indexcxt.  A relcache reset will include freeing that chunk and
     * setting rd_amcache = NULL.
     */
@@ -218,8 +218,8 @@ typedef Relation *RelationPtr;
  */
 typedef struct StdRdOptions
 {
-   int32   vl_len;             /* required to be a bytea */
-   int     fillfactor;         /* page fill factor in percent (0..100) */
+   int32       vl_len;         /* required to be a bytea */
+   int         fillfactor;     /* page fill factor in percent (0..100) */
 } StdRdOptions;
 
 #define HEAP_MIN_FILLFACTOR            10
index 83e17e4184a271830ac48afabf5312de0c16bf53..fd88be99694e942d11c90002084c224ecebe99b3 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/resowner.h,v 1.8 2006/07/13 18:01:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/resowner.h,v 1.9 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -109,8 +109,8 @@ extern void ResourceOwnerForgetRelationRef(ResourceOwner owner,
 /* support for tupledesc refcount management */
 extern void ResourceOwnerEnlargeTupleDescs(ResourceOwner owner);
 extern void ResourceOwnerRememberTupleDesc(ResourceOwner owner,
-                                          TupleDesc tupdesc);
+                              TupleDesc tupdesc);
 extern void ResourceOwnerForgetTupleDesc(ResourceOwner owner,
-                                        TupleDesc tupdesc);
+                            TupleDesc tupdesc);
 
 #endif   /* RESOWNER_H */
index aea2501ca397aebe59e14464aa685c10e3e06d50..69a22b37b56f1c7a577447caac1837c557ffbb1d 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.35 2006/09/20 19:50:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/selfuncs.h,v 1.36 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -98,21 +98,21 @@ typedef enum
 /* selfuncs.c */
 
 extern void examine_variable(PlannerInfo *root, Node *node, int varRelid,
-                            VariableStatData *vardata);
+                VariableStatData *vardata);
 extern bool get_restriction_variable(PlannerInfo *root, List *args,
-                                    int varRelid,
-                                    VariableStatData *vardata, Node **other,
-                                    bool *varonleft);
+                        int varRelid,
+                        VariableStatData *vardata, Node **other,
+                        bool *varonleft);
 extern void get_join_variables(PlannerInfo *root, List *args,
-                              VariableStatData *vardata1,
-                              VariableStatData *vardata2);
+                  VariableStatData *vardata1,
+                  VariableStatData *vardata2);
 extern double get_variable_numdistinct(VariableStatData *vardata);
 extern double mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc,
-                             Datum constval, bool varonleft,
-                             double *sumcommonp);
+               Datum constval, bool varonleft,
+               double *sumcommonp);
 extern double histogram_selectivity(VariableStatData *vardata, FmgrInfo *opproc,
-                                   Datum constval, bool varonleft,
-                                   int min_hist_size, int n_skip);
+                     Datum constval, bool varonleft,
+                     int min_hist_size, int n_skip);
 
 extern Pattern_Prefix_Status pattern_fixed_prefix(Const *patt,
                     Pattern_Type ptype,
@@ -151,13 +151,13 @@ extern Selectivity booltestsel(PlannerInfo *root, BoolTestType booltesttype,
 extern Selectivity nulltestsel(PlannerInfo *root, NullTestType nulltesttype,
            Node *arg, int varRelid);
 extern Selectivity scalararraysel(PlannerInfo *root,
-                                 ScalarArrayOpExpr *clause,
-                                 bool is_join_clause,
-                                 int varRelid, JoinType jointype);
+              ScalarArrayOpExpr *clause,
+              bool is_join_clause,
+              int varRelid, JoinType jointype);
 extern int estimate_array_length(Node *arrayexpr);
 extern Selectivity rowcomparesel(PlannerInfo *root,
-                                RowCompareExpr *clause,
-                                int varRelid, JoinType jointype);
+             RowCompareExpr *clause,
+             int varRelid, JoinType jointype);
 
 extern void mergejoinscansel(PlannerInfo *root, Node *clause,
                 Selectivity *leftscan,
index 45a742075146d3f098ddde2f521b38dd1eacf30d..0c6e59cc92fa5062193e758476409a6412f1bc0a 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.63 2006/09/05 01:13:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.64 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -160,7 +160,6 @@ typedef int32 fsec_t;
 #else
 
 typedef double fsec_t;
-
 #endif
 
 /*
@@ -305,7 +304,7 @@ extern Datum pgsql_postmaster_start_time(PG_FUNCTION_ARGS);
 extern TimestampTz GetCurrentTimestamp(void);
 
 extern void TimestampDifference(TimestampTz start_time, TimestampTz stop_time,
-                               long *secs, int *microsecs);
+                   long *secs, int *microsecs);
 
 extern TimestampTz time_t_to_timestamptz(time_t tm);
 extern time_t timestamptz_to_time_t(TimestampTz t);
index 394895d6011fd38db84cc25d8380e4b7b8b6f826..5f1fbc925cdc587d8e11d46d02b5724ce86997e3 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.63 2006/09/03 15:59:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.64 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,6 +42,7 @@ typedef struct SnapshotData
    /* note: all ids in xip[] satisfy xmin <= xip[i] < xmax */
    int32       subxcnt;        /* # of xact ids in subxip[], -1 if overflow */
    TransactionId *subxip;      /* array of subxact IDs in progress */
+
    /*
     * note: all ids in subxip[] are >= xmin, but we don't bother filtering
     * out any that are >= xmax
index ef33237318ee75492336cb3462943f7770c12abf..de70401d989c88c06341f7d04cd48e63141b3119 100644 (file)
@@ -13,7 +13,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/tuplesort.h,v 1.22 2006/07/13 16:49:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/tuplesort.h,v 1.23 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -56,7 +56,7 @@ extern Tuplesortstate *tuplesort_begin_datum(Oid datumType,
                      int workMem, bool randomAccess);
 
 extern void tuplesort_puttupleslot(Tuplesortstate *state,
-                                  TupleTableSlot *slot);
+                      TupleTableSlot *slot);
 extern void tuplesort_putindextuple(Tuplesortstate *state, IndexTuple tuple);
 extern void tuplesort_putdatum(Tuplesortstate *state, Datum val,
                   bool isNull);
@@ -64,9 +64,9 @@ extern void tuplesort_putdatum(Tuplesortstate *state, Datum val,
 extern void tuplesort_performsort(Tuplesortstate *state);
 
 extern bool tuplesort_gettupleslot(Tuplesortstate *state, bool forward,
-                                  TupleTableSlot *slot);
+                      TupleTableSlot *slot);
 extern IndexTuple tuplesort_getindextuple(Tuplesortstate *state, bool forward,
-                                         bool *should_free);
+                       bool *should_free);
 extern bool tuplesort_getdatum(Tuplesortstate *state, bool forward,
                   Datum *val, bool *isNull);
 
index 62279344144aaa6799f85e6ac35ed7d86fc08ff9..5aeaa4d11e49177c00df30272515de5b81b860e7 100644 (file)
@@ -22,7 +22,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/tuplestore.h,v 1.18 2006/06/27 02:51:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/tuplestore.h,v 1.19 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,7 +47,7 @@ extern Tuplestorestate *tuplestore_begin_heap(bool randomAccess,
                      int maxKBytes);
 
 extern void tuplestore_puttupleslot(Tuplestorestate *state,
-                                   TupleTableSlot *slot);
+                       TupleTableSlot *slot);
 extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
 
 /* tuplestore_donestoring() used to be required, but is no longer used */
@@ -55,7 +55,7 @@ extern void tuplestore_puttuple(Tuplestorestate *state, HeapTuple tuple);
 
 /* backwards scan is only allowed if randomAccess was specified 'true' */
 extern bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward,
-                                   TupleTableSlot *slot);
+                       TupleTableSlot *slot);
 extern bool tuplestore_advance(Tuplestorestate *state, bool forward);
 
 extern void tuplestore_end(Tuplestorestate *state);
index 7d3e284871c7e837fd6cc5b8aaa1a3c038e976c7..673bf176adee91fc5272dcfb9fd648f97c8c51f3 100644 (file)
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/typcache.h,v 1.11 2006/06/16 18:42:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/typcache.h,v 1.12 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -57,8 +57,8 @@ typedef struct TypeCacheEntry
 
    /*
     * Tuple descriptor if it's a composite type (row type).  NULL if not
-    * composite or information hasn't yet been requested.  (NOTE: this is
-    * reference-counted tupledesc.)
+    * composite or information hasn't yet been requested.  (NOTE: this is a
+    * reference-counted tupledesc.)
     */
    TupleDesc   tupDesc;
 } TypeCacheEntry;
index 4b7226eb4449700afeff019ed4e8c30a34b32317..2aef189bee8cbd5d961c735b6367404d9f1e1938 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/tzparser.h,v 1.1 2006/07/25 03:51:22 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/tzparser.h,v 1.2 2006/10/04 00:30:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 typedef struct tzEntry
 {
    /* the actual data: TZ abbrev (downcased), offset, DST flag */
-   char *abbrev;
-   int offset;                 /* in seconds from UTC */
-   bool is_dst;
+   char       *abbrev;
+   int         offset;         /* in seconds from UTC */
+   bool        is_dst;
    /* source information (for error messages) */
-   int lineno;
+   int         lineno;
    const char *filename;
 } tzEntry;
 
 
 extern bool load_tzoffsets(const char *filename, bool doit, int elevel);
 
-#endif /* TZPARSER_H */
+#endif   /* TZPARSER_H */
index a8a95f4e437f33507091e57dc515a28c30b649f4..cfde8be5aa139ac6eadec3c5b11e113ae4e65ee8 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.47 2006/08/15 06:40:19 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.48 2006/10/04 00:30:11 momjian Exp $ */
 
 #include 
 #include 
@@ -169,15 +169,16 @@ ecpg_strndup(const char *str, size_t len)
 int
 deccvasc(char *cp, int len, decimal *np)
 {
-   char        *str;
-   int     ret = 0;
-   numeric     *result;
+   char       *str;
+   int         ret = 0;
+   numeric    *result;
 
    rsetnull(CDECIMALTYPE, (char *) np);
    if (risnull(CSTRINGTYPE, cp))
        return 0;
 
-   str = ecpg_strndup(cp, len);    /* decimal_in always converts the complete string */
+   str = ecpg_strndup(cp, len);/* decimal_in always converts the complete
+                                * string */
    if (!str)
        ret = ECPG_INFORMIX_NUM_UNDERFLOW;
    else
@@ -378,8 +379,8 @@ dectoasc(decimal *np, char *cp, int len, int right)
        return -1;
 
    /*
-    * TODO: have to take care of len here and create exponential notation
-    * if necessary
+    * TODO: have to take care of len here and create exponential notation if
+    * necessary
     */
    if ((int) (strlen(str) + 1) > len)
    {
@@ -647,7 +648,7 @@ intoasc(interval * i, char *str)
 }
 
 /*
- * rfmt.c  -  description
+ * rfmt.c  -  description
  * by Carsten Wolff , Wed Apr 2 2003
  */
 
@@ -936,7 +937,8 @@ byleng(char *str, int len)
 void
 ldchar(char *src, int len, char *dest)
 {
-   int dlen = byleng(src, len);
+   int         dlen = byleng(src, len);
+
    memmove(dest, src, dlen);
    dest[dlen] = '\0';
 }
index b07a8bbeb659c3a14fbf73825c5876499ce9de3e..9636c91a363bb380f0045ccabaea0e8c47cc11ff 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.35 2006/08/29 12:24:51 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.36 2006/10/04 00:30:11 momjian Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -27,7 +27,8 @@ ecpg_actual_connection_init(void)
    pthread_key_create(&actual_connection_key, NULL);
 }
 
-void ecpg_pthreads_init(void)
+void
+ecpg_pthreads_init(void)
 {
    pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
 }
@@ -226,7 +227,7 @@ ECPGnoticeReceiver(void *arg, const PGresult *result)
    if (sqlstate == NULL)
        sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR;
 
-   if (message == NULL)  /* Shouldn't happen, but need to be sure */
+   if (message == NULL)        /* Shouldn't happen, but need to be sure */
        message = "No message received";
 
    /* these are not warnings */
@@ -369,9 +370,10 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
                            ECPGraise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, realname ? realname : "");
                            if (host)
                                ECPGfree(host);
-                           /* port not set yet
-                            * if (port)
-                            *  ECPGfree(port); */
+
+                           /*
+                            * port not set yet if (port) ECPGfree(port);
+                            */
                            if (options)
                                ECPGfree(options);
                            if (realname)
index 4f474d3bcf12b73a2f24238a93cecb2979087108..ab1f2554ce512bcb3bef73aa3e5a5f119cd94ceb 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.34 2006/08/24 10:35:58 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.35 2006/10/04 00:30:11 momjian Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
 #include "pgtypes_timestamp.h"
 #include "pgtypes_interval.h"
 
-static enum { NOT_CHECKED, REGRESS, NORMAL } ECPG_regression_mode = NOT_CHECKED;
+static enum
+{
+   NOT_CHECKED, REGRESS, NORMAL
+}  ECPG_regression_mode = NOT_CHECKED;
 
 static bool
 garbage_left(enum ARRAY_TYPE isarray, char *scan_length, enum COMPAT_MODE compat)
@@ -47,11 +50,11 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
             long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator)
 {
    struct sqlca_t *sqlca = ECPGget_sqlca();
-   char    *pval = (char *) PQgetvalue(results, act_tuple, act_field);
-   int binary = PQfformat(results, act_field);
-   int     size = PQgetlength(results, act_tuple, act_field);
-   int value_for_indicator = 0;
-   long    log_offset;
+   char       *pval = (char *) PQgetvalue(results, act_tuple, act_field);
+   int         binary = PQfformat(results, act_field);
+   int         size = PQgetlength(results, act_tuple, act_field);
+   int         value_for_indicator = 0;
+   long        log_offset;
 
    /*
     * use a global variable to see if the environment variable
@@ -62,13 +65,13 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
    {
        if (getenv("ECPG_REGRESSION"))
            ECPG_regression_mode = REGRESS;
-       else 
+       else
            ECPG_regression_mode = NORMAL;
    }
 
    /*
-    * If we are running in a regression test, do not log the offset
-    * variable, it depends on the machine's alignment.
+    * If we are running in a regression test, do not log the offset variable,
+    * it depends on the machine's alignment.
     */
    if (ECPG_regression_mode == REGRESS)
        log_offset = -1;
@@ -167,15 +170,15 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
        {
            if (pval)
            {
-               if (varcharsize == 0 || varcharsize*offset >= size)
+               if (varcharsize == 0 || varcharsize * offset >= size)
                    memcpy((char *) ((long) var + offset * act_tuple),
                           pval, size);
                else
                {
                    memcpy((char *) ((long) var + offset * act_tuple),
-                          pval, varcharsize*offset);
+                          pval, varcharsize * offset);
 
-                   if (varcharsize*offset < size)
+                   if (varcharsize * offset < size)
                    {
                        /* truncation */
                        switch (ind_type)
@@ -206,533 +209,533 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
                }
                pval += size;
            }
-       }   
+       }
        else
        {
-       switch (type)
-       {
-               long        res;
-               unsigned long ures;
-               double      dres;
-               char       *scan_length;
-               numeric    *nres;
-               date        ddres;
-               timestamp   tres;
-               interval   *ires;
-
-           case ECPGt_short:
-           case ECPGt_int:
-           case ECPGt_long:
-               if (pval)
-               {
-                   res = strtol(pval, &scan_length, 10);
-                   if (garbage_left(isarray, scan_length, compat))
+           switch (type)
+           {
+                   long        res;
+                   unsigned long ures;
+                   double      dres;
+                   char       *scan_length;
+                   numeric    *nres;
+                   date        ddres;
+                   timestamp   tres;
+                   interval   *ires;
+
+               case ECPGt_short:
+               case ECPGt_int:
+               case ECPGt_long:
+                   if (pval)
                    {
-                       ECPGraise(lineno, ECPG_INT_FORMAT,
-                                 ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                       return (false);
+                       res = strtol(pval, &scan_length, 10);
+                       if (garbage_left(isarray, scan_length, compat))
+                       {
+                           ECPGraise(lineno, ECPG_INT_FORMAT,
+                                     ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
+                           return (false);
+                       }
+                       pval = scan_length;
                    }
-                   pval = scan_length;
-               }
-               else
-                   res = 0L;
+                   else
+                       res = 0L;
 
-               switch (type)
-               {
-                   case ECPGt_short:
-                       *((short *) (var + offset * act_tuple)) = (short) res;
-                       break;
-                   case ECPGt_int:
-                       *((int *) (var + offset * act_tuple)) = (int) res;
-                       break;
-                   case ECPGt_long:
-                       *((long *) (var + offset * act_tuple)) = (long) res;
-                       break;
-                   default:
-                       /* Cannot happen */
-                       break;
-               }
-               break;
+                   switch (type)
+                   {
+                       case ECPGt_short:
+                           *((short *) (var + offset * act_tuple)) = (short) res;
+                           break;
+                       case ECPGt_int:
+                           *((int *) (var + offset * act_tuple)) = (int) res;
+                           break;
+                       case ECPGt_long:
+                           *((long *) (var + offset * act_tuple)) = (long) res;
+                           break;
+                       default:
+                           /* Cannot happen */
+                           break;
+                   }
+                   break;
 
-           case ECPGt_unsigned_short:
-           case ECPGt_unsigned_int:
-           case ECPGt_unsigned_long:
-               if (pval)
-               {
-                   ures = strtoul(pval, &scan_length, 10);
-                   if (garbage_left(isarray, scan_length, compat))
+               case ECPGt_unsigned_short:
+               case ECPGt_unsigned_int:
+               case ECPGt_unsigned_long:
+                   if (pval)
                    {
-                       ECPGraise(lineno, ECPG_UINT_FORMAT,
-                                 ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                       return (false);
+                       ures = strtoul(pval, &scan_length, 10);
+                       if (garbage_left(isarray, scan_length, compat))
+                       {
+                           ECPGraise(lineno, ECPG_UINT_FORMAT,
+                                     ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
+                           return (false);
+                       }
+                       pval = scan_length;
                    }
-                   pval = scan_length;
-               }
-               else
-                   ures = 0L;
+                   else
+                       ures = 0L;
 
-               switch (type)
-               {
-                   case ECPGt_unsigned_short:
-                       *((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures;
-                       break;
-                   case ECPGt_unsigned_int:
-                       *((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures;
-                       break;
-                   case ECPGt_unsigned_long:
-                       *((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures;
-                       break;
-                   default:
-                       /* Cannot happen */
-                       break;
-               }
-               break;
+                   switch (type)
+                   {
+                       case ECPGt_unsigned_short:
+                           *((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures;
+                           break;
+                       case ECPGt_unsigned_int:
+                           *((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures;
+                           break;
+                       case ECPGt_unsigned_long:
+                           *((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures;
+                           break;
+                       default:
+                           /* Cannot happen */
+                           break;
+                   }
+                   break;
 
 #ifdef HAVE_LONG_LONG_INT_64
 #ifdef HAVE_STRTOLL
-           case ECPGt_long_long:
-               if (pval)
-               {
-                   *((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
-                   if (garbage_left(isarray, scan_length, compat))
+               case ECPGt_long_long:
+                   if (pval)
                    {
-                       ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                       return (false);
+                       *((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
+                       if (garbage_left(isarray, scan_length, compat))
+                       {
+                           ECPGraise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
+                           return (false);
+                       }
+                       pval = scan_length;
                    }
-                   pval = scan_length;
-               }
-               else
-                   *((long long int *) (var + offset * act_tuple)) = (long long) 0;
+                   else
+                       *((long long int *) (var + offset * act_tuple)) = (long long) 0;
 
-               break;
+                   break;
 #endif   /* HAVE_STRTOLL */
 #ifdef HAVE_STRTOULL
-           case ECPGt_unsigned_long_long:
-               if (pval)
-               {
-                   *((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
-                   if ((isarray && *scan_length != ',' && *scan_length != '}')
-                       || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' '))        /* Garbage left */
+               case ECPGt_unsigned_long_long:
+                   if (pval)
                    {
-                       ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                       return (false);
+                       *((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
+                       if ((isarray && *scan_length != ',' && *scan_length != '}')
+                           || (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' '))    /* Garbage left */
+                       {
+                           ECPGraise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
+                           return (false);
+                       }
+                       pval = scan_length;
                    }
-                   pval = scan_length;
-               }
-               else
-                   *((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0;
+                   else
+                       *((unsigned long long int *) (var + offset * act_tuple)) = (long long) 0;
 
-               break;
+                   break;
 #endif   /* HAVE_STRTOULL */
 #endif   /* HAVE_LONG_LONG_INT_64 */
 
-           case ECPGt_float:
-           case ECPGt_double:
-               if (pval)
-               {
-                   if (isarray && *pval == '"')
-                       dres = strtod(pval + 1, &scan_length);
-                   else
-                       dres = strtod(pval, &scan_length);
-
-                   if (isarray && *scan_length == '"')
-                       scan_length++;
-
-                   if (garbage_left(isarray, scan_length, compat))
+               case ECPGt_float:
+               case ECPGt_double:
+                   if (pval)
                    {
-                       ECPGraise(lineno, ECPG_FLOAT_FORMAT,
-                                 ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                       return (false);
-                   }
-                   pval = scan_length;
-               }
-               else
-                   dres = 0.0;
+                       if (isarray && *pval == '"')
+                           dres = strtod(pval + 1, &scan_length);
+                       else
+                           dres = strtod(pval, &scan_length);
 
-               switch (type)
-               {
-                   case ECPGt_float:
-                       *((float *) (var + offset * act_tuple)) = dres;
-                       break;
-                   case ECPGt_double:
-                       *((double *) (var + offset * act_tuple)) = dres;
-                       break;
-                   default:
-                       /* Cannot happen */
-                       break;
-               }
-               break;
+                       if (isarray && *scan_length == '"')
+                           scan_length++;
 
-           case ECPGt_bool:
-               if (pval)
-               {
-                   if (pval[0] == 'f' && pval[1] == '\0')
-                   {
-                       if (offset == sizeof(char))
-                           *((char *) (var + offset * act_tuple)) = false;
-                       else if (offset == sizeof(int))
-                           *((int *) (var + offset * act_tuple)) = false;
-                       else
-                           ECPGraise(lineno, ECPG_CONVERT_BOOL,
-                                     ECPG_SQLSTATE_DATATYPE_MISMATCH,
-                                     "different size");
-                       break;
+                       if (garbage_left(isarray, scan_length, compat))
+                       {
+                           ECPGraise(lineno, ECPG_FLOAT_FORMAT,
+                                     ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
+                           return (false);
+                       }
+                       pval = scan_length;
                    }
-                   else if (pval[0] == 't' && pval[1] == '\0')
+                   else
+                       dres = 0.0;
+
+                   switch (type)
                    {
-                       if (offset == sizeof(char))
-                           *((char *) (var + offset * act_tuple)) = true;
-                       else if (offset == sizeof(int))
-                           *((int *) (var + offset * act_tuple)) = true;
-                       else
-                           ECPGraise(lineno, ECPG_CONVERT_BOOL,
-                                     ECPG_SQLSTATE_DATATYPE_MISMATCH,
-                                     "different size");
-                       break;
+                       case ECPGt_float:
+                           *((float *) (var + offset * act_tuple)) = dres;
+                           break;
+                       case ECPGt_double:
+                           *((double *) (var + offset * act_tuple)) = dres;
+                           break;
+                       default:
+                           /* Cannot happen */
+                           break;
                    }
-                   else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
+                   break;
+
+               case ECPGt_bool:
+                   if (pval)
                    {
-                       /* NULL is valid */
-                       break;
+                       if (pval[0] == 'f' && pval[1] == '\0')
+                       {
+                           if (offset == sizeof(char))
+                               *((char *) (var + offset * act_tuple)) = false;
+                           else if (offset == sizeof(int))
+                               *((int *) (var + offset * act_tuple)) = false;
+                           else
+                               ECPGraise(lineno, ECPG_CONVERT_BOOL,
+                                         ECPG_SQLSTATE_DATATYPE_MISMATCH,
+                                         "different size");
+                           break;
+                       }
+                       else if (pval[0] == 't' && pval[1] == '\0')
+                       {
+                           if (offset == sizeof(char))
+                               *((char *) (var + offset * act_tuple)) = true;
+                           else if (offset == sizeof(int))
+                               *((int *) (var + offset * act_tuple)) = true;
+                           else
+                               ECPGraise(lineno, ECPG_CONVERT_BOOL,
+                                         ECPG_SQLSTATE_DATATYPE_MISMATCH,
+                                         "different size");
+                           break;
+                       }
+                       else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
+                       {
+                           /* NULL is valid */
+                           break;
+                       }
                    }
-               }
 
-               ECPGraise(lineno, ECPG_CONVERT_BOOL,
-                         ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-               return (false);
-               break;
+                   ECPGraise(lineno, ECPG_CONVERT_BOOL,
+                             ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
+                   return (false);
+                   break;
 
-           case ECPGt_char:
-           case ECPGt_unsigned_char:
-               if (pval)
-               {
-                   if (varcharsize == 0 || varcharsize > size)
-                       strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1);
-                   else
+               case ECPGt_char:
+               case ECPGt_unsigned_char:
+                   if (pval)
                    {
-                       strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
-
-                       if (varcharsize < size)
+                       if (varcharsize == 0 || varcharsize > size)
+                           strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1);
+                       else
                        {
-                           /* truncation */
-                           switch (ind_type)
+                           strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
+
+                           if (varcharsize < size)
                            {
-                               case ECPGt_short:
-                               case ECPGt_unsigned_short:
-                                   *((short *) (ind + ind_offset * act_tuple)) = size;
-                                   break;
-                               case ECPGt_int:
-                               case ECPGt_unsigned_int:
-                                   *((int *) (ind + ind_offset * act_tuple)) = size;
-                                   break;
-                               case ECPGt_long:
-                               case ECPGt_unsigned_long:
-                                   *((long *) (ind + ind_offset * act_tuple)) = size;
-                                   break;
+                               /* truncation */
+                               switch (ind_type)
+                               {
+                                   case ECPGt_short:
+                                   case ECPGt_unsigned_short:
+                                       *((short *) (ind + ind_offset * act_tuple)) = size;
+                                       break;
+                                   case ECPGt_int:
+                                   case ECPGt_unsigned_int:
+                                       *((int *) (ind + ind_offset * act_tuple)) = size;
+                                       break;
+                                   case ECPGt_long:
+                                   case ECPGt_unsigned_long:
+                                       *((long *) (ind + ind_offset * act_tuple)) = size;
+                                       break;
 #ifdef HAVE_LONG_LONG_INT_64
-                               case ECPGt_long_long:
-                               case ECPGt_unsigned_long_long:
-                                   *((long long int *) (ind + ind_offset * act_tuple)) = size;
-                                   break;
+                                   case ECPGt_long_long:
+                                   case ECPGt_unsigned_long_long:
+                                       *((long long int *) (ind + ind_offset * act_tuple)) = size;
+                                       break;
 #endif   /* HAVE_LONG_LONG_INT_64 */
-                               default:
-                                   break;
+                                   default:
+                                       break;
+                               }
+                               sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
                            }
-                           sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
                        }
+                       pval += size;
                    }
-                   pval += size;
-               }
-               break;
+                   break;
 
-           case ECPGt_varchar:
-               if (pval)
-               {
-                   struct ECPGgeneric_varchar *variable =
-                   (struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
-
-                   variable->len = size;
-                   if (varcharsize == 0)
-                       strncpy(variable->arr, pval, variable->len);
-                   else
+               case ECPGt_varchar:
+                   if (pval)
                    {
-                       strncpy(variable->arr, pval, varcharsize);
+                       struct ECPGgeneric_varchar *variable =
+                       (struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
 
-                       if (variable->len > varcharsize)
+                       variable->len = size;
+                       if (varcharsize == 0)
+                           strncpy(variable->arr, pval, variable->len);
+                       else
                        {
-                           /* truncation */
-                           switch (ind_type)
+                           strncpy(variable->arr, pval, varcharsize);
+
+                           if (variable->len > varcharsize)
                            {
-                               case ECPGt_short:
-                               case ECPGt_unsigned_short:
-                                   *((short *) (ind + offset * act_tuple)) = variable->len;
-                                   break;
-                               case ECPGt_int:
-                               case ECPGt_unsigned_int:
-                                   *((int *) (ind + offset * act_tuple)) = variable->len;
-                                   break;
-                               case ECPGt_long:
-                               case ECPGt_unsigned_long:
-                                   *((long *) (ind + offset * act_tuple)) = variable->len;
-                                   break;
+                               /* truncation */
+                               switch (ind_type)
+                               {
+                                   case ECPGt_short:
+                                   case ECPGt_unsigned_short:
+                                       *((short *) (ind + offset * act_tuple)) = variable->len;
+                                       break;
+                                   case ECPGt_int:
+                                   case ECPGt_unsigned_int:
+                                       *((int *) (ind + offset * act_tuple)) = variable->len;
+                                       break;
+                                   case ECPGt_long:
+                                   case ECPGt_unsigned_long:
+                                       *((long *) (ind + offset * act_tuple)) = variable->len;
+                                       break;
 #ifdef HAVE_LONG_LONG_INT_64
-                               case ECPGt_long_long:
-                               case ECPGt_unsigned_long_long:
-                                   *((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
-                                   break;
+                                   case ECPGt_long_long:
+                                   case ECPGt_unsigned_long_long:
+                                       *((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
+                                       break;
 #endif   /* HAVE_LONG_LONG_INT_64 */
-                               default:
-                                   break;
-                           }
-                           sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
+                                   default:
+                                       break;
+                               }
+                               sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
 
-                           variable->len = varcharsize;
+                               variable->len = varcharsize;
+                           }
                        }
+                       pval += size;
                    }
-                   pval += size;
-               }
-               break;
+                   break;
 
-           case ECPGt_decimal:
-           case ECPGt_numeric:
-               if (pval)
-               {
-                   if (isarray && *pval == '"')
-                       nres = PGTYPESnumeric_from_asc(pval + 1, &scan_length);
-                   else
-                       nres = PGTYPESnumeric_from_asc(pval, &scan_length);
-
-                   /* did we get an error? */
-                   if (nres == NULL)
+               case ECPGt_decimal:
+               case ECPGt_numeric:
+                   if (pval)
                    {
-                       ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n",
-                               lineno, pval ? pval : "", errno);
+                       if (isarray && *pval == '"')
+                           nres = PGTYPESnumeric_from_asc(pval + 1, &scan_length);
+                       else
+                           nres = PGTYPESnumeric_from_asc(pval, &scan_length);
 
-                       if (INFORMIX_MODE(compat))
+                       /* did we get an error? */
+                       if (nres == NULL)
                        {
-                           /*
-                            * Informix wants its own NULL value here instead
-                            * of an error
-                            */
-                           nres = PGTYPESnumeric_new();
-                           if (nres)
-                               ECPGset_noind_null(ECPGt_numeric, nres);
+                           ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n",
+                                   lineno, pval ? pval : "", errno);
+
+                           if (INFORMIX_MODE(compat))
+                           {
+                               /*
+                                * Informix wants its own NULL value here
+                                * instead of an error
+                                */
+                               nres = PGTYPESnumeric_new();
+                               if (nres)
+                                   ECPGset_noind_null(ECPGt_numeric, nres);
+                               else
+                               {
+                                   ECPGraise(lineno, ECPG_OUT_OF_MEMORY,
+                                    ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
+                                   return (false);
+                               }
+                           }
                            else
                            {
-                               ECPGraise(lineno, ECPG_OUT_OF_MEMORY,
-                                   ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
+                               ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
+                                     ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
                                return (false);
                            }
                        }
                        else
                        {
-                           ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
-                                     ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
-                       }
-                   }
-                   else
-                   {
-                       if (isarray && *scan_length == '"')
-                           scan_length++;
+                           if (isarray && *scan_length == '"')
+                               scan_length++;
 
-                       if (garbage_left(isarray, scan_length, compat))
-                       {
-                           free(nres);
-                           ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
+                           if (garbage_left(isarray, scan_length, compat))
+                           {
+                               free(nres);
+                               ECPGraise(lineno, ECPG_NUMERIC_FORMAT,
                                      ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
+                               return (false);
+                           }
                        }
+                       pval = scan_length;
                    }
-                   pval = scan_length;
-               }
-               else
-                   nres = PGTYPESnumeric_from_asc("0.0", &scan_length);
-
-               if (type == ECPGt_numeric)
-                   PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
-               else
-                   PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
-
-               free(nres);
-               break;
+                   else
+                       nres = PGTYPESnumeric_from_asc("0.0", &scan_length);
 
-           case ECPGt_interval:
-               if (pval)
-               {
-                   if (isarray && *pval == '"')
-                       ires = PGTYPESinterval_from_asc(pval + 1, &scan_length);
+                   if (type == ECPGt_numeric)
+                       PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
                    else
-                       ires = PGTYPESinterval_from_asc(pval, &scan_length);
+                       PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
+
+                   free(nres);
+                   break;
 
-                   /* did we get an error? */
-                   if (ires == NULL)
+               case ECPGt_interval:
+                   if (pval)
                    {
-                       if (INFORMIX_MODE(compat))
+                       if (isarray && *pval == '"')
+                           ires = PGTYPESinterval_from_asc(pval + 1, &scan_length);
+                       else
+                           ires = PGTYPESinterval_from_asc(pval, &scan_length);
+
+                       /* did we get an error? */
+                       if (ires == NULL)
                        {
-                           /*
-                            * Informix wants its own NULL value here instead
-                            * of an error
-                            */
-                           ires = (interval *) ECPGalloc(sizeof(interval), lineno);
-                           if (!ires)
+                           if (INFORMIX_MODE(compat))
+                           {
+                               /*
+                                * Informix wants its own NULL value here
+                                * instead of an error
+                                */
+                               ires = (interval *) ECPGalloc(sizeof(interval), lineno);
+                               if (!ires)
+                                   return (false);
+
+                               ECPGset_noind_null(ECPGt_interval, ires);
+                           }
+                           else
+                           {
+                               ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
+                                     ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
                                return (false);
-
-                           ECPGset_noind_null(ECPGt_interval, ires);
+                           }
                        }
                        else
                        {
-                           ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
-                                     ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
-                       }
-                   }
-                   else
-                   {
-                       if (isarray && *scan_length == '"')
-                           scan_length++;
+                           if (isarray && *scan_length == '"')
+                               scan_length++;
 
-                       if (garbage_left(isarray, scan_length, compat))
-                       {
-                           free(ires);
-                           ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
+                           if (garbage_left(isarray, scan_length, compat))
+                           {
+                               free(ires);
+                               ECPGraise(lineno, ECPG_INTERVAL_FORMAT,
                                      ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
+                               return (false);
+                           }
                        }
+                       pval = scan_length;
                    }
-                   pval = scan_length;
-               }
-               else
-                   ires = PGTYPESinterval_from_asc("0 seconds", NULL);
-
-               PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
-               free(ires);
-               break;
-           case ECPGt_date:
-               if (pval)
-               {
-                   if (isarray && *pval == '"')
-                       ddres = PGTYPESdate_from_asc(pval + 1, &scan_length);
                    else
-                       ddres = PGTYPESdate_from_asc(pval, &scan_length);
+                       ires = PGTYPESinterval_from_asc("0 seconds", NULL);
 
-                   /* did we get an error? */
-                   if (errno != 0)
+                   PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
+                   free(ires);
+                   break;
+               case ECPGt_date:
+                   if (pval)
                    {
-                       if (INFORMIX_MODE(compat))
-                       {
-                           /*
-                            * Informix wants its own NULL value here instead
-                            * of an error
-                            */
-                           ECPGset_noind_null(ECPGt_date, &ddres);
-                       }
+                       if (isarray && *pval == '"')
+                           ddres = PGTYPESdate_from_asc(pval + 1, &scan_length);
                        else
+                           ddres = PGTYPESdate_from_asc(pval, &scan_length);
+
+                       /* did we get an error? */
+                       if (errno != 0)
                        {
-                           ECPGraise(lineno, ECPG_DATE_FORMAT,
+                           if (INFORMIX_MODE(compat))
+                           {
+                               /*
+                                * Informix wants its own NULL value here
+                                * instead of an error
+                                */
+                               ECPGset_noind_null(ECPGt_date, &ddres);
+                           }
+                           else
+                           {
+                               ECPGraise(lineno, ECPG_DATE_FORMAT,
                                      ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
+                               return (false);
+                           }
                        }
-                   }
-                   else
-                   {
-                       if (isarray && *scan_length == '"')
-                           scan_length++;
-
-                       if (garbage_left(isarray, scan_length, compat))
+                       else
                        {
-                           ECPGraise(lineno, ECPG_DATE_FORMAT,
+                           if (isarray && *scan_length == '"')
+                               scan_length++;
+
+                           if (garbage_left(isarray, scan_length, compat))
+                           {
+                               ECPGraise(lineno, ECPG_DATE_FORMAT,
                                      ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
+                               return (false);
+                           }
                        }
-                   }
-
-                   *((date *) (var + offset * act_tuple)) = ddres;
-                   pval = scan_length;
-               }
-               break;
 
-           case ECPGt_timestamp:
-               if (pval)
-               {
-                   if (isarray && *pval == '"')
-                       tres = PGTYPEStimestamp_from_asc(pval + 1, &scan_length);
-                   else
-                       tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
+                       *((date *) (var + offset * act_tuple)) = ddres;
+                       pval = scan_length;
+                   }
+                   break;
 
-                   /* did we get an error? */
-                   if (errno != 0)
+               case ECPGt_timestamp:
+                   if (pval)
                    {
-                       if (INFORMIX_MODE(compat))
-                       {
-                           /*
-                            * Informix wants its own NULL value here instead
-                            * of an error
-                            */
-                           ECPGset_noind_null(ECPGt_timestamp, &tres);
-                       }
+                       if (isarray && *pval == '"')
+                           tres = PGTYPEStimestamp_from_asc(pval + 1, &scan_length);
                        else
+                           tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
+
+                       /* did we get an error? */
+                       if (errno != 0)
                        {
-                           ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
+                           if (INFORMIX_MODE(compat))
+                           {
+                               /*
+                                * Informix wants its own NULL value here
+                                * instead of an error
+                                */
+                               ECPGset_noind_null(ECPGt_timestamp, &tres);
+                           }
+                           else
+                           {
+                               ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
                                      ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
+                               return (false);
+                           }
                        }
-                   }
-                   else
-                   {
-                       if (isarray && *scan_length == '"')
-                           scan_length++;
-
-                       if (garbage_left(isarray, scan_length, compat))
+                       else
                        {
-                           ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
+                           if (isarray && *scan_length == '"')
+                               scan_length++;
+
+                           if (garbage_left(isarray, scan_length, compat))
+                           {
+                               ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT,
                                      ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
-                           return (false);
+                               return (false);
+                           }
                        }
-                   }
 
-                   *((timestamp *) (var + offset * act_tuple)) = tres;
-                   pval = scan_length;
-               }
-               break;
+                       *((timestamp *) (var + offset * act_tuple)) = tres;
+                       pval = scan_length;
+                   }
+                   break;
 
-           default:
-               ECPGraise(lineno, ECPG_UNSUPPORTED,
-                         ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
-                         ECPGtype_name(type));
-               return (false);
-               break;
-       }
-       if (isarray == ECPG_ARRAY_ARRAY)
-       {
-           bool        string = false;
+               default:
+                   ECPGraise(lineno, ECPG_UNSUPPORTED,
+                             ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
+                             ECPGtype_name(type));
+                   return (false);
+                   break;
+           }
+           if (isarray == ECPG_ARRAY_ARRAY)
+           {
+               bool        string = false;
 
-           /* set array to next entry */
-           ++act_tuple;
+               /* set array to next entry */
+               ++act_tuple;
 
-           /* set pval to the next entry */
-           for (; string || (*pval != ',' && *pval != '}' && *pval != '\0'); ++pval)
-               if (*pval == '"')
-                   string = string ? false : true;
+               /* set pval to the next entry */
+               for (; string || (*pval != ',' && *pval != '}' && *pval != '\0'); ++pval)
+                   if (*pval == '"')
+                       string = string ? false : true;
 
-           if (*pval == ',')
-               ++pval;
-       }
-       else if (isarray == ECPG_ARRAY_VECTOR)
-       {
-           bool        string = false;
+               if (*pval == ',')
+                   ++pval;
+           }
+           else if (isarray == ECPG_ARRAY_VECTOR)
+           {
+               bool        string = false;
 
-           /* set array to next entry */
-           ++act_tuple;
+               /* set array to next entry */
+               ++act_tuple;
 
-           /* set pval to the next entry */
-           for (; string || (*pval != ' ' && *pval != '\0'); ++pval)
-               if (*pval == '"')
-                   string = string ? false : true;
+               /* set pval to the next entry */
+               for (; string || (*pval != ' ' && *pval != '\0'); ++pval)
+                   if (*pval == '"')
+                       string = string ? false : true;
 
-           if (*pval == ' ')
-               ++pval;
-       }
+               if (*pval == ' ')
+                   ++pval;
+           }
        }
    } while (*pval != '\0' && ((isarray == ECPG_ARRAY_ARRAY && *pval != '}') || isarray == ECPG_ARRAY_VECTOR));
 
index 58d7b5bf6f1d21aabc4f47a45af10bdd6ac462bd..d73b7d6e80ebe7b777130a1d14b5a9976b918165 100644 (file)
@@ -1,6 +1,6 @@
 /* dynamic SQL support routines
  *
- * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.19 2006/08/23 13:57:27 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.20 2006/10/04 00:30:11 momjian Exp $
  */
 
 #define POSTGRES_ECPG_INTERNAL
@@ -351,7 +351,8 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
                /* allocate storage if needed */
                if (arrsize == 0 && *(void **) var == NULL)
                {
-                   void *mem = (void *) ECPGalloc(offset * ntuples, lineno);
+                   void       *mem = (void *) ECPGalloc(offset * ntuples, lineno);
+
                    if (!mem)
                        return false;
                    *(void **) var = mem;
@@ -398,7 +399,12 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
        ECPGfree(oldlocale);
    }
    else if (data_var.ind_type != ECPGt_NO_INDICATOR && data_var.ind_pointer != NULL)
-   /* ind_type != NO_INDICATOR should always have ind_pointer != NULL but since this might be changed manually in the .c file let's play it safe */
+
+       /*
+        * ind_type != NO_INDICATOR should always have ind_pointer != NULL but
+        * since this might be changed manually in the .c file let's play it
+        * safe
+        */
    {
        /*
         * this is like ECPGstore_result but since we don't have a data
@@ -415,7 +421,8 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
        /* allocate storage if needed */
        if (data_var.ind_arrsize == 0 && data_var.ind_value == NULL)
        {
-           void *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
+           void       *mem = (void *) ECPGalloc(data_var.ind_offset * ntuples, lineno);
+
            if (!mem)
                return false;
            *(void **) data_var.ind_pointer = mem;
index 5e65c0df8d4cf2a7fd6ceaf17051728d9f42ee03..3f811377bdb99af98c08cced05012e7e83cc4d7a 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.14 2006/08/02 13:43:23 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.15 2006/10/04 00:30:11 momjian Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -190,7 +190,7 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat)
        sqlca->sqlcode = ECPG_PGSQL;
 
    ECPGlog("raising sqlstate %.*s (sqlcode: %d) in line %d, '%s'.\n",
-   sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, line, sqlca->sqlerrm.sqlerrmc);
+           sizeof(sqlca->sqlstate), sqlca->sqlstate, sqlca->sqlcode, line, sqlca->sqlerrm.sqlerrmc);
 
    /* free all memory we have allocated for the user */
    ECPGfree_auto_mem();
index 7cd23cfc15eb8701105d5044e8fde4527f09fe5b..15edddcea21ff830b5eb32ec24031dbe54778380 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.61 2006/08/23 12:01:52 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.62 2006/10/04 00:30:11 momjian Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
@@ -39,10 +39,13 @@ static char *
 quote_postgres(char *arg, bool quote, int lineno)
 {
    char       *res;
-   int         i, ri = 0;
+   int         i,
+               ri = 0;
 
-   /* if quote is false we just need to store things in a descriptor 
-    * they will be quoted once they are inserted in a statement */
+   /*
+    * if quote is false we just need to store things in a descriptor they
+    * will be quoted once they are inserted in a statement
+    */
    if (!quote)
        return res = ECPGstrdup(arg, lineno);
    else
@@ -52,9 +55,9 @@ quote_postgres(char *arg, bool quote, int lineno)
            return (res);
 
        /*
-        *  We don't know if the target database is using
-        *  standard_conforming_strings, so we always use E'' strings.
-        */ 
+        * We don't know if the target database is using
+        * standard_conforming_strings, so we always use E'' strings.
+        */
        if (strchr(arg, '\\') != NULL)
            res[ri++] = ESCAPE_STRING_SYNTAX;
 
@@ -270,7 +273,7 @@ ECPGtypeinfocache_push(struct ECPGtype_information_cache ** cache, int oid, bool
    new_entry->isarray = isarray;
    new_entry->next = *cache;
    *cache = new_entry;
-   return(true);
+   return (true);
 }
 
 static enum ARRAY_TYPE
@@ -290,48 +293,90 @@ ECPGis_type_an_array(int type, const struct statement * stmt, const struct varia
 #define not_an_array_in_ecpg ECPG_ARRAY_NONE
 
        /* populate cache with well known types to speed things up */
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOOLOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BYTEAOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NAMEOID, not_an_array_in_ecpg, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT8OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2VECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT4OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), REGPROCOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TEXTOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), XIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDVECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POINTOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LSEGOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), PATHOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOXOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POLYGONOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LINEOID, ECPG_ARRAY_VECTOR, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT4OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT8OID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ABSTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), RELTIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TINTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), UNKNOWNOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BPCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARCHAROID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), DATEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMEOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPTZOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INTERVALOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMETZOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ZPBITOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARBITOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
-       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NUMERICOID, ECPG_ARRAY_NONE, stmt->lineno)) return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOOLOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BYTEAOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CHAROID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NAMEOID, not_an_array_in_ecpg, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT8OID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2OID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT2VECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INT4OID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), REGPROCOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TEXTOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIDOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), XIDOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), OIDVECTOROID, ECPG_ARRAY_VECTOR, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POINTOID, ECPG_ARRAY_VECTOR, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LSEGOID, ECPG_ARRAY_VECTOR, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), PATHOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BOXOID, ECPG_ARRAY_VECTOR, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), POLYGONOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), LINEOID, ECPG_ARRAY_VECTOR, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT4OID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), FLOAT8OID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ABSTIMEOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), RELTIMEOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TINTERVALOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), UNKNOWNOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIRCLEOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CASHOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INETOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), CIDROID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), BPCHAROID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARCHAROID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), DATEOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMEOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMESTAMPTZOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), INTERVALOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), TIMETZOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), ZPBITOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), VARBITOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
+       if (!ECPGtypeinfocache_push(&(stmt->connection->cache_head), NUMERICOID, ECPG_ARRAY_NONE, stmt->lineno))
+           return (ECPG_ARRAY_ERROR);
    }
 
    for (cache_entry = (stmt->connection->cache_head); cache_entry != NULL; cache_entry = cache_entry->next)
@@ -580,7 +625,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
    }
    if (**tobeinserted_p == '\0')
    {
-       int asize = var->arrsize? var->arrsize : 1;
+       int         asize = var->arrsize ? var->arrsize : 1;
 
        switch (var->type)
        {
@@ -882,7 +927,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
            case ECPGt_numeric:
                {
                    char       *str = NULL;
-                   int     slen;
+                   int         slen;
                    numeric    *nval;
 
                    if (var->arrsize > 1)
@@ -892,7 +937,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
                            nval = PGTYPESnumeric_new();
                            if (!nval)
                                return false;
-                               
+
                            if (var->type == ECPGt_numeric)
                                PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
                            else
@@ -1237,8 +1282,8 @@ ECPGexecute(struct statement * stmt)
             * the first %s
             */
            if (!(newcopy = (char *) ECPGalloc(strlen(copiedquery)
-                                            + strlen(tobeinserted)
-                                            + 1, stmt->lineno)))
+                                              + strlen(tobeinserted)
+                                              + 1, stmt->lineno)))
            {
                ECPGfree(copiedquery);
                return false;
@@ -1252,7 +1297,7 @@ ECPGexecute(struct statement * stmt)
                 * in the string
                 */
                ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS,
-                         ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS,
+                       ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS,
                          NULL);
                ECPGfree(copiedquery);
                ECPGfree(newcopy);
@@ -1422,11 +1467,12 @@ ECPGexecute(struct statement * stmt)
                break;
            case PGRES_COPY_OUT:
                {
-                   char *buffer;
-                   int res;
+                   char       *buffer;
+                   int         res;
+
                    ECPGlog("ECPGexecute line %d: Got PGRES_COPY_OUT\n", stmt->lineno);
                    while ((res = PQgetCopyData(stmt->connection->connection,
-                                        &buffer, 0)) > 0)
+                                               &buffer, 0)) > 0)
                    {
                        printf("%s", buffer);
                        PQfreemem(buffer);
index 62f8cf34da7245f48a95832561fd9e590509e826..8759fac4fdb5cc52185400909d0d968cb4ea60ff 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.19 2006/08/23 12:01:52 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.20 2006/10/04 00:30:11 momjian Exp $ */
 
 #ifndef _ECPG_LIB_EXTERN_H
 #define _ECPG_LIB_EXTERN_H
@@ -27,6 +27,7 @@ void      ECPGadd_mem(void *ptr, int lineno);
 bool ECPGget_data(const PGresult *, int, int, int, enum ECPGttype type,
             enum ECPGttype, char *, char *, long, long, long,
             enum ARRAY_TYPE, enum COMPAT_MODE, bool);
+
 #ifdef ENABLE_THREAD_SAFETY
 void       ecpg_pthreads_init(void);
 #endif
index 3c84cfd4f75ebcdf5f789381d0eb5eb4154e52ad..0bd850d36d912fd64f58bbdefd30c474110a54cd 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.31 2006/08/15 06:40:19 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.32 2006/10/04 00:30:11 momjian Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -247,8 +247,8 @@ ECPGlog(const char *format,...)
 
    if (simple_debug)
    {
-       int             bufsize = strlen(format) + 100;
-       char           *f = (char *) malloc(bufsize);
+       int         bufsize = strlen(format) + 100;
+       char       *f = (char *) malloc(bufsize);
 
        if (f == NULL)
        {
index 19b771afea20719be4133adef300eac28e941b32..f1a9db0729ff593ce2113e113ba4510918c71103 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.17 2006/09/05 10:00:52 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.18 2006/10/04 00:30:11 momjian Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -53,8 +53,9 @@ replace_variables(char *text)
                *ptr = '?';
                for (++ptr; *ptr && isvarchar(*ptr); ptr++)
                    *ptr = ' ';
-               if (*ptr == '\0') /* we reached the end */
-                   ptr--; /* since we will ptr++ in the top level for loop */
+               if (*ptr == '\0')       /* we reached the end */
+                   ptr--;      /* since we will ptr++ in the top level for
+                                * loop */
            }
        }
    }
@@ -103,7 +104,7 @@ ECPGprepare(int lineno, const char *name, const char *variable)
    this->name = ECPGstrdup(name, lineno);
    this->stmt = stmt;
    ECPGlog("ECPGprepare line %d: QUERY: %s\n", stmt->lineno, stmt->command);
-       
+
 
    if (prep_stmts == NULL)
        this->next = NULL;
index ced6da563d089fcfb81eefefdd74b26041757988..ab18b7e5f985be333ebfdc4df6eeb91e46a52cd7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * this is a small part of c.h since we don't want to leak all postgres
  * definitions into ecpg programs
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.69 2006/08/04 16:54:05 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.70 2006/10/04 00:30:11 momjian Exp $
  */
 
 #ifndef _ECPGLIB_H
@@ -38,7 +38,7 @@ extern        "C"
 {
 #endif
 
-void       ECPGinit_sqlca(struct sqlca_t *sqlca);
+void       ECPGinit_sqlca(struct sqlca_t * sqlca);
 void       ECPGdebug(int, FILE *);
 bool       ECPGstatus(int, const char *);
 bool       ECPGsetcommit(int, const char *, const char *);
index 2afc97198e24eb3003ff10fd920411b145caa412..9cc4233ee0f19a82d8fcac516e27e84662e27ff4 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_date.h,v 1.10 2006/09/14 08:02:38 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_date.h,v 1.11 2006/10/04 00:30:11 momjian Exp $ */
 
 #ifndef PGTYPES_DATETIME
 #define PGTYPES_DATETIME
@@ -13,7 +13,7 @@ extern        "C"
 #endif
 
 extern date *PGTYPESdate_new(void);
-extern void  PGTYPESdate_free(date *);
+extern void PGTYPESdate_free(date *);
 extern date PGTYPESdate_from_asc(char *, char **);
 extern char *PGTYPESdate_to_asc(date);
 extern date PGTYPESdate_from_timestamp(timestamp);
index b2ab1a871ed059370700ba07a6518444c6e02865..bb4f269ead3bf507725c8d8e9f7b140ebc732ffa 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.12 2006/09/14 08:02:38 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.13 2006/10/04 00:30:11 momjian Exp $ */
 
 #ifndef PGTYPES_INTERVAL
 #define PGTYPES_INTERVAL
@@ -17,8 +17,8 @@ typedef long int int64;
 #ifndef HAVE_INT64
 typedef long long int int64;
 #endif
-#else                                                   /* not HAVE_LONG_INT_64 and not
-                                                                 * HAVE_LONG_LONG_INT_64 */
+#else                          /* not HAVE_LONG_INT_64 and not
+                                * HAVE_LONG_LONG_INT_64 */
 
 /* Won't actually work, but fall back to long int so that code compiles */
 #ifndef HAVE_INT64
@@ -26,13 +26,13 @@ typedef long int int64;
 #endif
 
 #define INT64_IS_BUSTED
-#endif   /* not HAVE_LONG_INT_64 and not HAVE_LONG_LONG_INT_64 */
+#endif   /* not HAVE_LONG_INT_64 and not
+                                * HAVE_LONG_LONG_INT_64 */
 
 #if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED)
 #define HAVE_INT64_TIMESTAMP
 #endif
-
-#endif /* C_H */
+#endif   /* C_H */
 
 typedef struct
 {
index e323d579e7800bdba3857b5731d650deb1ab03f3..87b62c0b10529c2b51d9d01adf4d9c17c42070d6 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.31 2006/09/14 08:02:38 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.32 2006/10/04 00:30:11 momjian Exp $ */
 
 #include "postgres_fe.h"
 
 date *
 PGTYPESdate_new(void)
 {
-   date *result;
+   date       *result;
+
    result = (date *) pgtypes_alloc(sizeof(date));
    /* result can be NULL if we run out of memory */
    return result;
 }
 
 void
-PGTYPESdate_free(date *d)
+PGTYPESdate_free(date * d)
 {
    free(d);
 }
index b49267eb62ca423b3b29a84a714ddac294a40fac..534acdcc5fd77379325acffb05f2c64f312ca289 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.35 2006/09/14 08:02:38 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.36 2006/10/04 00:30:11 momjian Exp $ */
 
 #include "postgres_fe.h"
 #include 
@@ -307,7 +307,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
                        tm->tm_mday += val * 7;
                        if (fval != 0)
                        {
-                           int extra_days;
+                           int         extra_days;
+
                            fval *= 7;
                            extra_days = (int32) fval;
                            tm->tm_mday += extra_days;
@@ -315,6 +316,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
                            if (fval != 0)
                            {
                                int         sec;
+
                                fval *= SECS_PER_DAY;
                                sec = fval;
                                tm->tm_sec += sec;
@@ -332,7 +334,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
                        tm->tm_mon += val;
                        if (fval != 0)
                        {
-                           int         day;
+                           int         day;
+
                            fval *= DAYS_PER_MONTH;
                            day = fval;
                            tm->tm_mday += day;
@@ -340,6 +343,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse
                            if (fval != 0)
                            {
                                int         sec;
+
                                fval *= SECS_PER_DAY;
                                sec = fval;
                                tm->tm_sec += sec;
@@ -756,14 +760,15 @@ tm2interval(struct tm * tm, fsec_t fsec, interval * span)
 interval *
 PGTYPESinterval_new(void)
 {
-   interval *result;
+   interval   *result;
+
    result = (interval *) pgtypes_alloc(sizeof(interval));
    /* result can be NULL if we run out of memory */
    return result;
 }
 
 void
-PGTYPESinterval_free(interval *intvl)
+PGTYPESinterval_free(interval * intvl)
 {
    free(intvl);
 }
index c462d21673bfab109f1d52404521627af0382a72..93505eaab187cf05b232257357b34b72bf54b758 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.32 2006/08/15 06:40:19 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.33 2006/10/04 00:30:12 momjian Exp $ */
 
 #include "postgres_fe.h"
 #include 
@@ -143,6 +143,7 @@ decimal *
 PGTYPESdecimal_new(void)
 {
    decimal    *var;
+
    if ((var = (decimal *) pgtypes_alloc(sizeof(decimal))) == NULL)
        return NULL;
 
@@ -382,7 +383,7 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
    char       *realptr;
    char      **ptr = (endptr != NULL) ? endptr : &realptr;
 
-   if (!value) 
+   if (!value)
        return (NULL);
 
    ret = set_var_from_str(str, ptr, value);
@@ -398,8 +399,8 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
 char *
 PGTYPESnumeric_to_asc(numeric *num, int dscale)
 {
-   numeric *numcopy = PGTYPESnumeric_new();
-   char    *s;
+   numeric    *numcopy = PGTYPESnumeric_new();
+   char       *s;
 
    if (dscale < 0)
        dscale = num->dscale;
@@ -1468,7 +1469,7 @@ PGTYPESnumeric_from_double(double d, numeric *dst)
 {
    char        buffer[100];
    numeric    *tmp;
-   int i;
+   int         i;
 
    if (sprintf(buffer, "%f", d) == 0)
        return -1;
@@ -1490,7 +1491,7 @@ numericvar_to_double(numeric *var, double *dp)
    char       *tmp;
    double      val;
    char       *endptr;
-   numeric    *varcopy = PGTYPESnumeric_new();
+   numeric    *varcopy = PGTYPESnumeric_new();
 
    if (PGTYPESnumeric_copy(var, varcopy) < 0)
    {
@@ -1566,8 +1567,8 @@ PGTYPESnumeric_to_int(numeric *nv, int *ip)
 int
 PGTYPESnumeric_to_long(numeric *nv, long *lp)
 {
-   char *s = PGTYPESnumeric_to_asc(nv, 0);
-   char *endptr;
+   char       *s = PGTYPESnumeric_to_asc(nv, 0);
+   char       *endptr;
 
    if (s == NULL)
        return -1;
index d7011243857c1364339f4cd14271d67e92e82460..19c6bb80de69afe5bec4ccda05ebd36fe9a63fee 100644 (file)
@@ -423,47 +423,50 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
            replace_type = PGTYPES_TYPE_NOTHING;
            switch (*p)
            {
-               /* the abbreviated name of the day in the week */
-               /* XXX should be locale aware */
+                   /* the abbreviated name of the day in the week */
+                   /* XXX should be locale aware */
                case 'a':
                    replace_val.str_val = pgtypes_date_weekdays_short[dow];
                    replace_type = PGTYPES_TYPE_STRING_CONSTANT;
                    break;
-               /* the full name of the day in the week */
-               /* XXX should be locale aware */
+                   /* the full name of the day in the week */
+                   /* XXX should be locale aware */
                case 'A':
                    replace_val.str_val = days[dow];
                    replace_type = PGTYPES_TYPE_STRING_CONSTANT;
                    break;
-               /* the abbreviated name of the month */
-               /* XXX should be locale aware */
+                   /* the abbreviated name of the month */
+                   /* XXX should be locale aware */
                case 'b':
                case 'h':
                    replace_val.str_val = months[tm->tm_mon];
                    replace_type = PGTYPES_TYPE_STRING_CONSTANT;
                    break;
-               /* the full name name of the month */
-               /* XXX should be locale aware */
+                   /* the full name name of the month */
+                   /* XXX should be locale aware */
                case 'B':
                    replace_val.str_val = pgtypes_date_months[tm->tm_mon];
                    replace_type = PGTYPES_TYPE_STRING_CONSTANT;
                    break;
-               /* The  preferred  date  and  time  representation  for the
-                * current locale. */
+
+                   /*
+                    * The  preferred  date  and  time  representation  for
+                    * the current locale.
+                    */
                case 'c':
                    /* XXX */
                    break;
-               /* the century number with leading zeroes */
+                   /* the century number with leading zeroes */
                case 'C':
                    replace_val.uint_val = tm->tm_year / 100;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /* day with leading zeroes (01 - 31) */
+                   /* day with leading zeroes (01 - 31) */
                case 'd':
                    replace_val.uint_val = tm->tm_mday;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /* the date in the format mm/dd/yy */
+                   /* the date in the format mm/dd/yy */
                case 'D':
 
                    /*
@@ -480,14 +483,15 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    if (i)
                        return i;
                    break;
-               /* day with leading spaces (01 - 31) */
+                   /* day with leading spaces (01 - 31) */
                case 'e':
                    replace_val.uint_val = tm->tm_mday;
                    replace_type = PGTYPES_TYPE_UINT_2_LS;
                    break;
-               /*
-                * alternative format modifier
-                */
+
+                   /*
+                    * alternative format modifier
+                    */
                case 'E':
                    {
                        char        tmp[4] = "%Ex";
@@ -496,7 +500,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                        if (*p == '\0')
                            return -1;
                        tmp[2] = *p;
-                       
+
                        /*
                         * strftime's month is 0 based, ours is 1 based
                         */
@@ -513,10 +517,11 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                        replace_type = PGTYPES_TYPE_NOTHING;
                        break;
                    }
-               /*
-                * The ISO 8601 year with century as a decimal number. The
-                * 4-digit year corresponding to the ISO week number.
-                */
+
+                   /*
+                    * The ISO 8601 year with century as a decimal number. The
+                    * 4-digit year corresponding to the ISO week number.
+                    */
                case 'G':
                    tm->tm_mon -= 1;
                    i = strftime(q, *pstr_len, "%G", tm);
@@ -530,10 +535,11 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    tm->tm_mon += 1;
                    replace_type = PGTYPES_TYPE_NOTHING;
                    break;
-               /*
-                * Like %G, but without century, i.e., with a 2-digit year
-                * (00-99).
-                */
+
+                   /*
+                    * Like %G, but without century, i.e., with a 2-digit year
+                    * (00-99).
+                    */
                case 'g':
                    {
                        char       *fmt = "%g"; /* Keep compiler quiet about
@@ -552,57 +558,60 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                        replace_type = PGTYPES_TYPE_NOTHING;
                    }
                    break;
-               /* hour (24 hour clock) with leading zeroes */
+                   /* hour (24 hour clock) with leading zeroes */
                case 'H':
                    replace_val.uint_val = tm->tm_hour;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /* hour (12 hour clock) with leading zeroes */
+                   /* hour (12 hour clock) with leading zeroes */
                case 'I':
                    replace_val.uint_val = tm->tm_hour % 12;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /*
-                * The day of the year as a decimal number with leading zeroes.
-                * It ranges from 001 to 366.
-                */
+
+                   /*
+                    * The day of the year as a decimal number with leading
+                    * zeroes. It ranges from 001 to 366.
+                    */
                case 'j':
                    replace_val.uint_val = tm->tm_yday;
                    replace_type = PGTYPES_TYPE_UINT_3_LZ;
                    break;
-               /*
-                * The hour (24 hour clock). Leading zeroes will be turned into
-                * spaces.
-                */
+
+                   /*
+                    * The hour (24 hour clock). Leading zeroes will be turned
+                    * into spaces.
+                    */
                case 'k':
                    replace_val.uint_val = tm->tm_hour;
                    replace_type = PGTYPES_TYPE_UINT_2_LS;
                    break;
-               /*
-                * The hour (12 hour clock). Leading zeroes will be turned into
-                * spaces.
-                */
+
+                   /*
+                    * The hour (12 hour clock). Leading zeroes will be turned
+                    * into spaces.
+                    */
                case 'l':
                    replace_val.uint_val = tm->tm_hour % 12;
                    replace_type = PGTYPES_TYPE_UINT_2_LS;
                    break;
-               /* The month as a decimal number with a leading zero */
+                   /* The month as a decimal number with a leading zero */
                case 'm':
                    replace_val.uint_val = tm->tm_mon;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /* The minute as a decimal number with a leading zero */
+                   /* The minute as a decimal number with a leading zero */
                case 'M':
                    replace_val.uint_val = tm->tm_min;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /* A newline character */
+                   /* A newline character */
                case 'n':
                    replace_val.char_val = '\n';
                    replace_type = PGTYPES_TYPE_CHAR;
                    break;
-               /* the AM/PM specifier (uppercase) */
-               /* XXX should be locale aware */
+                   /* the AM/PM specifier (uppercase) */
+                   /* XXX should be locale aware */
                case 'p':
                    if (tm->tm_hour < 12)
                        replace_val.str_val = "AM";
@@ -610,8 +619,8 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                        replace_val.str_val = "PM";
                    replace_type = PGTYPES_TYPE_STRING_CONSTANT;
                    break;
-               /* the AM/PM specifier (lowercase) */
-               /* XXX should be locale aware */
+                   /* the AM/PM specifier (lowercase) */
+                   /* XXX should be locale aware */
                case 'P':
                    if (tm->tm_hour < 12)
                        replace_val.str_val = "am";
@@ -619,8 +628,8 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                        replace_val.str_val = "pm";
                    replace_type = PGTYPES_TYPE_STRING_CONSTANT;
                    break;
-               /* the time in the format %I:%M:%S %p */
-               /* XXX should be locale aware */
+                   /* the time in the format %I:%M:%S %p */
+                   /* XXX should be locale aware */
                case 'r':
                    i = dttofmtasc_replace(ts, dDate, dow, tm,
                                           q, pstr_len,
@@ -628,7 +637,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    if (i)
                        return i;
                    break;
-               /* The time in 24 hour notation (%H:%M) */
+                   /* The time in 24 hour notation (%H:%M) */
                case 'R':
                    i = dttofmtasc_replace(ts, dDate, dow, tm,
                                           q, pstr_len,
@@ -636,7 +645,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    if (i)
                        return i;
                    break;
-               /* The number of seconds since the Epoch (1970-01-01) */
+                   /* The number of seconds since the Epoch (1970-01-01) */
                case 's':
 #ifdef HAVE_INT64_TIMESTAMP
                    replace_val.int64_val = (*ts - SetEpochTimestamp()) / 1000000.0;
@@ -646,17 +655,17 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    replace_type = PGTYPES_TYPE_DOUBLE_NF;
 #endif
                    break;
-               /* seconds as a decimal number with leading zeroes */
+                   /* seconds as a decimal number with leading zeroes */
                case 'S':
                    replace_val.uint_val = tm->tm_sec;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /* A tabulator */
+                   /* A tabulator */
                case 't':
                    replace_val.char_val = '\t';
                    replace_type = PGTYPES_TYPE_CHAR;
                    break;
-               /* The time in 24 hour notation (%H:%M:%S) */
+                   /* The time in 24 hour notation (%H:%M:%S) */
                case 'T':
                    i = dttofmtasc_replace(ts, dDate, dow, tm,
                                           q, pstr_len,
@@ -664,14 +673,18 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    if (i)
                        return i;
                    break;
-               /* The day of the week as a decimal, Monday = 1, Sunday = 7 */
+
+                   /*
+                    * The day of the week as a decimal, Monday = 1, Sunday =
+                    * 7
+                    */
                case 'u':
                    replace_val.uint_val = dow;
                    if (replace_val.uint_val == 0)
                        replace_val.uint_val = 7;
                    replace_type = PGTYPES_TYPE_UINT;
                    break;
-               /* The week number of the year as a decimal number */
+                   /* The week number of the year as a decimal number */
                case 'U':
                    tm->tm_mon -= 1;
                    i = strftime(q, *pstr_len, "%U", tm);
@@ -685,10 +698,11 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    tm->tm_mon += 1;
                    replace_type = PGTYPES_TYPE_NOTHING;
                    break;
-               /*
-                * The ISO 8601:1988 week number of the current year as a
-                * decimal number.
-                */
+
+                   /*
+                    * The ISO 8601:1988 week number of the current year as a
+                    * decimal number.
+                    */
                case 'V':
                    i = strftime(q, *pstr_len, "%V", tm);
                    if (i == 0)
@@ -700,15 +714,16 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    }
                    replace_type = PGTYPES_TYPE_NOTHING;
                    break;
-               /*
-                * The day of the week as a decimal, Sunday being 0 and
-                * Monday 1.
-                */
+
+                   /*
+                    * The day of the week as a decimal, Sunday being 0 and
+                    * Monday 1.
+                    */
                case 'w':
                    replace_val.uint_val = dow;
                    replace_type = PGTYPES_TYPE_UINT;
                    break;
-               /* The week number of the year (another definition) */
+                   /* The week number of the year (another definition) */
                case 'W':
                    tm->tm_mon -= 1;
                    i = strftime(q, *pstr_len, "%U", tm);
@@ -722,10 +737,11 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    tm->tm_mon += 1;
                    replace_type = PGTYPES_TYPE_NOTHING;
                    break;
-               /*
-                * The preferred date representation for the current locale
-                * without the time.
-                */
+
+                   /*
+                    * The preferred date representation for the current
+                    * locale without the time.
+                    */
                case 'x':
                    {
                        char       *fmt = "%x"; /* Keep compiler quiet about
@@ -744,10 +760,11 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                        replace_type = PGTYPES_TYPE_NOTHING;
                    }
                    break;
-               /*
-                * The preferred time representation for the current locale
-                * without the date.
-                */
+
+                   /*
+                    * The preferred time representation for the current
+                    * locale without the date.
+                    */
                case 'X':
                    tm->tm_mon -= 1;
                    i = strftime(q, *pstr_len, "%X", tm);
@@ -761,17 +778,17 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    tm->tm_mon += 1;
                    replace_type = PGTYPES_TYPE_NOTHING;
                    break;
-               /* The year without the century (2 digits, leading zeroes) */
+                   /* The year without the century (2 digits, leading zeroes) */
                case 'y':
                    replace_val.uint_val = tm->tm_year % 100;
                    replace_type = PGTYPES_TYPE_UINT_2_LZ;
                    break;
-               /* The year with the century (4 digits) */
+                   /* The year with the century (4 digits) */
                case 'Y':
                    replace_val.uint_val = tm->tm_year;
                    replace_type = PGTYPES_TYPE_UINT;
                    break;
-               /* The time zone offset from GMT */
+                   /* The time zone offset from GMT */
                case 'z':
                    tm->tm_mon -= 1;
                    i = strftime(q, *pstr_len, "%z", tm);
@@ -785,7 +802,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    tm->tm_mon += 1;
                    replace_type = PGTYPES_TYPE_NOTHING;
                    break;
-               /* The name or abbreviation of the time zone */
+                   /* The name or abbreviation of the time zone */
                case 'Z':
                    tm->tm_mon -= 1;
                    i = strftime(q, *pstr_len, "%Z", tm);
@@ -799,18 +816,20 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
                    tm->tm_mon += 1;
                    replace_type = PGTYPES_TYPE_NOTHING;
                    break;
-               /* A % sign */
+                   /* A % sign */
                case '%':
                    replace_val.char_val = '%';
                    replace_type = PGTYPES_TYPE_CHAR;
                    break;
                case '\0':
                    /* fmtstr: foo%' - The string ends with a % sign */
+
                    /*
                     * this is not compliant to the specification
                     */
                    return -1;
                default:
+
                    /*
                     * if we don't know the pattern, we just copy it
                     */
index 910d1750a4c6d527d2cf0615ac2ad618f7788491..23469fca8608acfc6da85374bcfd3a93ec01e221 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.18 2006/08/15 06:40:19 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.19 2006/10/04 00:30:12 momjian Exp $ */
 
 #include "postgres_fe.h"
 
@@ -9,8 +9,8 @@ static void output_escaped_str(char *cmd);
 void
 output_line_number(void)
 {
-   char *line = hashline_number();
-   
+   char       *line = hashline_number();
+
    /* output_escaped_str(line); */
    fprintf(yyout, "%s", line);
    free(line);
@@ -130,7 +130,8 @@ output_statement(char *stmt, int mode, char *con)
 static void
 output_escaped_str(char *str)
 {
-   int         i, len = strlen(str);
+   int         i,
+               len = strlen(str);
 
    /* output this char by char as we have to filter " and \n */
    for (i = 0; i < len; i++)
@@ -139,7 +140,7 @@ output_escaped_str(char *str)
            fputs("\\\"", yyout);
        else if (str[i] == '\n')
            fputs("\\\n", yyout);
-       else if (str[i] == '\r' && str[i+1] == '\n')
+       else if (str[i] == '\r' && str[i + 1] == '\n')
        {
            fputs("\\\r\n", yyout);
            i++;
index eddd580e54223e058c23a688aa2b11b1f80b3313..7ed4de17edaced663bfedca46921fdf047be5888 100644 (file)
 #include 
 #include 
 
-int main(void)
+int
+main(void)
 {
-   char t1[] = "abc  def  ghi  ";
-             /* 123456789012345 */
-   char buf[50];
-   int k;
+   char        t1[] = "abc  def  ghi  ";
+
+   /* 123456789012345 */
+   char        buf[50];
+   int         k;
 
    printf("t1: _%s_\n", t1);
    rupshift(t1);
index a130aa17c9012af8268e37f7824ccb6873002774..bde792c4000d1cd0e472a9dd485e30d461cbb48e 100644 (file)
@@ -44,31 +44,36 @@ TODO:
    ECPG_INFORMIX_BAD_EXPONENT ?
 */
 
-char* decs[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
-                "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4",
-                ".500001", "-.5000001",
-                "1234567890123456789012345678.91", /* 30 digits should fit
-                                                      into decimal */
-                "1234567890123456789012345678.921", /* 31 digits should NOT
-                                                       fit into decimal */
-                "not a number",
-                NULL};
+char      *decs[] = {"2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
+   "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4",
+   ".500001", "-.5000001",
+   "1234567890123456789012345678.91",  /* 30 digits should fit into decimal */
+   "1234567890123456789012345678.921", /* 31 digits should NOT fit into
+                                        * decimal */
+   "not a number",
+NULL};
 
 
 static void
-check_errno(void);
+           check_errno(void);
 
 #define BUFSIZE 200
 
 int
 main(void)
 {
-   decimal *dec, *din;
-   char buf[BUFSIZE];
-   long l;
-   int i, j, k, q, r, count = 0;
-   double dbl;
-   decimal **decarr = (decimal **) calloc(1, sizeof(decimal));
+   decimal    *dec,
+              *din;
+   char        buf[BUFSIZE];
+   long        l;
+   int         i,
+               j,
+               k,
+               q,
+               r,
+               count = 0;
+   double      dbl;
+   decimal   **decarr = (decimal **) calloc(1, sizeof(decimal));
 
    ECPGdebug(1, stderr);
 
@@ -85,52 +90,62 @@ main(void)
        decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
        decarr[count++] = dec;
 
-       r = dectoasc(dec, buf, BUFSIZE-1, -1);
-       if (r < 0) check_errno();
+       r = dectoasc(dec, buf, BUFSIZE - 1, -1);
+       if (r < 0)
+           check_errno();
        printf("dec[%d,1]: r: %d, %s\n", i, r, buf);
 
-       r = dectoasc(dec, buf, BUFSIZE-1, 0);
-       if (r < 0) check_errno();
+       r = dectoasc(dec, buf, BUFSIZE - 1, 0);
+       if (r < 0)
+           check_errno();
        printf("dec[%d,2]: r: %d, %s\n", i, r, buf);
-       r = dectoasc(dec, buf, BUFSIZE-1, 1);
-       if (r < 0) check_errno();
+       r = dectoasc(dec, buf, BUFSIZE - 1, 1);
+       if (r < 0)
+           check_errno();
        printf("dec[%d,3]: r: %d, %s\n", i, r, buf);
-       r = dectoasc(dec, buf, BUFSIZE-1, 2);
-       if (r < 0) check_errno();
+       r = dectoasc(dec, buf, BUFSIZE - 1, 2);
+       if (r < 0)
+           check_errno();
        printf("dec[%d,4]: r: %d, %s\n", i, r, buf);
 
        din = PGTYPESdecimal_new();
-       r = dectoasc(din, buf, BUFSIZE-1, 2);
-       if (r < 0) check_errno();
+       r = dectoasc(din, buf, BUFSIZE - 1, 2);
+       if (r < 0)
+           check_errno();
        printf("dec[%d,5]: r: %d, %s\n", i, r, buf);
 
        r = dectolong(dec, &l);
-       if (r) check_errno();
-       printf("dec[%d,6]: %ld (r: %d)\n", i, r?0L:l, r);
+       if (r)
+           check_errno();
+       printf("dec[%d,6]: %ld (r: %d)\n", i, r ? 0L : l, r);
        if (r == 0)
        {
            r = deccvlong(l, din);
-           if (r) check_errno();
-           dectoasc(din, buf, BUFSIZE-1, 2);
+           if (r)
+               check_errno();
+           dectoasc(din, buf, BUFSIZE - 1, 2);
            q = deccmp(dec, din);
            printf("dec[%d,7]: %s (r: %d - cmp: %d)\n", i, buf, r, q);
        }
 
        r = dectoint(dec, &k);
-       if (r) check_errno();
-       printf("dec[%d,8]: %d (r: %d)\n", i, r?0:k, r);
+       if (r)
+           check_errno();
+       printf("dec[%d,8]: %d (r: %d)\n", i, r ? 0 : k, r);
        if (r == 0)
        {
            r = deccvint(k, din);
-           if (r) check_errno();
-           dectoasc(din, buf, BUFSIZE-1, 2);
+           if (r)
+               check_errno();
+           dectoasc(din, buf, BUFSIZE - 1, 2);
            q = deccmp(dec, din);
            printf("dec[%d,9]: %s (r: %d - cmp: %d)\n", i, buf, r, q);
        }
 
        r = dectodbl(dec, &dbl);
-       if (r) check_errno();
-       printf("dec[%d,10]: %g (r: %d)\n", i, r?0.0:dbl, r);
+       if (r)
+           check_errno();
+       printf("dec[%d,10]: %g (r: %d)\n", i, r ? 0.0 : dbl, r);
 
        PGTYPESdecimal_free(din);
        printf("\n");
@@ -141,23 +156,29 @@ main(void)
    decarr = realloc(decarr, sizeof(decimal *) * (count + 1));
    decarr[count++] = dec;
 
-   rsetnull(CDECIMALTYPE, (char *) decarr[count-1]);
-   printf("dec[%d]: %sNULL\n", count-1,
-       risnull(CDECIMALTYPE, (char *) decarr[count-1]) ? "" : "NOT ");
+   rsetnull(CDECIMALTYPE, (char *) decarr[count - 1]);
+   printf("dec[%d]: %sNULL\n", count - 1,
+          risnull(CDECIMALTYPE, (char *) decarr[count - 1]) ? "" : "NOT ");
    printf("dec[0]: %sNULL\n",
-       risnull(CDECIMALTYPE, (char *) decarr[0]) ? "" : "NOT ");
+          risnull(CDECIMALTYPE, (char *) decarr[0]) ? "" : "NOT ");
 
    r = dectoasc(decarr[3], buf, -1, -1);
-   check_errno(); printf("dectoasc with len == -1: r: %d\n", r);
+   check_errno();
+   printf("dectoasc with len == -1: r: %d\n", r);
    r = dectoasc(decarr[3], buf, 0, -1);
-   check_errno(); printf("dectoasc with len == 0: r: %d\n", r);
+   check_errno();
+   printf("dectoasc with len == 0: r: %d\n", r);
 
    for (i = 0; i < count; i++)
    {
        for (j = 0; j < count; j++)
        {
-           decimal a, s, m, d;
-           int c;
+           decimal     a,
+                       s,
+                       m,
+                       d;
+           int         c;
+
            c = deccmp(decarr[i], decarr[j]);
            printf("dec[c,%d,%d]: %d\n", i, j, c);
 
@@ -169,7 +190,7 @@ main(void)
            }
            else
            {
-               dectoasc(&a, buf, BUFSIZE-1, -1);
+               dectoasc(&a, buf, BUFSIZE - 1, -1);
                printf("dec[a,%d,%d]: %s\n", i, j, buf);
            }
 
@@ -181,7 +202,7 @@ main(void)
            }
            else
            {
-               dectoasc(&s, buf, BUFSIZE-1, -1);
+               dectoasc(&s, buf, BUFSIZE - 1, -1);
                printf("dec[s,%d,%d]: %s\n", i, j, buf);
            }
 
@@ -193,7 +214,7 @@ main(void)
            }
            else
            {
-               dectoasc(&m, buf, BUFSIZE-1, -1);
+               dectoasc(&m, buf, BUFSIZE - 1, -1);
                printf("dec[m,%d,%d]: %s\n", i, j, buf);
            }
 
@@ -205,7 +226,7 @@ main(void)
            }
            else
            {
-               dectoasc(&d, buf, BUFSIZE-1, -1);
+               dectoasc(&d, buf, BUFSIZE - 1, -1);
                printf("dec[d,%d,%d]: %s\n", i, j, buf);
            }
        }
@@ -213,7 +234,7 @@ main(void)
 
    for (i = 0; i < count; i++)
    {
-       dectoasc(decarr[i], buf, BUFSIZE-1, -1);
+       dectoasc(decarr[i], buf, BUFSIZE - 1, -1);
        printf("%d: %s\n", i, buf);
    }
 
@@ -223,7 +244,7 @@ main(void)
 static void
 check_errno(void)
 {
-   switch(errno)
+   switch (errno)
    {
        case 0:
            printf("(no errno set) - ");
index 49de0b660b17c59510771ae0c86f5f3ceb282c9b..7add41eb8eececadf6ec88e46363d1acbc0f0720 100644 (file)
 
 
 static void
-check_return(int ret);
+           check_return(int ret);
 
 static void
 date_test_strdate(char *input)
 {
-   static int i;
-   date d;
-   int r, q;
-   char dbuf[11];
+   static int  i;
+   date        d;
+   int         r,
+               q;
+   char        dbuf[11];
 
    r = rstrdate(input, &d);
    printf("r: %d ", r);
@@ -51,10 +52,11 @@ date_test_strdate(char *input)
 static void
 date_test_defmt(char *fmt, char *input)
 {
-   static int i;
-   char dbuf[11];
-   date d;
-   int q, r;
+   static int  i;
+   char        dbuf[11];
+   date        d;
+   int         q,
+               r;
 
    r = rdefmtdate(&d, fmt, input);
    printf("r: %d ", r);
@@ -76,9 +78,9 @@ date_test_defmt(char *fmt, char *input)
 static void
 date_test_fmt(date d, char *fmt)
 {
-   static int i;
-   char buf[200];
-   int r;
+   static int  i;
+   char        buf[200];
+   int         r;
 
    r = rfmtdate(d, fmt, buf);
    printf("r: %d ", r);
@@ -92,10 +94,10 @@ date_test_fmt(date d, char *fmt)
 int
 main(void)
 {
-   short mdy[3] = { 11, 23, 1959 };
-   char dbuf[11];
-   date d;
-   int r;
+   short       mdy[3] = {11, 23, 1959};
+   char        dbuf[11];
+   date        d;
+   int         r;
 
    ECPGdebug(1, stderr);
 
@@ -164,7 +166,7 @@ main(void)
 static void
 check_return(int ret)
 {
-   switch(ret)
+   switch (ret)
    {
        case ECPG_INFORMIX_ENOTDMY:
            printf("(ECPG_INFORMIX_ENOTDMY)");
index d000054abb7845f27acf47a512b6a735aa32a707..8c9d76986c271bda1c1de8666929a191188d9b77 100644 (file)
 
 
 static void
-check_return(int ret);
+           check_return(int ret);
 
 static void
 fmtlong(long lng, char *fmt)
 {
-   static int i;
-   int r;
-   char buf[30];
+   static int  i;
+   int         r;
+   char        buf[30];
 
    r = rfmtlong(lng, fmt, buf);
    printf("r: %d ", r);
@@ -62,7 +62,7 @@ main(void)
 static void
 check_return(int ret)
 {
-   switch(ret)
+   switch (ret)
    {
        case ECPG_INFORMIX_ENOTDMY:
            printf("(ECPG_INFORMIX_ENOTDMY)");
index 9ee19ace763d629e51da9afd044aa1d5948aacbb..7cfa6a80d1225fc1745630ed9c1088a77d8447b3 100644 (file)
@@ -30,65 +30,66 @@ test_null(int type, char *ptr)
    printf("null: %d\n", risnull(type, ptr));
 }
 
-int main(void)
+int
+main(void)
 {
-   
+
 #line 15 "rnull.pgc"
char  c []   = "abc       " ;
  char        c[] = "abc       ";
 
 #line 15 "rnull.pgc"
 
-   
+
 #line 16 "rnull.pgc"
short  s   = 17 ;
  short       s = 17;
 
 #line 16 "rnull.pgc"
 
-   
+
 #line 17 "rnull.pgc"
int  i   = - 74874 ;
  int         i = -74874;
 
 #line 17 "rnull.pgc"
 
-   
+
 #line 18 "rnull.pgc"
bool  b   = 1 ;
  bool        b = 1;
 
 #line 18 "rnull.pgc"
 
-   
+
 #line 19 "rnull.pgc"
float  f   = 3.71 ;
  float       f = 3.71;
 
 #line 19 "rnull.pgc"
 
-   
+
 #line 20 "rnull.pgc"
long  l   = 487444 ;
  long        l = 487444;
 
 #line 20 "rnull.pgc"
 
-   
+
 #line 21 "rnull.pgc"
double  dbl   = 404.404 ;
  double      dbl = 404.404;
 
 #line 21 "rnull.pgc"
 
-   
+
 #line 22 "rnull.pgc"
decimal  dec    ;
  decimal     dec;
 
 #line 22 "rnull.pgc"
 
-   
+
 #line 23 "rnull.pgc"
date  dat    ;
  date        dat;
 
 #line 23 "rnull.pgc"
 
-   
+
 #line 24 "rnull.pgc"
timestamp  tmp    ;
  timestamp   tmp;
 
 #line 24 "rnull.pgc"
 
@@ -98,50 +99,65 @@ int main(void)
 #line 27 "rnull.pgc"
 
 
-   { ECPGconnect(__LINE__, 1, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 1, "regress1", NULL, NULL, NULL, 0);
 #line 29 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "rnull.pgc"
 
 
-   { ECPGdo(__LINE__, 1, 0, NULL, "create  table test ( id int   , c char  ( 10 )    , s smallint   , i int   , b bool   , f float    , l bigint   , dbl double precision   , dec decimal    , dat date   , tmp timestamptz   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 0, NULL, "create  table test ( id int   , c char  ( 10 )    , s smallint   , i int   , b bool   , f float    , l bigint   , dbl double precision   , dec decimal    , dat date   , tmp timestamptz   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 33 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 33 "rnull.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 34 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 34 "rnull.pgc"
 
 
-   { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  ) values( 1 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ", 
-   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  ) values( 1 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ",
+              ECPGt_char, (c), (long) sizeof("abc       "), (long) 1, (sizeof("abc       ")) *sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 38 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 38 "rnull.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 39 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "rnull.pgc"
 
 
@@ -156,65 +172,74 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    rsetnull(CDATETYPE, (char *) &dat);
    rsetnull(CDTIMETYPE, (char *) &tmp);
 
-   { ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  , dec  , dat  , tmp  ) values( 2 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ", 
-   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id  , c  , s  , i  , b  , f  , l  , dbl  , dec  , dat  , tmp  ) values( 2 ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ,  ? ) ",
+              ECPGt_char, (c), (long) sizeof("abc       "), (long) 1, (sizeof("abc       ")) *sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_decimal, &(dec), (long) 1, (long) 1, sizeof(decimal),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_date, &(dat), (long) 1, (long) 1, sizeof(date),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_timestamp, &(tmp), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 54 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 54 "rnull.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 55 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 55 "rnull.pgc"
 
 
    printf("first select\n");
 
-   { ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 1  ", ECPGt_EOIT, 
-   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 1  ", ECPGt_EOIT,
+              ECPGt_char, (c), (long) sizeof("abc       "), (long) 1, (sizeof("abc       ")) *sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_decimal, &(dec), (long) 1, (long) 1, sizeof(decimal),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_date, &(dat), (long) 1, (long) 1, sizeof(date),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_timestamp, &(tmp), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 61 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 61 "rnull.pgc"
 
 
@@ -231,30 +256,33 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
 
    printf("second select\n");
 
-   { ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 2  ", ECPGt_EOIT, 
-   ECPGt_char,(c),(long)sizeof("abc       "),(long)1,(sizeof("abc       "))*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_short,&(s),(long)1,(long)1,sizeof(short), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_bool,&(b),(long)1,(long)1,sizeof(bool), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_float,&(f),(long)1,(long)1,sizeof(float), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_long,&(l),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_double,&(dbl),(long)1,(long)1,sizeof(double), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_decimal,&(dec),(long)1,(long)1,sizeof(decimal), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_date,&(dat),(long)1,(long)1,sizeof(date), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_timestamp,&(tmp),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 0, NULL, "select  c , s , i , b , f , l , dbl , dec , dat , tmp  from test where id = 2  ", ECPGt_EOIT,
+              ECPGt_char, (c), (long) sizeof("abc       "), (long) 1, (sizeof("abc       ")) *sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_short, &(s), (long) 1, (long) 1, sizeof(short),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_bool, &(b), (long) 1, (long) 1, sizeof(bool),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_float, &(f), (long) 1, (long) 1, sizeof(float),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_long, &(l), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_double, &(dbl), (long) 1, (long) 1, sizeof(double),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_decimal, &(dec), (long) 1, (long) 1, sizeof(decimal),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_date, &(dat), (long) 1, (long) 1, sizeof(date),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_timestamp, &(tmp), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 78 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 78 "rnull.pgc"
 
 
@@ -269,23 +297,32 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    test_null(CDATETYPE, (char *) &dat);
    test_null(CDTIMETYPE, (char *) &tmp);
 
-   { ECPGdo(__LINE__, 1, 0, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 0, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
 #line 91 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 91 "rnull.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 92 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 92 "rnull.pgc"
 
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 94 "rnull.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 94 "rnull.pgc"
 
 
index 53e39a008d791c80f225a95974f9f65d917e630d..166a15c5f09423b93458ab886ed02ceb50dac2e0 100644 (file)
 
 
 static void openit(void);
-static void dosqlprint(void) {
+static void
+dosqlprint(void)
+{
    printf("doSQLprint: Error: %s\n", sqlca.sqlerrm.sqlerrmc);
 }
 
-int main(void)
+int
+main(void)
 {
-   
+
 #line 14 "test_informix.pgc"
int  i   = 14 ;
  int         i = 14;
 
 #line 14 "test_informix.pgc"
-   
+
+
 #line 15 "test_informix.pgc"
- decimal  j    ,  m    ,  n    ;
+   decimal     j,
+               m,
+               n;
 
 #line 15 "test_informix.pgc"
 
 
    ECPGdebug(1, stderr);
-   /* exec sql whenever sqlerror  do dosqlprint (  ) ; */
+   /* exec sql whenever sqlerror  do dosqlprint (  ) ; */
 #line 18 "test_informix.pgc"
 
 
-   { ECPGconnect(__LINE__, 1, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 1, "regress1", NULL, NULL, NULL, 0);
 #line 20 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 20 "test_informix.pgc"
 
-   if (sqlca.sqlcode != 0) exit(1);
+   if (sqlca.sqlcode != 0)
+       exit(1);
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "create  table test ( i int   primary key   , j int   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "create  table test ( i int   primary key   , j int   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 23 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 23 "test_informix.pgc"
 
 
    /* this INSERT works */
-   rsetnull(CDECIMALTYPE, (char *)&j);
-   { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i  , j  ) values( 7 ,  ? ) ", 
-   ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   rsetnull(CDECIMALTYPE, (char *) &j);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i  , j  ) values( 7 ,  ? ) ",
+              ECPGt_decimal, &(j), (long) 1, (long) 1, sizeof(decimal),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 27 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 27 "test_informix.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 28 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 28 "test_informix.pgc"
 
 
    /* this INSERT should fail because i is a unique column */
-   { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i  , j  ) values( 7 , 12 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i  , j  ) values( 7 , 12 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 31 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 31 "test_informix.pgc"
 
    printf("INSERT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
-   if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback");
+   if (sqlca.sqlcode != 0)
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 33 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 33 "test_informix.pgc"
 
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i  , j  ) values(  ? , 1 ) ", 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "insert into test ( i  , j  ) values(  ? , 1 ) ",
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 35 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 35 "test_informix.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 36 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 36 "test_informix.pgc"
 
 
    /* this will fail (more than one row in subquery) */
-   { ECPGdo(__LINE__, 1, 1, NULL, "select  i  from test where j = ( select  j  from test    )  ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "select  i  from test where j = ( select  j  from test    )  ", ECPGt_EOIT, ECPGt_EORT);
 #line 39 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 39 "test_informix.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 40 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 40 "test_informix.pgc"
 
 
    /* this however should be ok */
-   { ECPGdo(__LINE__, 1, 1, NULL, "select  i  from test where j = ( select  j  from test    order by i limit 1  )  ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "select  i  from test where j = ( select  j  from test    order by i limit 1  )  ", ECPGt_EOIT, ECPGt_EORT);
 #line 43 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 43 "test_informix.pgc"
 
    printf("SELECT: %ld=%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
-   if (sqlca.sqlcode != 0) { ECPGtrans(__LINE__, NULL, "rollback");
+   if (sqlca.sqlcode != 0)
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 45 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 45 "test_informix.pgc"
 
 
-    ECPG_informix_set_var( 0, &( i ), __LINE__);\
-  /* declare c  cursor  for select  *  from test where i <=  ?   */
+   ECPG_informix_set_var(0, &(i), __LINE__);
+   \
+   /* declare c  cursor  for select  *  from test where i <=  ?   */
 #line 47 "test_informix.pgc"
 
-   openit();
+       openit();
 
    deccvint(0, &j);
 
    while (1)
    {
-       { ECPGdo(__LINE__, 1, 1, NULL, "fetch forward from c", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+       {
+           ECPGdo(__LINE__, 1, 1, NULL, "fetch forward from c", ECPGt_EOIT,
+                  ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+                  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+                  ECPGt_decimal, &(j), (long) 1, (long) 1, sizeof(decimal),
+                  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 54 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+           if (sqlca.sqlcode < 0)
+               dosqlprint();
+       }
 #line 54 "test_informix.pgc"
 
-       if (sqlca.sqlcode == 100) break;
-       else if (sqlca.sqlcode != 0) printf ("Error: %ld\n", sqlca.sqlcode);
+       if (sqlca.sqlcode == 100)
+           break;
+       else if (sqlca.sqlcode != 0)
+           printf("Error: %ld\n", sqlca.sqlcode);
 
-       if (risnull(CDECIMALTYPE, (char *)&j))
+       if (risnull(CDECIMALTYPE, (char *) &j))
            printf("%d NULL\n", i);
        else
        {
-           int a;
+           int         a;
 
            dectoint(&j, &a);
            printf("%d %d\n", i, a);
@@ -177,70 +227,94 @@ if (sqlca.sqlcode < 0) dosqlprint (  );}
    deccvint(7, &j);
    deccvint(14, &m);
    decadd(&j, &m, &n);
-   { ECPGdo(__LINE__, 1, 1, NULL, "delete from test  where i =  ? ", 
-   ECPGt_decimal,&(n),(long)1,(long)1,sizeof(decimal), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "delete from test  where i =  ? ",
+              ECPGt_decimal, &(n), (long) 1, (long) 1, sizeof(decimal),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 72 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 72 "test_informix.pgc"
 
    printf("DELETE: %ld\n", sqlca.sqlcode);
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "select  1  from test where i = 14  ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "select  1  from test where i = 14  ", ECPGt_EOIT, ECPGt_EORT);
 #line 75 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 75 "test_informix.pgc"
 
    printf("Exists: %ld\n", sqlca.sqlcode);
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "select  1  from test where i = 147  ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "select  1  from test where i = 147  ", ECPGt_EOIT, ECPGt_EORT);
 #line 78 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 78 "test_informix.pgc"
 
    printf("Does not exist: %ld\n", sqlca.sqlcode);
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 81 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 81 "test_informix.pgc"
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
 #line 82 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 82 "test_informix.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 83 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 83 "test_informix.pgc"
 
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 85 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 85 "test_informix.pgc"
 
 
    return 0;
 }
 
-static void openit(void)
+static void
+openit(void)
 {
-   { ECPGdo(__LINE__, 1, 1, NULL, "declare c  cursor  for select  *  from test where i <=  ?  ", 
-   ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "declare c  cursor  for select  *  from test where i <=  ?  ",
+              ECPGt_int, &(*(int *) (ECPG_informix_get_var(0))), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 92 "test_informix.pgc"
 
-if (sqlca.sqlcode < 0) dosqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           dosqlprint();
+   }
 #line 92 "test_informix.pgc"
 
 }
-
index 12c34203fa5316b88bec9c9bb20f5900b9193cce..7926d782516ba5528f4c76c2783bf7f0cc21c8b4 100644 (file)
@@ -79,7 +79,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 5 "test_informix2.pgc"
@@ -97,72 +96,79 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 /* Check SQLCODE, and produce a "standard error" if it's wrong! */
-static void sql_check(char *fn, char *caller, int ignore)
+static void
+sql_check(char *fn, char *caller, int ignore)
 {
-  char errorstring[255];
-
-  if (SQLCODE == ignore)
-    return;
-  else
-  {
-    if (SQLCODE != 0)
-    {
-
-      sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]",
-             SQLCODE, caller, fn, sqlca.sqlerrm.sqlerrmc);
-      fprintf(stderr, "%s", errorstring);
-      printf("%s\n", errorstring);
-
-      /* attempt a ROLLBACK */
-      { ECPGtrans(__LINE__, NULL, "rollback");}
+   char        errorstring[255];
+
+   if (SQLCODE == ignore)
+       return;
+   else
+   {
+       if (SQLCODE != 0)
+       {
+
+           sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]",
+                   SQLCODE, caller, fn, sqlca.sqlerrm.sqlerrmc);
+           fprintf(stderr, "%s", errorstring);
+           printf("%s\n", errorstring);
+
+           /* attempt a ROLLBACK */
+           {
+               ECPGtrans(__LINE__, NULL, "rollback");
+           }
 #line 27 "test_informix2.pgc"
 
 
-      if (SQLCODE == 0)
-      {
-        sprintf(errorstring, "Rollback successful.\n");
-      } else {
-        sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE);
-      }
+           if (SQLCODE == 0)
+           {
+               sprintf(errorstring, "Rollback successful.\n");
+           }
+           else
+           {
+               sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE);
+           }
 
-      fprintf(stderr, "%s", errorstring);
-      printf("%s\n", errorstring);
+           fprintf(stderr, "%s", errorstring);
+           printf("%s\n", errorstring);
 
-      exit(1);
-    }
-  }
+           exit(1);
+       }
+   }
 }
 
 
 
-int main(void)
+int
+main(void)
 {
    /* exec sql begin declare section */
-        
-        
-        
-        
-        
-   
+
+
+
+
+
+
 #line 49 "test_informix2.pgc"
int  c    ;
  int         c;
+
 #line 50 "test_informix2.pgc"
timestamp  d    ;
  timestamp   d;
+
 #line 51 "test_informix2.pgc"
timestamp  e    ;
  timestamp   e;
+
 #line 52 "test_informix2.pgc"
timestamp  maxd    ;
  timestamp   maxd;
+
 #line 53 "test_informix2.pgc"
- char  dbname [ 30 ]    ;
+   char        dbname[30];
+
 /* exec sql end declare section */
 #line 54 "test_informix2.pgc"
 
 
-   interval *intvl;
+   interval   *intvl;
 
    /* exec sql whenever sqlerror  sqlprint ; */
 #line 58 "test_informix2.pgc"
@@ -171,57 +177,75 @@ int main(void)
    ECPGdebug(1, stderr);
 
    strcpy(dbname, "regress1");
-   { ECPGconnect(__LINE__, 1, dbname , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 1, dbname, NULL, NULL, NULL, 0);
 #line 63 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 63 "test_informix2.pgc"
 
    sql_check("main", "connect", 0);
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT);
 #line 66 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 66 "test_informix2.pgc"
 
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "create  table history ( customerid integer   , timestamp timestamp without time zone   , action_taken char  ( 5 )    , narrative varchar ( 100 )    )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "create  table history ( customerid integer   , timestamp timestamp without time zone   , action_taken char  ( 5 )    , narrative varchar ( 100 )    )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 68 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 68 "test_informix2.pgc"
 
    sql_check("main", "create", 0);
-   
-   { ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid  , timestamp  , action_taken  , narrative  ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' ) ", ECPGt_EOIT, ECPGt_EORT);
+
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid  , timestamp  , action_taken  , narrative  ) values( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 73 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 73 "test_informix2.pgc"
 
    sql_check("main", "insert", 0);
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "select  max ( timestamp )  from history   ", ECPGt_EOIT, 
-   ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "select  max ( timestamp )  from history   ", ECPGt_EOIT,
+            ECPGt_timestamp, &(maxd), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 78 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 78 "test_informix2.pgc"
 
    sql_check("main", "select max", 100);
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "select  customerid , timestamp  from history where timestamp =  ?    limit 1 ", 
-   ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-   ECPGt_int,&(c),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_timestamp,&(d),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "select  customerid , timestamp  from history where timestamp =  ?    limit 1 ",
+            ECPGt_timestamp, &(maxd), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT,
+              ECPGt_int, &(c), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_timestamp, &(d), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 85 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 85 "test_informix2.pgc"
 
    sql_check("main", "select", 0);
@@ -233,44 +257,59 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
    c++;
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid  , timestamp  , action_taken  , narrative  ) values(  ? ,  ? , 'test' , 'test' ) ", 
-   ECPGt_int,&(c),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "insert into history ( customerid  , timestamp  , action_taken  , narrative  ) values(  ? ,  ? , 'test' , 'test' ) ",
+              ECPGt_int, &(c), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_timestamp, &(e), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 97 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 97 "test_informix2.pgc"
 
    sql_check("main", "update", 0);
-  
-   { ECPGtrans(__LINE__, NULL, "commit");
+
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 100 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 100 "test_informix2.pgc"
 
 
-   { ECPGdo(__LINE__, 1, 1, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 1, 1, NULL, "drop table history ", ECPGt_EOIT, ECPGt_EORT);
 #line 102 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 102 "test_informix2.pgc"
 
    sql_check("main", "drop", 0);
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 105 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 105 "test_informix2.pgc"
 
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 107 "test_informix2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 107 "test_informix2.pgc"
 
    sql_check("main", "disconnect", 0);
@@ -280,13 +319,13 @@ if (sqlca.sqlcode < 0) sqlprint();}
    exit(0);
 
 /*
-                 Table "public.history"
-    Column    |            Type             | Modifiers
+                Table "public.history"
+   Column    |            Type             | Modifiers
 --------------+-----------------------------+-----------
- customerid   | integer                     | not null
- timestamp    | timestamp without time zone | not null
- action_taken | character(5)                | not null
- narrative    | character varying(100)      |
+ customerid   | integer                        | not null
+ timestamp   | timestamp without time zone | not null
+ action_taken | character(5)               | not null
+ narrative   | character varying(100)      |
 */
 
 }
index 86f3d8d1d375728c3419e7213ff4c50358f88a77..59a3b7399725c64db5cff6f645629dc10c408ade 100644 (file)
@@ -25,125 +25,184 @@ int
 main(void)
 {
 /* exec sql begin declare section */
-    
-    
+
+
 
 #line 16 "test1.pgc"
char  db [ 200 ]    ;
  char        db[200];
+
 #line 17 "test1.pgc"
- char  pw [ 200 ]    ;
+   char        pw[200];
+
 /* exec sql end declare section */
 #line 18 "test1.pgc"
 
 
    ECPGdebug(1, stderr);
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
+   }
 #line 22 "test1.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser  encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser  encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 23 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 24 "test1.pgc"
-  /* <-- "main" not specified */
+   /* <-- "main" not specified */
 
-   { ECPGconnect(__LINE__, 0, "connectdb@localhost" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb@localhost", NULL, NULL, "main", 0);
+   }
 #line 26 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 27 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "@localhost" , "connectdb" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "@localhost", "connectdb", NULL, "main", 0);
+   }
 #line 29 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 30 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "connectdb@localhost:55432" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb@localhost:55432", NULL, NULL, "main", 0);
+   }
 #line 32 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 33 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "@localhost:55432" , "connectdb" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "@localhost:55432", "connectdb", NULL, "main", 0);
+   }
 #line 35 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 36 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "connectdb:55432" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb:55432", NULL, NULL, "main", 0);
+   }
 #line 38 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 39 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, ":55432" , "connectdb" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, ":55432", "connectdb", NULL, "main", 0);
+   }
 #line 41 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 42 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/connectdb", "connectuser", "connectpw", NULL, 0);
+   }
 #line 44 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 45 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/" , "connectdb" , NULL , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/", "connectdb", NULL, NULL, 0);
+   }
 #line 47 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 48 "test1.pgc"
 
 
    strcpy(pw, "connectpw");
    strcpy(db, "tcp:postgresql://localhost:55432/connectdb");
-   { ECPGconnect(__LINE__, 0, db , "connectuser" , pw , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, db, "connectuser", pw, NULL, 0);
+   }
 #line 52 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 53 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", "connectpw", NULL, 0);
+   }
 #line 55 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 56 "test1.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , NULL , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", NULL, NULL, 0);
+   }
 #line 58 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 59 "test1.pgc"
 
 
    /* wrong db */
-   { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/nonexistant" , "connectuser" , "connectpw" , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:55432/nonexistant", "connectuser", "connectpw", NULL, 0);
+   }
 #line 62 "test1.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 63 "test1.pgc"
 
 
    /* wrong port */
-   { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:20/connectdb" , "connectuser" , "connectpw" , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost:20/connectdb", "connectuser", "connectpw", NULL, 0);
+   }
 #line 66 "test1.pgc"
 
    /* no disconnect necessary */
 
    /* wrong password */
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb" , "connectuser" , "wrongpw" , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://localhost:55432/connectdb", "connectuser", "wrongpw", NULL, 0);
+   }
 #line 70 "test1.pgc"
 
    /* no disconnect necessary */
index ce18b08bf89664cb4ab59f74c3c20e004ec0de1b..464a7cdf4d3a6cdd6c5f3379d5c7e0d2f3a7f6e0 100644 (file)
@@ -32,14 +32,15 @@ int
 main(void)
 {
 /* exec sql begin declare section */
-    
-    
+
+
 
 #line 17 "test2.pgc"
char  id [ 200 ]    ;
  char        id[200];
+
 #line 18 "test2.pgc"
- char  res [ 200 ]    ;
+   char        res[200];
+
 /* exec sql end declare section */
 #line 19 "test2.pgc"
 
@@ -47,56 +48,78 @@ main(void)
    ECPGdebug(1, stderr);
 
    strcpy(id, "first");
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , id, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, id, 0);
+   }
 #line 24 "test2.pgc"
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0);
+   }
 #line 25 "test2.pgc"
 
 
    /* this selects from "second" which was opened last */
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT, 
-   ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT,
+              ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 28 "test2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, "first", "select  current_database ()     ", ECPGt_EOIT, 
-   ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, "first", "select  current_database ()     ", ECPGt_EOIT,
+              ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 29 "test2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, "second", "select  current_database ()     ", ECPGt_EOIT, 
-   ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, "second", "select  current_database ()     ", ECPGt_EOIT,
+              ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 30 "test2.pgc"
 
 
-   { ECPGsetconn(__LINE__, "first");}
+   {
+       ECPGsetconn(__LINE__, "first");
+   }
 #line 32 "test2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT, 
-   ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT,
+              ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 33 "test2.pgc"
 
 
    /* this will disconnect from "first" */
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 36 "test2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT, 
-   ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT,
+              ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 37 "test2.pgc"
 
 
    /* error here since "first" is already disconnected */
-   { ECPGdisconnect(__LINE__, id);}
+   {
+       ECPGdisconnect(__LINE__, id);
+   }
 #line 40 "test2.pgc"
 
 
    /* disconnect from "second" */
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 43 "test2.pgc"
 
 
index 5e4451a4c5740ae35629f21915a4c02267edb56e..496083da5e05f072017f0dab6c6a29f4bd548f56 100644 (file)
@@ -31,14 +31,15 @@ int
 main(void)
 {
 /* exec sql begin declare section */
-    
-    
+
+
 
 #line 16 "test3.pgc"
char  id [ 200 ]    ;
  char        id[200];
+
 #line 17 "test3.pgc"
- char  res [ 200 ]    ;
+   char        res[200];
+
 /* exec sql end declare section */
 #line 18 "test3.pgc"
 
@@ -46,60 +47,83 @@ main(void)
    ECPGdebug(1, stderr);
 
    strcpy(id, "first");
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , id, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, id, 0);
+   }
 #line 23 "test3.pgc"
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0);
+   }
 #line 24 "test3.pgc"
 
 
    /* this selects from "second" which was opened last */
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT, 
-   ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT,
+              ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 27 "test3.pgc"
 
 
    /* will close "second" */
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 30 "test3.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT, 
-   ECPGt_char,(res),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  current_database ()     ", ECPGt_EOIT,
+              ECPGt_char, (res), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 31 "test3.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "second", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "second", 0);
+   }
 #line 33 "test3.pgc"
 
    /* will close "second" */
-   { ECPGdisconnect(__LINE__, "DEFAULT");}
+   {
+       ECPGdisconnect(__LINE__, "DEFAULT");
+   }
 #line 35 "test3.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "second", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "second", 0);
+   }
 #line 37 "test3.pgc"
 
-   { ECPGdisconnect(__LINE__, "ALL");}
+   {
+       ECPGdisconnect(__LINE__, "ALL");
+   }
 #line 38 "test3.pgc"
 
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 40 "test3.pgc"
 
-   { ECPGdisconnect(__LINE__, "DEFAULT");}
+   {
+       ECPGdisconnect(__LINE__, "DEFAULT");
+   }
 #line 41 "test3.pgc"
 
-   { ECPGdisconnect(__LINE__, "ALL");}
+   {
+       ECPGdisconnect(__LINE__, "ALL");
+   }
 #line 42 "test3.pgc"
 
 
    /*
-    * exec sql disconnect;
-    * exec sql disconnect name;
+    * exec sql disconnect; exec sql disconnect name;
     *
-    *     are used in other tests
+    * are used in other tests
     */
 
    return (0);
index ba15660f336bf82f881c3ab5465b4aa639d37354..2b9f4ff2972f73ac87bd475a456a3b36d2329576 100644 (file)
@@ -28,15 +28,21 @@ main(void)
 {
    ECPGdebug(1, stderr);
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "main", 0);
+   }
 #line 13 "test4.pgc"
 
 
-   { ECPGsetconn(__LINE__, "main");}
+   {
+       ECPGsetconn(__LINE__, "main");
+   }
 #line 15 "test4.pgc"
 
 
-   { ECPGdisconnect(__LINE__, "DEFAULT");}
+   {
+       ECPGdisconnect(__LINE__, "DEFAULT");
+   }
 #line 17 "test4.pgc"
 
 
index 6075aacf13cbbff95b5d9b02b71206aad72396e3..36e902979cee091a834465ae8c9f2a5b229097fb 100644 (file)
@@ -22,122 +22,181 @@ int
 main(void)
 {
 /* exec sql begin declare section */
-    
-    
+
+
 
 #line 16 "test5.pgc"
char  db [ 200 ]    ;
  char        db[200];
+
 #line 17 "test5.pgc"
- char  id [ 200 ]    ;
+   char        id[200];
+
 /* exec sql end declare section */
 #line 18 "test5.pgc"
 
 
    ECPGdebug(1, stderr);
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
+   }
 #line 22 "test5.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser  encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "alter user connectuser  encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 23 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 24 "test5.pgc"
-  /* <-- "main" not specified */
+   /* <-- "main" not specified */
 
    strcpy(db, "connectdb");
    strcpy(id, "main");
-   { ECPGconnect(__LINE__, 0, db , NULL,NULL , id, 0); }
+   {
+       ECPGconnect(__LINE__, 0, db, NULL, NULL, id, 0);
+   }
 #line 28 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, id);}
+   {
+       ECPGdisconnect(__LINE__, id);
+   }
 #line 29 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
+   }
 #line 31 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 32 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
+   }
 #line 34 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 35 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
+   }
 #line 37 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 38 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "" , "connectdb" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "", "connectdb", NULL, "main", 0);
+   }
 #line 40 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 41 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", "connectuser", "connectdb", "main", 0);
+   }
 #line 43 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 44 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0);
+   }
 #line 46 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 47 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0);
+   }
 #line 49 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 50 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb", "connectuser", NULL, "main", 0);
+   }
 #line 52 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 53 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb", "connectuser", NULL, "main", 0);
+   }
 #line 55 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 56 "test5.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "connectdb" , NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/", "connectdb", NULL, "main", 0);
+   }
 #line 58 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 59 "test5.pgc"
 
 
    /* connect twice */
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
+   }
 #line 62 "test5.pgc"
 
-   { ECPGconnect(__LINE__, 0, "connectdb" , NULL,NULL , "main", 0); }
+   {
+       ECPGconnect(__LINE__, 0, "connectdb", NULL, NULL, "main", 0);
+   }
 #line 63 "test5.pgc"
 
-   { ECPGdisconnect(__LINE__, "main");}
+   {
+       ECPGdisconnect(__LINE__, "main");
+   }
 #line 64 "test5.pgc"
 
 
    /* not connected */
-   { ECPGdisconnect(__LINE__, "nonexistant");}
+   {
+       ECPGdisconnect(__LINE__, "nonexistant");
+   }
 #line 67 "test5.pgc"
 
 
index 0ce27f4596d36267478f7cbb0b1d89a53c3e78eb..a81863467514f37e206eabc343f639afbd96e671 100644 (file)
@@ -29,94 +29,116 @@ int
 main(void)
 {
    /* exec sql begin declare section */
-        
-        
-         
-        
-   
+
+
+
+
+
 #line 14 "dt_test.pgc"
date  date1    ;
  date        date1;
+
 #line 15 "dt_test.pgc"
timestamp  ts1    ;
  timestamp   ts1;
+
 #line 16 "dt_test.pgc"
- interval * iv1    ,  iv2    ;
+   interval   *iv1,
+               iv2;
+
 #line 17 "dt_test.pgc"
- char * text    ;
+   char       *text;
+
 /* exec sql end declare section */
 #line 18 "dt_test.pgc"
 
-   date date2;
-   int mdy[3] = { 4, 19, 1998 };
-   char *fmt, *out, *in;
-   char *d1 = "Mon Jan 17 1966";
-   char *t1 = "2000-7-12 17:34:29";
-   int i;
-
-        ECPGdebug(1, stderr);
-        /* exec sql whenever sqlerror  do sqlprint (  ) ; */
+   date        date2;
+   int         mdy[3] = {4, 19, 1998};
+   char       *fmt,
+              *out,
+              *in;
+   char       *d1 = "Mon Jan 17 1966";
+   char       *t1 = "2000-7-12 17:34:29";
+   int         i;
+
+   ECPGdebug(1, stderr);
+   /* exec sql whenever sqlerror  do sqlprint (  ) ; */
 #line 27 "dt_test.pgc"
 
-        { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 28 "dt_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 28 "dt_test.pgc"
 
-        { ECPGdo(__LINE__, 0, 1, NULL, "create  table date_test ( d date   , ts timestamp    )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table date_test ( d date   , ts timestamp    )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 29 "dt_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "dt_test.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
 #line 30 "dt_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 30 "dt_test.pgc"
 
 
-   date1 = PGTYPESdate_from_asc(d1, NULL); 
-   ts1 = PGTYPEStimestamp_from_asc(t1, NULL); 
+   date1 = PGTYPESdate_from_asc(d1, NULL);
+   ts1 = PGTYPEStimestamp_from_asc(t1, NULL);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into date_test ( d  , ts  ) values(  ? ,  ? ) ", 
-   ECPGt_date,&(date1),(long)1,(long)1,sizeof(date), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into date_test ( d  , ts  ) values(  ? ,  ? ) ",
+              ECPGt_date, &(date1), (long) 1, (long) 1, sizeof(date),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_timestamp, &(ts1), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 35 "dt_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 35 "dt_test.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from date_test where d =  ?  ", 
-   ECPGt_date,&(date1),(long)1,(long)1,sizeof(date), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-   ECPGt_date,&(date1),(long)1,(long)1,sizeof(date), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_timestamp,&(ts1),(long)1,(long)1,sizeof(timestamp), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from date_test where d =  ?  ",
+              ECPGt_date, &(date1), (long) 1, (long) 1, sizeof(date),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT,
+              ECPGt_date, &(date1), (long) 1, (long) 1, sizeof(date),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_timestamp, &(ts1), (long) 1, (long) 1, sizeof(timestamp),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 37 "dt_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "dt_test.pgc"
 
 
    text = PGTYPESdate_to_asc(date1);
-   printf ("Date: %s\n", text);
+
+   printf("Date: %s\n", text);
    free(text);
 
    text = PGTYPEStimestamp_to_asc(ts1);
-   printf ("timestamp: %s\n", text);
+
+   printf("timestamp: %s\n", text);
    free(text);
 
    iv1 = PGTYPESinterval_from_asc("13556 days 12 hours 34 minutes 14 seconds ", NULL);
    PGTYPESinterval_copy(iv1, &iv2);
    text = PGTYPESinterval_to_asc(&iv2);
-   printf ("interval: %s\n", text);
+
+   printf("interval: %s\n", text);
    free(text);
 
    PGTYPESdate_mdyjul(mdy, &date2);
@@ -131,8 +153,9 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
 
    ts1 = PGTYPEStimestamp_from_asc("2003-12-04 17:34:29", NULL);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    fmt = "(ddd), mmm. dd, yyyy, repeat: (ddd), mmm. dd, yyyy. end";
-   out = (char*) malloc(strlen(fmt) + 1);
+   out = (char *) malloc(strlen(fmt) + 1);
    date1 = PGTYPESdate_from_timestamp(ts1);
    PGTYPESdate_fmt_asc(date1, fmt, out);
    printf("date_day of %s is %d\n", text, PGTYPESdate_dayofweek(date1));
@@ -142,249 +165,306 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
 
    /* rdate_defmt_asc() */
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "yy/mm/dd";
    in = "In the year 1995, the month of December, it is the 25th day";
-   /*    0123456789012345678901234567890123456789012345678901234567890
-    *    0         1         2         3         4         5         6
+
+   /*
+    * 0123456789012345678901234567890123456789012345678901234567890 0
+    * 1         2         3         4         5         6
     */
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc1: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "mmmm. dd. yyyy";
    in = "12/25/95";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc2: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "yy/mm/dd";
    in = "95/12/25";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc3: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "yy/mm/dd";
    in = "1995, December 25th";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc4: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "dd-mm-yy";
    in = "This is 25th day of December, 1995";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc5: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "mmddyy";
    in = "Dec. 25th, 1995";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc6: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "mmm. dd. yyyy";
    in = "dec 25th 1995";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc7: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "mmm. dd. yyyy";
    in = "DEC-25-1995";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc8: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "mm yy   dd.";
    in = "12199525";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc9: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "yyyy fierj mm   dd.";
    in = "19951225";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc10: %s\n", text);
    free(text);
 
-   date1 = 0; text = "";
+   date1 = 0;
+   text = "";
+
    fmt = "mm/dd/yy";
    in = "122595";
    PGTYPESdate_defmt_asc(&date1, fmt, in);
    text = PGTYPESdate_to_asc(date1);
+
    printf("date_defmt_asc12: %s\n", text);
    free(text);
 
    PGTYPEStimestamp_current(&ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    /* can't output this in regression mode */
    /* printf("timestamp_current: Now: %s\n", text); */
    free(text);
 
    ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_to_asc1: %s\n", text);
    free(text);
 
    ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_to_asc2: %s\n", text);
    free(text);
 
    ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_to_asc3: %s\n", text);
    free(text);
 
 /* abc-03:10:35-def-02/11/94-gh  */
-/*      12345678901234567890123456789 */
+/*     12345678901234567890123456789 */
 
-   out = (char*) malloc(32);
+   out = (char *) malloc(32);
    i = PGTYPEStimestamp_fmt_asc(&ts1, out, 31, "abc-%X-def-%x-ghi%%");
    printf("timestamp_fmt_asc: %d: %s\n", i, out);
    free(out);
 
    fmt = "This is a %m/%d/%y %H-%Ml%Stest";
-   in =  "This is a 4/12/80 3-39l12test";
+   in = "This is a 4/12/80 3-39l12test";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%a %b %d %H:%M:%S %z %Y";
-   in =  "Tue Jul 22 17:28:44 +0200 2003";
+   in = "Tue Jul 22 17:28:44 +0200 2003";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%a %b %d %H:%M:%S %z %Y";
-   in =  "Tue Feb 29 17:28:44 +0200 2000";
+   in = "Tue Feb 29 17:28:44 +0200 2000";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%a %b %d %H:%M:%S %z %Y";
-   in =  "Tue Feb 29 17:28:44 +0200 1900";
+   in = "Tue Feb 29 17:28:44 +0200 1900";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%a %b %d %H:%M:%S %z %Y";
-   in =  "Tue Feb 29 17:28:44 +0200 1996";
+   in = "Tue Feb 29 17:28:44 +0200 1996";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%b %d %H:%M:%S %z %Y";
-   in =  "      Jul 31 17:28:44 +0200 1996";
+   in = "      Jul 31 17:28:44 +0200 1996";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%b %d %H:%M:%S %z %Y";
-   in =  "      Jul 32 17:28:44 +0200 1996";
+   in = "      Jul 32 17:28:44 +0200 1996";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%a %b %d %H:%M:%S %z %Y";
-   in =  "Tue Feb 29 17:28:44 +0200 1997";
+   in = "Tue Feb 29 17:28:44 +0200 1997";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%";
-   in =  "Tue Jul 22 17:28:44 +0200 2003";
+   in = "Tue Jul 22 17:28:44 +0200 2003";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "a %";
-   in =  "Tue Jul 22 17:28:44 +0200 2003";
+   in = "Tue Jul 22 17:28:44 +0200 2003";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%b, %d %H_%M`%S %z %Y";
-   in =  "    Jul, 22 17_28 `44 +0200  2003  ";
+   in = "    Jul, 22 17_28 `44 +0200  2003  ";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%a %b %%%d %H:%M:%S %Z %Y";
-   in =  "Tue Jul %22 17:28:44 CEST 2003";
+   in = "Tue Jul %22 17:28:44 CEST 2003";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "%a %b %%%d %H:%M:%S %Z %Y";
-   in =  "Tue Jul %22 17:28:44 CEST 2003";
+   in = "Tue Jul %22 17:28:44 CEST 2003";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
-   in =  "abc\n   19 October %22 17:28:44 CEST 2003";
+   in = "abc\n   19 October %22 17:28:44 CEST 2003";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
-   in =  "abc\n   18 October %34 17:28:44 CEST 80";
+   in = "abc\n   18 October %34 17:28:44 CEST 80";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
    free(text);
 
    fmt = "";
-   in =  "abc\n   18 October %34 17:28:44 CEST 80";
+   in = "abc\n   18 October %34 17:28:44 CEST 80";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
    free(text);
 
    fmt = NULL;
-   in =  "1980-04-12 3:49:44      ";
+   in = "1980-04-12 3:49:44      ";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, NULL) = %s, error: %d\n", in, text, i);
    free(text);
 
    fmt = "%B %d, %Y. Time: %I:%M%p";
-   in =  "July 14, 1988. Time: 9:15am";
+   in = "July 14, 1988. Time: 9:15am";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
@@ -392,6 +472,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    fmt = "%B %d at %I:%M %p in the year %Y";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
@@ -399,6 +480,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    fmt = "%Y,   %B %d. Time: %I:%M %p";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
@@ -406,6 +488,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    fmt = "%Y,   %B %d. Time: %I:%M%p";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
@@ -413,22 +496,28 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    fmt = "%Y, %P  %B %d. Time: %I:%M";
    i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
    text = PGTYPEStimestamp_to_asc(ts1);
+
    printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
    free(text);
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 350 "dt_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 350 "dt_test.pgc"
 
-        { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 351 "dt_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 351 "dt_test.pgc"
 
 
    return (0);
 }
-
index e5388b6fa8da5cc4044dced3978f9e0b47c2da42..72b1199dd8ecb87f7261e998af796cbcc42e1640 100644 (file)
 #line 8 "dt_test2.pgc"
 
 
-char *dates[] = { "19990108foobar",
-                 "19990108 foobar",
-                 "1999-01-08 foobar",
-                 "January 8, 1999",
-                 "1999-01-08",
-                 "1/8/1999",
-                 "1/18/1999",
-                 "01/02/03",
-                 "1999-Jan-08",
-                 "Jan-08-1999",
-                 "08-Jan-1999",
-                 "99-Jan-08",
-                 "08-Jan-99",
-                 "08-Jan-06",
-                 "Jan-08-99",
-                 "19990108",
-                 "990108",
-                 "1999.008",
-                 "J2451187",
-                 "January 8, 99 BC",
-                 NULL };
-
-char *times[] = { "0:04",
-                 "1:59 PDT",
-                 "13:24:40 -8:00",
-                 "13:24:40.495+3",
-                 NULL };
-
-char *intervals[] = { "1 minute",
-                     "1 12:59:10",
-                     "2 day 12 hour 59 minute 10 second",
-                     "1 days 12 hrs 59 mins 10 secs",
-                     "1 days 1 hours 1 minutes 1 seconds",
-                     "1 year 59 mins",
-                     "1 year 59 mins foobar",
-                     NULL };
+char      *dates[] = {"19990108foobar",
+   "19990108 foobar",
+   "1999-01-08 foobar",
+   "January 8, 1999",
+   "1999-01-08",
+   "1/8/1999",
+   "1/18/1999",
+   "01/02/03",
+   "1999-Jan-08",
+   "Jan-08-1999",
+   "08-Jan-1999",
+   "99-Jan-08",
+   "08-Jan-99",
+   "08-Jan-06",
+   "Jan-08-99",
+   "19990108",
+   "990108",
+   "1999.008",
+   "J2451187",
+   "January 8, 99 BC",
+NULL};
+
+char      *times[] = {"0:04",
+   "1:59 PDT",
+   "13:24:40 -8:00",
+   "13:24:40.495+3",
+NULL};
+
+char      *intervals[] = {"1 minute",
+   "1 12:59:10",
+   "2 day 12 hour 59 minute 10 second",
+   "1 days 12 hrs 59 mins 10 secs",
+   "1 days 1 hours 1 minutes 1 seconds",
+   "1 year 59 mins",
+   "1 year 59 mins foobar",
+NULL};
 
 int
 main(void)
 {
    /* exec sql begin declare section */
-        
-         
-        
-        
-        
-   
+
+
+
+
+
+
 #line 51 "dt_test2.pgc"
date  date1    ;
  date        date1;
+
 #line 52 "dt_test2.pgc"
- timestamp  ts1    ,  ts2    ;
+   timestamp   ts1,
+               ts2;
+
 #line 53 "dt_test2.pgc"
char * text    ;
  char       *text;
+
 #line 54 "dt_test2.pgc"
interval * i1    ;
  interval   *i1;
+
 #line 55 "dt_test2.pgc"
- date * dc    ;
+   date       *dc;
+
 /* exec sql end declare section */
 #line 56 "dt_test2.pgc"
 
 
-   int i, j;
-   char *endptr;
+   int         i,
+               j;
+   char       *endptr;
 
    ECPGdebug(1, stderr);
 
@@ -105,38 +108,45 @@ main(void)
    dc = PGTYPESdate_new();
    *dc = date1;
    text = PGTYPESdate_to_asc(*dc);
+
    printf("Date of timestamp: %s\n", text);
    free(text);
    PGTYPESdate_free(dc);
 
    for (i = 0; dates[i]; i++)
    {
-       bool err = false;
+       bool        err = false;
+
        date1 = PGTYPESdate_from_asc(dates[i], &endptr);
-       if (date1 == INT_MIN) {
+       if (date1 == INT_MIN)
+       {
            err = true;
        }
        text = PGTYPESdate_to_asc(date1);
+
        printf("Date[%d]: %s (%c - %c)\n",
-                   i, err ? "-" : text,
-                   endptr ? 'N' : 'Y',
-                   err ? 'T' : 'F');
+              i, err ? "-" : text,
+              endptr ? 'N' : 'Y',
+              err ? 'T' : 'F');
        free(text);
        if (!err)
        {
            for (j = 0; times[j]; j++)
            {
-               int length = strlen(dates[i])
-                       + 1
-                       + strlen(times[j])
-                       + 1;
-               char* t = malloc(length);
+               int         length = strlen(dates[i])
+               + 1
+               + strlen(times[j])
+               + 1;
+               char       *t = malloc(length);
+
                sprintf(t, "%s %s", dates[i], times[j]);
                ts1 = PGTYPEStimestamp_from_asc(t, NULL);
                text = PGTYPEStimestamp_to_asc(ts1);
-               if (i != 19 || j != 3) /* timestamp as integer or double differ for this case */
+
+               if (i != 19 || j != 3)  /* timestamp as integer or double
+                                        * differ for this case */
                    printf("TS[%d,%d]: %s\n",
-                       i, j, errno ? "-" : text);
+                          i, j, errno ? "-" : text);
                free(text);
            }
        }
@@ -146,7 +156,8 @@ main(void)
 
    for (i = 0; intervals[i]; i++)
    {
-       interval *ic;
+       interval   *ic;
+
        i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
        if (*endptr)
            printf("endptr set to %s\n", endptr);
@@ -159,12 +170,14 @@ main(void)
        if (j < 0)
            continue;
        text = PGTYPESinterval_to_asc(i1);
+
        printf("interval[%d]: %s\n", i, text ? text : "-");
        free(text);
 
        ic = PGTYPESinterval_new();
        PGTYPESinterval_copy(i1, ic);
        text = PGTYPESinterval_to_asc(i1);
+
        printf("interval_copy[%d]: %s\n", i, text ? text : "-");
        free(text);
        PGTYPESinterval_free(ic);
@@ -172,4 +185,3 @@ main(void)
 
    return (0);
 }
-
index e45abe636888fc4cb3128ae4ce60a2a720ff9d77..903b8247042590a0161c75104ee22c36f951da12 100644 (file)
@@ -34,49 +34,64 @@ NOTE: This file has a different expect file for regression tests on MinGW32
 int
 main(void)
 {
-   char *text="error\n";
-   numeric *value1, *value2, *res;
+   char       *text = "error\n";
+   numeric    *value1,
+              *value2,
+              *res;
+
    /* exec sql begin declare section */
-        
-       /* = {0, 0, 0, 0, 0, NULL, NULL} ; */
-   
+
+   /* = {0, 0, 0, 0, 0, NULL, NULL} ; */
+
 #line 22 "num_test.pgc"
- numeric * des    ;
+   numeric    *des;
+
 /* exec sql end declare section */
 #line 24 "num_test.pgc"
 
-   double d;
-   long l1, l2;
-   int i;
+   double      d;
+   long        l1,
+               l2;
+   int         i;
 
    ECPGdebug(1, stderr);
    /* exec sql whenever sqlerror  do sqlprint (  ) ; */
 #line 30 "num_test.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 32 "num_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "num_test.pgc"
 
 
-   { ECPGsetcommit(__LINE__, "off", NULL);
+   {
+       ECPGsetcommit(__LINE__, "off", NULL);
 #line 34 "num_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 34 "num_test.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( text char  ( 5 )    , num numeric ( 14 , 7 )   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( text char  ( 5 )    , num numeric ( 14 , 7 )   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 35 "num_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 35 "num_test.pgc"
 
 
    value1 = PGTYPESnumeric_new();
    PGTYPESnumeric_from_int(1407, value1);
    text = PGTYPESnumeric_to_asc(value1, -1);
+
    printf("from int = %s\n", text);
    free(text);
    PGTYPESnumeric_free(value1);
@@ -86,23 +101,28 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    res = PGTYPESnumeric_new();
    PGTYPESnumeric_add(value1, value2, res);
    text = PGTYPESnumeric_to_asc(res, -1);
+
    printf("add = %s\n", text);
    free(text);
 
    PGTYPESnumeric_sub(res, value2, res);
    text = PGTYPESnumeric_to_asc(res, -1);
+
    printf("sub = %s\n", text);
    free(text);
    PGTYPESnumeric_free(value2);
 
    des = PGTYPESnumeric_new();
    PGTYPESnumeric_copy(res, des);
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( text  , num  ) values( 'test' ,  ? ) ", 
-   ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( text  , num  ) values( 'test' ,  ? ) ",
+              ECPGt_numeric, &(des), (long) 1, (long) 0, sizeof(numeric),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 60 "num_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 60 "num_test.pgc"
 
 
@@ -110,17 +130,21 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    PGTYPESnumeric_mul(value1, value2, res);
    PGTYPESnumeric_free(value2);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  num  from test where text = 'test'  ", ECPGt_EOIT, 
-   ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  num  from test where text = 'test'  ", ECPGt_EOIT,
+              ECPGt_numeric, &(des), (long) 1, (long) 0, sizeof(numeric),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 66 "num_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 66 "num_test.pgc"
 
 
    PGTYPESnumeric_mul(res, des, res);
    text = PGTYPESnumeric_to_asc(res, -1);
+
    printf("mul = %s\n", text);
    free(text);
    PGTYPESnumeric_free(des);
@@ -128,6 +152,7 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    value2 = PGTYPESnumeric_from_asc("10000", NULL);
    PGTYPESnumeric_div(res, value2, res);
    text = PGTYPESnumeric_to_asc(res, -1);
+
    PGTYPESnumeric_to_double(res, &d);
    printf("div = %s %e\n", text, d);
 
@@ -141,19 +166,24 @@ if (sqlca.sqlcode < 0) sqlprint (  );}
    PGTYPESnumeric_free(value2);
    PGTYPESnumeric_free(res);
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 90 "num_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 90 "num_test.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 91 "num_test.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 91 "num_test.pgc"
 
 
    return (0);
 }
-
index 9db09e718892e38e797699445685ac32a234cce4..41d2511c40f23bf0561b85a1d5a58d331dfdde0a 100644 (file)
@@ -32,112 +32,149 @@ NOTE: This file has a different expect file for regression tests on MinGW32
 */
 
 
-char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
-                "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4",
-                ".500001", "-.5000001",
-                "1234567890123456789012345678.91", /* 30 digits should fit
-                                                      into decimal */
-                "1234567890123456789012345678.921", /* 31 digits should NOT
-                                                       fit into decimal */
-                "not a number",
-                NULL};
+char      *nums[] = {"2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
+   "2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4",
+   ".500001", "-.5000001",
+   "1234567890123456789012345678.91",  /* 30 digits should fit into decimal */
+   "1234567890123456789012345678.921", /* 31 digits should NOT fit into
+                                        * decimal */
+   "not a number",
+NULL};
 
 
 static void
-check_errno(void);
+           check_errno(void);
 
 int
 main(void)
 {
-   char *text="error\n";
-   char *endptr;
-   numeric *num, *nin;
-   decimal *dec;
-   long l;
-   int i, j, k, q, r, count = 0;
-   double d;
-   numeric **numarr = (numeric **) calloc(1, sizeof(numeric));
+   char       *text = "error\n";
+   char       *endptr;
+   numeric    *num,
+              *nin;
+   decimal    *dec;
+   long        l;
+   int         i,
+               j,
+               k,
+               q,
+               r,
+               count = 0;
+   double      d;
+   numeric   **numarr = (numeric **) calloc(1, sizeof(numeric));
 
    ECPGdebug(1, stderr);
 
    for (i = 0; nums[i]; i++)
    {
        num = PGTYPESnumeric_from_asc(nums[i], &endptr);
-       if (!num) check_errno();
+       if (!num)
+           check_errno();
        if (endptr != NULL)
        {
            printf("endptr of %d is not NULL\n", i);
            if (*endptr != '\0')
                printf("*endptr of %d is not \\0\n", i);
        }
-       if (!num) continue;
+       if (!num)
+           continue;
 
        numarr = realloc(numarr, sizeof(numeric *) * (count + 1));
        numarr[count++] = num;
 
        text = PGTYPESnumeric_to_asc(num, -1);
-       if (!text) check_errno();
-       printf("num[%d,1]: %s\n", i, text); free(text);
+
+       if (!text)
+           check_errno();
+       printf("num[%d,1]: %s\n", i, text);
+       free(text);
        text = PGTYPESnumeric_to_asc(num, 0);
-       if (!text) check_errno();
-       printf("num[%d,2]: %s\n", i, text); free(text);
+
+       if (!text)
+           check_errno();
+       printf("num[%d,2]: %s\n", i, text);
+       free(text);
        text = PGTYPESnumeric_to_asc(num, 1);
-       if (!text) check_errno();
-       printf("num[%d,3]: %s\n", i, text); free(text);
+
+       if (!text)
+           check_errno();
+       printf("num[%d,3]: %s\n", i, text);
+       free(text);
        text = PGTYPESnumeric_to_asc(num, 2);
-       if (!text) check_errno();
-       printf("num[%d,4]: %s\n", i, text); free(text);
+
+       if (!text)
+           check_errno();
+       printf("num[%d,4]: %s\n", i, text);
+       free(text);
 
        nin = PGTYPESnumeric_new();
        text = PGTYPESnumeric_to_asc(nin, 2);
-       if (!text) check_errno();
-       printf("num[%d,5]: %s\n", i, text); free(text);
+
+       if (!text)
+           check_errno();
+       printf("num[%d,5]: %s\n", i, text);
+       free(text);
 
        r = PGTYPESnumeric_to_long(num, &l);
-       if (r) check_errno();
-       printf("num[%d,6]: %ld (r: %d)\n", i, r?0L:l, r);
+       if (r)
+           check_errno();
+       printf("num[%d,6]: %ld (r: %d)\n", i, r ? 0L : l, r);
        if (r == 0)
        {
            r = PGTYPESnumeric_from_long(l, nin);
-           if (r) check_errno();
+           if (r)
+               check_errno();
            text = PGTYPESnumeric_to_asc(nin, 2);
+
            q = PGTYPESnumeric_cmp(num, nin);
            printf("num[%d,7]: %s (r: %d - cmp: %d)\n", i, text, r, q);
            free(text);
        }
 
        r = PGTYPESnumeric_to_int(num, &k);
-       if (r) check_errno();
-       printf("num[%d,8]: %d (r: %d)\n", i, r?0:k, r);
+       if (r)
+           check_errno();
+       printf("num[%d,8]: %d (r: %d)\n", i, r ? 0 : k, r);
        if (r == 0)
        {
            r = PGTYPESnumeric_from_int(k, nin);
-           if (r) check_errno();
+           if (r)
+               check_errno();
            text = PGTYPESnumeric_to_asc(nin, 2);
+
            q = PGTYPESnumeric_cmp(num, nin);
            printf("num[%d,9]: %s (r: %d - cmp: %d)\n", i, text, r, q);
            free(text);
        }
 
        r = PGTYPESnumeric_to_double(num, &d);
-       if (r) check_errno();
-       printf("num[%d,10]: %g (r: %d)\n", i, r?0.0:d, r);
-       /* do not test double to numeric because
-        * - extra digits are different on different architectures
-        * - PGTYPESnumeric_from_double internally calls PGTYPESnumeric_from_asc anyway
+       if (r)
+           check_errno();
+       printf("num[%d,10]: %g (r: %d)\n", i, r ? 0.0 : d, r);
+
+       /*
+        * do not test double to numeric because - extra digits are different
+        * on different architectures - PGTYPESnumeric_from_double internally
+        * calls PGTYPESnumeric_from_asc anyway
         */
 
        dec = PGTYPESdecimal_new();
        r = PGTYPESnumeric_to_decimal(num, dec);
-       if (r) check_errno();
-       /* we have no special routine for outputting decimal, it would
-        * convert to a numeric anyway */
+       if (r)
+           check_errno();
+
+       /*
+        * we have no special routine for outputting decimal, it would convert
+        * to a numeric anyway
+        */
        printf("num[%d,11]: - (r: %d)\n", i, r);
        if (r == 0)
        {
            r = PGTYPESnumeric_from_decimal(dec, nin);
-           if (r) check_errno();
+           if (r)
+               check_errno();
            text = PGTYPESnumeric_to_asc(nin, 2);
+
            q = PGTYPESnumeric_cmp(num, nin);
            printf("num[%d,12]: %s (r: %d - cmp: %d)\n", i, text, r, q);
            free(text);
@@ -152,10 +189,11 @@ main(void)
    {
        for (j = 0; j < count; j++)
        {
-           numeric* a = PGTYPESnumeric_new();
-           numeric* s = PGTYPESnumeric_new();
-           numeric* m = PGTYPESnumeric_new();
-           numeric* d = PGTYPESnumeric_new();
+           numeric    *a = PGTYPESnumeric_new();
+           numeric    *s = PGTYPESnumeric_new();
+           numeric    *m = PGTYPESnumeric_new();
+           numeric    *d = PGTYPESnumeric_new();
+
            r = PGTYPESnumeric_add(numarr[i], numarr[j], a);
            if (r)
            {
@@ -165,6 +203,7 @@ main(void)
            else
            {
                text = PGTYPESnumeric_to_asc(a, 10);
+
                printf("num[a,%d,%d]: %s\n", i, j, text);
                free(text);
            }
@@ -177,6 +216,7 @@ main(void)
            else
            {
                text = PGTYPESnumeric_to_asc(s, 10);
+
                printf("num[s,%d,%d]: %s\n", i, j, text);
                free(text);
            }
@@ -189,6 +229,7 @@ main(void)
            else
            {
                text = PGTYPESnumeric_to_asc(m, 10);
+
                printf("num[m,%d,%d]: %s\n", i, j, text);
                free(text);
            }
@@ -201,6 +242,7 @@ main(void)
            else
            {
                text = PGTYPESnumeric_to_asc(d, 10);
+
                printf("num[d,%d,%d]: %s\n", i, j, text);
                free(text);
            }
@@ -210,6 +252,7 @@ main(void)
    for (i = 0; i < count; i++)
    {
        text = PGTYPESnumeric_to_asc(numarr[i], -1);
+
        printf("%d: %s\n", i, text);
        free(text);
    }
@@ -220,7 +263,7 @@ main(void)
 static void
 check_errno(void)
 {
-   switch(errno)
+   switch (errno)
    {
        case 0:
            printf("(no errno set) - ");
index 23e81708eeefa0a069a4429729bd11bea6c4ce4d..3297ede6b6e6faf189656d6c0ad5b2c3e8b23ca3 100644 (file)
 #line 3 "comment.pgc"
 
 
-/* just a test comment */ int i;
-/* just a test comment int j*/;
+ /* just a test comment */ int i;
+
+ /* just a test comment int j*/ ;
 
 /****************************************************************************/
-/* Test comment                                                             */
+/* Test comment                                                                */
 /*--------------------------------------------------------------------------*/
 
-int main(void)
+int
+main(void)
 {
-  ECPGdebug(1, stderr);
+   ECPGdebug(1, stderr);
 
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 17 "comment.pgc"
 
 
-  { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 19 "comment.pgc"
 
-  exit (0);
+   exit(0);
 }
-
index 4c4caa7295c28bb4acbac92fc1e0635345e3f729..9978fead817cefb0c6909733caeae6ff65637839 100644 (file)
 
 
 
-/* exec sql type intarray is int [ 6 ]   */
+/* exec sql type intarray is int [ 6 ]  */
 #line 13 "define.pgc"
 
-typedef int intarray[ 6];
+typedef int intarray[6];
 
 int
 main(void)
 {
 /* exec sql begin declare section */
 
-      typedef char  string [ 8 ] ;
+   typedef char string[8];
 
 #line 21 "define.pgc"
 
-    
-      
-        
+
+
+
+
 #line 22 "define.pgc"
intarray  amount    ;
  intarray    amount;
+
 #line 23 "define.pgc"
char  name [ 6 ] [ 8 ]    ;
  char        name[6][8];
+
 #line 24 "define.pgc"
char  letter [ 6 ] [ 1 ]    ;
  char        letter[6][1];
+
 #if 0
+
 #line 26 "define.pgc"
- int  not_used    ;
+   int         not_used;
 #endif
 /* exec sql end declare section */
 #line 29 "define.pgc"
 
-   int i,j;
+   int         i,
+               j;
 
    ECPGdebug(1, stderr);
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 34 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 34 "define.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( name char  ( 8 )    , amount int   , letter char  ( 1 )    )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( name char  ( 8 )    , amount int   , letter char  ( 1 )    )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 36 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "define.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 37 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "define.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into Test ( name  , amount  , letter  ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into Test ( name  , amount  , letter  ) values ( 'false' , 1 , 'f' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 39 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "define.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( name  , amount  , letter  ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( name  , amount  , letter  ) values ( 'true' , 2 , 't' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 40 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 40 "define.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 41 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 41 "define.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test   ", ECPGt_EOIT, 
-   ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,(amount),(long)1,(long)6,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test   ", ECPGt_EOIT,
+              ECPGt_char, (name), (long) 8, (long) 6, (8) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, (amount), (long) 1, (long) 6, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (letter), (long) 1, (long) 6, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 43 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 43 "define.pgc"
 
 
-   for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
+   for (i = 0, j = sqlca.sqlerrd[2]; i < j; i++)
    {
        /* exec sql begin declare section */
-           
-          
-       
+
+
+
 #line 48 "define.pgc"
- char  n [ 8 ]    ,  l   = letter [ i ] [ 0 ] ;
+       char        n[8],
+                   l = letter[i][0];
+
 #line 49 "define.pgc"
- int  a   = amount [ i ] ;
+       int         a = amount[i];
+
 /* exec sql end declare section */
 #line 50 "define.pgc"
 
 
-       strncpy(n, name[i],  8);
+       strncpy(n, name[i], 8);
        printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
    }
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
 #line 56 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 56 "define.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 57 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 57 "define.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 58 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 58 "define.pgc"
 
 
index 0d085b140dd3cc7ae7728c630e0f30545630b0f4..f5e8e9e19a1fd8d824fda901db823b68f441c3b5 100644 (file)
@@ -73,16 +73,22 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 1 "init.pgc"
 
 
-enum e { ENUM0, ENUM1 };
-struct sa { int member; };
+enum e
+{
+   ENUM0, ENUM1
+};
+struct sa
+{
+   int         member;
+};
 
-static int fa(void)
+static int
+fa(void)
 {
    printf("in fa\n");
    return 2;
@@ -102,19 +108,22 @@ fc(const char *x)
    return *x;
 }
 
-static int fd(const char *x,int i)
+static int
+fd(const char *x, int i)
 {
    printf("in fd (%s, %d)\n", x, i);
-   return (*x)*i;
+   return (*x) * i;
 }
 
-static int fe(enum e x)
+static int
+fe(enum e x)
 {
    printf("in fe (%d)\n", (int) x);
-   return (int)x;
+   return (int) x;
 }
 
-static void sqlnotice(char *notice, short trans)
+static void
+sqlnotice(char *notice, short trans)
 {
    if (!notice)
        notice = "-empty-";
@@ -126,76 +135,79 @@ static void sqlnotice(char *notice, short trans)
 #define YES 1
 
 #ifdef _cplusplus
-namespace N
+namespace  N
 {
-   static const int i=2;
+   static const int i = 2;
 };
 #endif
 
-int main(void)
+int
+main(void)
 {
-   struct sa x = { 14 },*y = &x;
+   struct sa   x = {14}, *y = &x;
+
    /* exec sql begin declare section */
-        
-        
-        
-        
-        
-        
-        
-
-        
-        
-         
-         /* = 1L */ 
-   
+
+
+
+
+
+
+
+
+
+
+
+   /* = 1L */
+
 #line 60 "init.pgc"
int  a   = ( int ) 2 ;
  int         a = (int) 2;
+
 #line 61 "init.pgc"
int  b   = 2 + 2 ;
  int         b = 2 + 2;
+
 #line 62 "init.pgc"
int  b2   = ( 14 * 7 ) ;
  int         b2 = (14 * 7);
+
 #line 63 "init.pgc"
int  d   = x . member ;
  int         d = x.member;
+
 #line 64 "init.pgc"
int  g   = fb ( 2 ) ;
  int         g = fb(2);
+
 #line 65 "init.pgc"
int  i   = 3 ^ 1 ;
  int         i = 3 ^ 1;
+
 #line 66 "init.pgc"
int  j   = 1 ? 1 : 2 ;
  int         j = 1 ? 1 : 2;
+
 #line 68 "init.pgc"
int  e   = y -> member ;
  int         e = y->member;
+
 #line 69 "init.pgc"
int  c   = 10 >> 2 ;
  int         c = 10 >> 2;
+
 #line 70 "init.pgc"
bool  h   = 2 || 1 ;
  bool        h = 2 || 1;
+
 #line 71 "init.pgc"
- long  iay    ;
+   long        iay;
+
 /* exec sql end declare section */
 #line 72 "init.pgc"
 
 
-   int f=fa();
+   int         f = fa();
 
 #ifdef _cplusplus
    /* exec sql begin declare section */
-     /* compile error */
-   
+   /* compile error */
+
 #line 78 "init.pgc"
- int  k   = N : : i ;
+   int         k = N::i;
+
 /* exec sql end declare section */
 #line 79 "init.pgc"
-
 #endif
 
    ECPGdebug(1, stderr);
@@ -203,58 +215,76 @@ int main(void)
    printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j);
    iay = 0;
    printf("%ld\n", iay);
-   /* exec sql whenever sqlerror  do fa (  ) ; */
+   /* exec sql whenever sqlerror  do fa (  ) ; */
 #line 87 "init.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
 #line 88 "init.pgc"
 
-if (sqlca.sqlcode < 0) fa (  );}
+       if (sqlca.sqlcode < 0)
+           fa();
+   }
 #line 88 "init.pgc"
 
    /* exec sql whenever sqlerror  do fb ( 20 ) ; */
 #line 89 "init.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
 #line 90 "init.pgc"
 
-if (sqlca.sqlcode < 0) fb ( 20 );}
+       if (sqlca.sqlcode < 0)
+           fb(20);
+   }
 #line 90 "init.pgc"
 
    /* exec sql whenever sqlerror  do fc ( \"50\" ) ; */
 #line 91 "init.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
 #line 92 "init.pgc"
 
-if (sqlca.sqlcode < 0) fc ( "50" );}
+       if (sqlca.sqlcode < 0)
+           fc("50");
+   }
 #line 92 "init.pgc"
 
    /* exec sql whenever sqlerror  do fd ( \"50\" , 1 ) ; */
 #line 93 "init.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
 #line 94 "init.pgc"
 
-if (sqlca.sqlcode < 0) fd ( "50" , 1 );}
+       if (sqlca.sqlcode < 0)
+           fd("50", 1);
+   }
 #line 94 "init.pgc"
 
    /* exec sql whenever sqlerror  do fe ( ENUM0 ) ; */
 #line 95 "init.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
 #line 96 "init.pgc"
 
-if (sqlca.sqlcode < 0) fe ( ENUM0 );}
+       if (sqlca.sqlcode < 0)
+           fe(ENUM0);
+   }
 #line 96 "init.pgc"
 
    /* exec sql whenever sqlerror  do sqlnotice ( NULL , 0 ) ; */
 #line 97 "init.pgc"
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  now ()     ", ECPGt_EOIT, ECPGt_EORT);
 #line 98 "init.pgc"
 
-if (sqlca.sqlcode < 0) sqlnotice ( NULL , 0 );}
+       if (sqlca.sqlcode < 0)
+           sqlnotice(NULL, 0);
+   }
 #line 98 "init.pgc"
 
    return 0;
index 20e937188c13125728c994a411dbf5493d2a2f9a..fc9334b8c145966b43efe3bed41b9e19ad4e3021 100644 (file)
 #line 4 "type.pgc"
 
 
-typedef long  mmInteger ;
+typedef long mmInteger;
 
 #line 6 "type.pgc"
 
 #line 6 "type.pgc"
 
-typedef char  mmChar ;
+typedef char mmChar;
 
 #line 7 "type.pgc"
 
 #line 7 "type.pgc"
 
-typedef short  mmSmallInt ;
+typedef short mmSmallInt;
 
 #line 8 "type.pgc"
 
 #line 8 "type.pgc"
 
 
-/* exec sql type string is char [ 11 ]   */
+/* exec sql type string is char [ 11 ]  */
 #line 10 "type.pgc"
 
 typedef char string[11];
 
-/* exec sql type c is char  reference */
+/* exec sql type c is char reference */
 #line 13 "type.pgc"
 
-typedef charc;
+typedef char *c;
 
 /* exec sql begin declare section */
 
-   
-   
-   
 
-struct TBempl { 
+
+
+
+
+struct TBempl
+{
 #line 19 "type.pgc"
mmInteger  idnum    ;
  mmInteger   idnum;
+
 #line 20 "type.pgc"
mmChar  name [ 21 ]    ;
  mmChar      name[21];
+
 #line 21 "type.pgc"
- mmSmallInt  accs    ;
- } ;/* exec sql end declare section */
+   mmSmallInt  accs;
+};                             /* exec sql end declare section */
+
 #line 23 "type.pgc"
 
 
 int
-main (void)
+main(void)
 {
-  /* exec sql begin declare section */
-    
-   
-     
-   
-  
-    
-    
-   
-  
+   /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+
 #line 29 "type.pgc"
struct TBempl  empl    ;
  struct TBempl empl;
+
 #line 30 "type.pgc"
string  str    ;
  string      str;
+
 #line 31 "type.pgc"
c  ptr   = NULL ;
  c           ptr = NULL;
+
 #line 36 "type.pgc"
- struct varchar_vc { 
+   struct varchar_vc
+   {
 #line 34 "type.pgc"
int  len    ;
      int         len;
+
 #line 35 "type.pgc"
- char  text [ 10 ]    ;
- }  vc    ;
+       char text   [10];
+   }           vc;
+
 /* exec sql end declare section */
 #line 37 "type.pgc"
 
 
-  /* exec sql var vc is  [ 10 ]   */
+   /* exec sql var vc is  [ 10 ]   */
 #line 39 "type.pgc"
 
-  ECPGdebug (1, stderr);
+   ECPGdebug(1, stderr);
 
-  empl.idnum = 1;
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   empl.idnum = 1;
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 43 "type.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("connect error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
+   if (sqlca.sqlcode)
+   {
+       printf("connect error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , string1 char  ( 10 )    , string2 char  ( 10 )    , string3 char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , string1 char  ( 10 )    , string2 char  ( 10 )    , string3 char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 51 "type.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("create error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
+   if (sqlca.sqlcode)
+   {
+       printf("create error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' ) ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 58 "type.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("insert error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
-
-  { ECPGdo(__LINE__, 0, 1, NULL, "select  idnum , name , accs , string1 , string2 , string3  from empl where idnum =  ?  ", 
-   ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-   ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar_vc), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   if (sqlca.sqlcode)
+   {
+       printf("insert error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  idnum , name , accs , string1 , string2 , string3  from empl where idnum =  ?  ",
+              ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT,
+              ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+         ECPGt_char, &(empl.name), (long) 21, (long) 1, (21) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_short, &(empl.accs), (long) 1, (long) 1, sizeof(short),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (str), (long) 11, (long) 1, (11) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, &(ptr), (long) 0, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+       ECPGt_varchar, &(vc), (long) 10, (long) 1, sizeof(struct varchar_vc),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 68 "type.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("select error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
-  printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);
+   if (sqlca.sqlcode)
+   {
+       printf("select error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
+   printf("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);
 
-  { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 76 "type.pgc"
 
 
-  free(ptr);
-  exit (0);
+   free(ptr);
+   exit(0);
 }
index 37819927477732a47244e939bee2c918f91618c7..83761b1f968487f6208fcf4c99685edea5f61674 100644 (file)
 #line 6 "variable.pgc"
 
 
-/* exec sql type c is char  reference */
+/* exec sql type c is char reference */
 #line 8 "variable.pgc"
 
-typedef charc;
+typedef char *c;
 
-/* exec sql type ind is union { 
+/* exec sql type ind is union {
 #line 11 "variable.pgc"
- int  integer    ;
+ int  integer   ;
+
 #line 11 "variable.pgc"
- short  smallint    ;
- }   */
+ short smallint    ;
+ }  */
 #line 11 "variable.pgc"
 
-typedef union { int integer; short smallint; } ind;
+typedef union
+{
+   int         integer;
+   short       smallint;
+}  ind;
 
 #define BUFFERSIZ 8
-/* exec sql type str is  [ BUFFERSIZ ]   */
+/* exec sql type str is  [ BUFFERSIZ ]  */
 #line 15 "variable.pgc"
 
 
-/* declare cur  cursor  for select  name , born , age , married , children  from family    */
+/* declare cur cursor  for select  name , born , age , married , children  from family    */
 #line 18 "variable.pgc"
 
 
 int
-main (void)
+main(void)
 {
-   struct birthinfo { 
+   struct birthinfo
+   {
 #line 23 "variable.pgc"
long  born    ;
      long        born;
+
 #line 23 "variable.pgc"
- short  age    ;
- } ;
+       short       age;
+   };
+
 #line 23 "variable.pgc"
 
 /* exec sql begin declare section */
-            
-                     
-                 
-        
-                     
-                   
-    
+
+
+
+
+
+
+
 
 #line 27 "variable.pgc"
- struct personal_struct { 
+   struct personal_struct
+   {
 #line 25 "variable.pgc"
-   struct varchar_name  { int len; char arr[ BUFFERSIZ ]; }  name    ;
+       struct varchar_name
+       {
+           int         len;
+           char        arr[BUFFERSIZ];
+       }           name;
+
 #line 26 "variable.pgc"
struct birthinfo  birth    ;
}  personal    , * p    ;
      struct birthinfo birth;
  }           personal, *p;
+
 #line 30 "variable.pgc"
- struct personal_indicator { 
+   struct personal_indicator
+   {
 #line 28 "variable.pgc"
int  ind_name    ;
      int         ind_name;
+
 #line 29 "variable.pgc"
struct birthinfo  ind_birth    ;
}  ind_personal    , * i    ;
      struct birthinfo ind_birth;
  }           ind_personal, *i;
+
 #line 31 "variable.pgc"
- ind  ind_children    ;
+   ind         ind_children;
+
 /* exec sql end declare section */
 #line 32 "variable.pgc"
 
 
-   
+
 #line 34 "variable.pgc"
char * married   = NULL ;
  char       *married = NULL;
 
 #line 34 "variable.pgc"
 
-   
+
 #line 35 "variable.pgc"
long  ind_married    ;
  long        ind_married;
 
 #line 35 "variable.pgc"
 
-   
+
 #line 36 "variable.pgc"
ind  children    ;
  ind         children;
 
 #line 36 "variable.pgc"
 
 
-   char msg[128];
+   char        msg[128];
 
-        ECPGdebug(1, stderr);
+   ECPGdebug(1, stderr);
 
    strcpy(msg, "connect");
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 43 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 43 "variable.pgc"
 
 
    strcpy(msg, "set");
-   { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
 #line 46 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 46 "variable.pgc"
 
 
    strcpy(msg, "create");
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table family ( name char  ( 8 )    , born integer   , age smallint   , married date   , children integer   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table family ( name char  ( 8 )    , born integer   , age smallint   , married date   , children integer   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 49 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 49 "variable.pgc"
 
 
    strcpy(msg, "insert");
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , married  , children  ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , married  , children  ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 52 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 52 "variable.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , born  , married  , children  ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , born  , married  , children  ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 53 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 53 "variable.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , age  ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , age  ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 54 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 54 "variable.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , age  ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , age  ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 55 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 55 "variable.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , age  ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name  , age  ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 56 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 56 "variable.pgc"
 
 
    strcpy(msg, "commit");
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 59 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 59 "variable.pgc"
 
 
    strcpy(msg, "open");
-   { ECPGdo(__LINE__, 0, 1, NULL, "declare cur  cursor  for select  name , born , age , married , children  from family   ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare cur  cursor  for select  name , born , age , married , children  from family   ", ECPGt_EOIT, ECPGt_EORT);
 #line 62 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 62 "variable.pgc"
 
 
-   /* exec sql whenever not found  break ; */
+   /* exec sql whenever not found  break ; */
 #line 64 "variable.pgc"
 
 
-   p=&personal;
-   i=&ind_personal;
+   p = &personal;
+   i = &ind_personal;
    memset(i, 0, sizeof(ind_personal));
-   while (1) {
+   while (1)
+   {
        strcpy(msg, "fetch");
-       { ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT, 
-   ECPGt_varchar,&(p->name),(long)BUFFERSIZ,(long)1,sizeof(struct varchar_name), 
-   ECPGt_int,&(i->ind_name),(long)1,(long)1,sizeof(int), 
-   ECPGt_long,&(p->birth.born),(long)1,(long)1,sizeof(long), 
-   ECPGt_long,&(i->ind_birth.born),(long)1,(long)1,sizeof(long), 
-   ECPGt_short,&(p->birth.age),(long)1,(long)1,sizeof(short), 
-   ECPGt_short,&(i->ind_birth.age),(long)1,(long)1,sizeof(short), 
-   ECPGt_char,&(married),(long)0,(long)1,(1)*sizeof(char), 
-   ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long), 
-   ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int), 
-   ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT);
+       {
+           ECPGdo(__LINE__, 0, 1, NULL, "fetch cur", ECPGt_EOIT,
+                  ECPGt_varchar, &(p->name), (long) BUFFERSIZ, (long) 1, sizeof(struct varchar_name),
+                  ECPGt_int, &(i->ind_name), (long) 1, (long) 1, sizeof(int),
+             ECPGt_long, &(p->birth.born), (long) 1, (long) 1, sizeof(long),
+                  ECPGt_long, &(i->ind_birth.born), (long) 1, (long) 1, sizeof(long),
+            ECPGt_short, &(p->birth.age), (long) 1, (long) 1, sizeof(short),
+                  ECPGt_short, &(i->ind_birth.age), (long) 1, (long) 1, sizeof(short),
+             ECPGt_char, &(married), (long) 0, (long) 1, (1) * sizeof(char),
+               ECPGt_long, &(ind_married), (long) 1, (long) 1, sizeof(long),
+            ECPGt_int, &(children.integer), (long) 1, (long) 1, sizeof(int),
+                  ECPGt_short, &(ind_children.smallint), (long) 1, (long) 1, sizeof(short), ECPGt_EORT);
 #line 71 "variable.pgc"
 
-if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+           if (sqlca.sqlcode == ECPG_NOT_FOUND)
+               break;
 #line 71 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+           if (sqlca.sqlcode < 0)
+               sqlprint();
+       }
 #line 71 "variable.pgc"
 
        printf("%8.8s", personal.name.arr);
@@ -234,34 +282,46 @@ if (sqlca.sqlcode < 0) sqlprint();}
    }
 
    strcpy(msg, "close");
-   { ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT);
 #line 88 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 88 "variable.pgc"
 
 
    strcpy(msg, "drop");
-   { ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT);
 #line 91 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 91 "variable.pgc"
 
 
    strcpy(msg, "commit");
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 94 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 94 "variable.pgc"
 
 
-   strcpy(msg, "disconnect"); 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   strcpy(msg, "disconnect");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 97 "variable.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 97 "variable.pgc"
 
 
index 79983ce2f3d7148e511bfaeed1f6257149a3fa09..270287624d8540dfc028c9242a5713cfdf6fac5b 100644 (file)
 #line 5 "whenever.pgc"
 
 
-static void print(char *msg)
+static void
+print(char *msg)
 {
-        fprintf(stderr, "Error in statement '%s':\n", msg);
-        sqlprint();
+   fprintf(stderr, "Error in statement '%s':\n", msg);
+   sqlprint();
 }
 
-static void print2(void)
+static void
+print2(void)
 {
-        fprintf(stderr, "Found another error\n");
-        sqlprint();
+   fprintf(stderr, "Found another error\n");
+   sqlprint();
 }
 
-static void warn(void)
+static void
+warn(void)
 {
-        fprintf(stderr, "Warning: At least one column was truncated\n");
+   fprintf(stderr, "Warning: At least one column was truncated\n");
 }
 
-int main(void)
+int
+main(void)
 {
-   
+
 #line 26 "whenever.pgc"
int  i    ;
  int         i;
 
 #line 26 "whenever.pgc"
 
-   
+
 #line 27 "whenever.pgc"
char  c [ 6 ]    ;
  char        c[6];
 
 #line 27 "whenever.pgc"
 
 
    ECPGdebug(1, stderr);
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 31 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 31 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( i int   , c char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( i int   , c char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 32 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values ( 1 , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values ( 1 , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 33 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 33 "whenever.pgc"
 
 
    /* exec sql whenever sql_warning  do warn (  ) ; */
 #line 35 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test   ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(c),(long)6,(long)1,(6)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test   ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (c), (long) 6, (long) 1, (6) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 36 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 36 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "whenever.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 37 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 37 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "whenever.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 39 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 39 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "whenever.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 40 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 40 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 40 "whenever.pgc"
 
 
    /* exec sql whenever sqlerror  do print ( \"select\" ) ; */
 #line 42 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 43 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 43 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) print ( "select" );}
+       if (sqlca.sqlcode < 0)
+           print("select");
+   }
 #line 43 "whenever.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 44 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 44 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) print ( "select" );}
+       if (sqlca.sqlcode < 0)
+           print("select");
+   }
 #line 44 "whenever.pgc"
 
 
    /* exec sql whenever sqlerror  call print2 (  ) ; */
 #line 46 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 47 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 47 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) print2 (  );}
+       if (sqlca.sqlcode < 0)
+           print2();
+   }
 #line 47 "whenever.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 48 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 48 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) print2 (  );}
+       if (sqlca.sqlcode < 0)
+           print2();
+   }
 #line 48 "whenever.pgc"
 
 
    /* exec sql whenever sqlerror  continue ; */
 #line 50 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 51 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );}
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
+   }
 #line 51 "whenever.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 52 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );}
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
+   }
 #line 52 "whenever.pgc"
 
 
    /* exec sql whenever sqlerror  goto  error ; */
 #line 54 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 55 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 55 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) goto error;}
+       if (sqlca.sqlcode < 0)
+           goto error;
+   }
 #line 55 "whenever.pgc"
 
    printf("Should not be reachable\n");
 
-   error:
-   { ECPGtrans(__LINE__, NULL, "rollback");
+error:
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 59 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 59 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) goto error;}
+       if (sqlca.sqlcode < 0)
+           goto error;
+   }
 #line 59 "whenever.pgc"
 
 
    /* exec sql whenever sqlerror  stop ; */
 #line 61 "whenever.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from nonexistant   ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 62 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 62 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) exit (1);}
+       if (sqlca.sqlcode < 0)
+           exit(1);
+   }
 #line 62 "whenever.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 63 "whenever.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') warn (  );
+       if (sqlca.sqlwarn[0] == 'W')
+           warn();
 #line 63 "whenever.pgc"
 
-if (sqlca.sqlcode < 0) exit (1);}
+       if (sqlca.sqlcode < 0)
+           exit(1);
+   }
 #line 63 "whenever.pgc"
 
-   exit (0);
-}  
+   exit(0);
+}
index 87ec88f985a74bc09c82a812f296f867a0da8aa7..8b7dec49e79a82fb927efd974560a79f6fe29bc5 100644 (file)
@@ -81,7 +81,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 7 "array.pgc"
@@ -98,33 +97,34 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 int
-main (void)
+main(void)
 {
 /* exec sql begin declare section */
-      
-      
-      
-      
-       
-    
+
+
+
+
+
+
 
 #line 14 "array.pgc"
int  i   = 1 ;
  int         i = 1;
+
 #line 15 "array.pgc"
int * did   = & i ;
  int        *did = &i;
+
 #line 16 "array.pgc"
int  a [ 10 ]   = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ;
  int         a[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+
 #line 17 "array.pgc"
char  text [ 25 ]   = "klmnopqrst" ;
  char text   [25] = "klmnopqrst";
+
 #line 18 "array.pgc"
char * t   = ( char * ) malloc ( 11 ) ;
  char       *t = (char *) malloc(11);
+
 #line 19 "array.pgc"
- double  f    ;
+   double      f;
+
 /* exec sql end declare section */
 #line 20 "array.pgc"
 
@@ -134,103 +134,136 @@ main (void)
 
    ECPGdebug(1, stderr);
 
-        { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 27 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 27 "array.pgc"
 
 
-   { ECPGsetcommit(__LINE__, "on", NULL);
+   {
+       ECPGsetcommit(__LINE__, "on", NULL);
 #line 29 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "array.pgc"
 
 
-   { ECPGtrans(__LINE__, NULL, "begin transaction ");
+   {
+       ECPGtrans(__LINE__, NULL, "begin transaction ");
 #line 31 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 31 "array.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( f float    , i int   , a int [ 10 ]   , text char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( f float    , i int   , a int [ 10 ]   , text char  ( 10 )    )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 33 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 33 "array.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 35 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 35 "array.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 140787.0 , 2 ,  ? ,  ? ) ", 
-   ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 140787.0 , 2 ,  ? ,  ? ) ",
+              ECPGt_int, (a), (long) 1, (long) 10, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (text), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 37 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "array.pgc"
 
-   
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 14.07 ,  ? ,  ? ,  ? ) ", 
-   ECPGt_int,&(did),(long)1,(long)0,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( f  , i  , a  , text  ) values ( 14.07 ,  ? ,  ? ,  ? ) ",
+              ECPGt_int, &(did), (long) 1, (long) 0, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, (a), (long) 1, (long) 10, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, &(t), (long) 0, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 39 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "array.pgc"
 
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 41 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 41 "array.pgc"
 
 
-   { ECPGtrans(__LINE__, NULL, "begin transaction ");
+   {
+       ECPGtrans(__LINE__, NULL, "begin transaction ");
 #line 43 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 43 "array.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  f , text  from test where i = 1  ", ECPGt_EOIT, 
-   ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  f , text  from test where i = 1  ", ECPGt_EOIT,
+              ECPGt_double, &(f), (long) 1, (long) 1, sizeof(double),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (text), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 48 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 48 "array.pgc"
 
 
    printf("Found f=%f text=%10.10s\n", f, text);
 
-   f=140787;
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  a , text  from test where f =  ?  ", 
-   ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-   ECPGt_int,(a),(long)1,(long)10,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   f = 140787;
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  a , text  from test where f =  ?  ",
+              ECPGt_double, &(f), (long) 1, (long) 1, sizeof(double),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT,
+              ECPGt_int, (a), (long) 1, (long) 10, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, &(t), (long) 0, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 56 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 56 "array.pgc"
 
 
@@ -239,37 +272,49 @@ if (sqlca.sqlcode < 0) sqlprint();}
 
    printf("Found text=%10.10s\n", t);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  a  from test where f =  ?  ", 
-   ECPGt_double,&(f),(long)1,(long)1,sizeof(double), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-   ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  a  from test where f =  ?  ",
+              ECPGt_double, &(f), (long) 1, (long) 1, sizeof(double),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT,
+              ECPGt_char, (text), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 66 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 66 "array.pgc"
 
 
    printf("Found text=%s\n", text);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
 #line 70 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 70 "array.pgc"
 
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 72 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 72 "array.pgc"
 
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 74 "array.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 74 "array.pgc"
 
 
index deb0220d44f6de1c0bfc20f1efd4f4cc6f255bf2..ae444253f7a3a902a21a14f400a3e1b28c4c1347 100644 (file)
 
 
 /* exec sql begin declare section */
 
-   
-   
-   
-   
 
-struct TBempl { 
+
+
+
+
+
+struct TBempl
+{
 #line 9 "binary.pgc"
long  idnum    ;
  long        idnum;
+
 #line 10 "binary.pgc"
char  name [ 21 ]    ;
  char        name[21];
+
 #line 11 "binary.pgc"
short  accs    ;
  short       accs;
+
 #line 12 "binary.pgc"
- char  byte [ 20 ]    ;
- } ;/* exec sql end declare section */
+   char        byte[20];
+};                             /* exec sql end declare section */
+
 #line 14 "binary.pgc"
 
 
 int
-main (void)
+main(void)
 {
-  /* exec sql begin declare section */
-    
-     
-  
+   /* exec sql begin declare section */
+
+
+
 #line 20 "binary.pgc"
struct TBempl  empl    ;
  struct TBempl empl;
+
 #line 21 "binary.pgc"
- char * data   = "\\001\\155\\000\\212" ;
+   char       *data = "\\001\\155\\000\\212";
+
 /* exec sql end declare section */
 #line 22 "binary.pgc"
 
-  int i;
+   int         i;
 
-  ECPGdebug (1, stderr);
+   ECPGdebug(1, stderr);
 
-  empl.idnum = 1;
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   empl.idnum = 1;
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 28 "binary.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("connect error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
+   if (sqlca.sqlcode)
+   {
+       printf("connect error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , byte bytea   )    ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , byte bytea   )    ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 36 "binary.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("create error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
-
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'first user' , 320 ,  ? ) ", 
-   ECPGt_char,&(data),(long)0,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
+   if (sqlca.sqlcode)
+   {
+       printf("create error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values ( 1 , 'first user' , 320 ,  ? ) ",
+              ECPGt_char, &(data), (long) 0, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 43 "binary.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("insert error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
+   if (sqlca.sqlcode)
+   {
+       printf("insert error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
 
-  /* declare C  cursor  for select  name , accs , byte  from empl where idnum =  ?   */
+   /*
+    * declare C  cursor  for select  name , accs , byte  from empl where
+    * idnum =  ?
+    */
 #line 50 "binary.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "declare C  cursor  for select  name , accs , byte  from empl where idnum =  ?  ", 
-   ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare C  cursor  for select  name , accs , byte  from empl where idnum =  ?  ",
+              ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 51 "binary.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "fetch C", ECPGt_EOIT, 
-   ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "fetch C", ECPGt_EOIT,
+          ECPGt_char, (empl.name), (long) 21, (long) 1, (21) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_short, &(empl.accs), (long) 1, (long) 1, sizeof(short),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+          ECPGt_char, (empl.byte), (long) 20, (long) 1, (20) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 52 "binary.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("fetch error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
+   if (sqlca.sqlcode)
+   {
+       printf("fetch error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
+
+   printf("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
 
-  printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
+   memset(empl.name, 0, 21L);
+   memset(empl.byte, '#', 20L);
 
-  memset(empl.name, 0, 21L);
-  memset(empl.byte, '#', 20L);
-  /* declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  ?   */
+   /*
+    * declare B  binary cursor  for select  name , accs , byte  from empl
+    * where idnum =  ?
+    */
 #line 63 "binary.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  ?  ", 
-   ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  ?  ",
+              ECPGt_long, &(empl.idnum), (long) 1, (long) 1, sizeof(long),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 64 "binary.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "fetch B", ECPGt_EOIT, 
-   ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "fetch B", ECPGt_EOIT,
+          ECPGt_char, (empl.name), (long) 21, (long) 1, (21) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_short, &(empl.accs), (long) 1, (long) 1, sizeof(short),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+          ECPGt_char, (empl.byte), (long) 20, (long) 1, (20) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 65 "binary.pgc"
 
-  if (sqlca.sqlcode)
-    {
-      printf ("fetch error = %ld\n", sqlca.sqlcode);
-      exit (sqlca.sqlcode);
-    }
+   if (sqlca.sqlcode)
+   {
+       printf("fetch error = %ld\n", sqlca.sqlcode);
+       exit(sqlca.sqlcode);
+   }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "close B", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close B", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 72 "binary.pgc"
 
 
-  /* do not print a.accs because big/little endian will have different outputs here */
-  printf ("name=%s, byte=", empl.name);
-  for (i=0; i<20; i++)
-  {
-   if (empl.byte[i] == '#')
-       break;
-   printf("(%o)", (unsigned char)empl.byte[i]);
-  }
-  printf("\n");
-  { ECPGdisconnect(__LINE__, "CURRENT");}
+   /*
+    * do not print a.accs because big/little endian will have different
+    * outputs here
+    */
+   printf("name=%s, byte=", empl.name);
+   for (i = 0; i < 20; i++)
+   {
+       if (empl.byte[i] == '#')
+           break;
+       printf("(%o)", (unsigned char) empl.byte[i]);
+   }
+   printf("\n");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 83 "binary.pgc"
 
-  exit (0);
+   exit(0);
 }
index 88bb07925a94c5b4511cb195819f44c03eeadccc..036672ff2306d5d0577f4ed24d3eff69ee313473 100644 (file)
@@ -73,7 +73,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 1 "code100.pgc"
@@ -92,73 +91,109 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-int main(int argc, char **argv)
-{  /* exec sql begin declare section */
-    
-   
+int
+main(int argc, char **argv)
+{                              /* exec sql begin declare section */
+
+
 #line 9 "code100.pgc"
- int  index    ;
+   int         index;
+
 /* exec sql end declare section */
 #line 10 "code100.pgc"
 
 
 
-   ECPGdebug(1,stderr);
-   
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   ECPGdebug(1, stderr);
+
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 15 "code100.pgc"
 
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
+   if (sqlca.sqlcode)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( \"index\" numeric ( 3 )   primary key   , \"payload\" int4   not null )    ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( \"index\" numeric ( 3 )   primary key   , \"payload\" int4   not null )    ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 20 "code100.pgc"
 
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   { ECPGtrans(__LINE__, NULL, "commit");}
+   if (sqlca.sqlcode)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 22 "code100.pgc"
 
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   
-   for (index=0;index<10;++index)
-   {  { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( payload  , index  ) values( 0 ,  ? ) ", 
-   ECPGt_int,&(index),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
+   if (sqlca.sqlcode)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+
+   for (index = 0; index < 10; ++index)
+   {
+       {
+           ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( payload  , index  ) values( 0 ,  ? ) ",
+                  ECPGt_int, &(index), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+       }
 #line 28 "code100.pgc"
 
-      if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   }
-   { ECPGtrans(__LINE__, NULL, "commit");}
+       if (sqlca.sqlcode)
+           printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+   }
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 31 "code100.pgc"
 
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   
-   { ECPGdo(__LINE__, 0, 1, NULL, "update test set payload  = payload + 1  where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);}
+   if (sqlca.sqlcode)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "update test set payload  = payload + 1  where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 35 "code100.pgc"
 
-   if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   
-   { ECPGdo(__LINE__, 0, 1, NULL, "delete from test  where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);}
+   if (sqlca.sqlcode != 100)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "delete from test  where index = - 1 ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 38 "code100.pgc"
 
-   if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
+   if (sqlca.sqlcode != 100)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( select  *  from test where index = - 1   ) ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( select  *  from test where index = - 1   ) ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 41 "code100.pgc"
 
-   if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
+   if (sqlca.sqlcode != 100)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 44 "code100.pgc"
 
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   { ECPGtrans(__LINE__, NULL, "commit");}
+   if (sqlca.sqlcode)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 46 "code100.pgc"
 
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   if (sqlca.sqlcode)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 49 "code100.pgc"
 
-   if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
-   return 0;
+   if (sqlca.sqlcode)
+       printf("%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+   return 0;
 }
index 8e14452872867d9f44d1650c94d7f6c93d3e6e38..83444f801b7ffee033525103c0824fda4bb255f0 100644 (file)
@@ -75,7 +75,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 3 "copystdout.pgc"
@@ -96,7 +95,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 int
-main ()
+main()
 {
 /*
   EXEC SQL BEGIN DECLARE SECTION;
@@ -104,57 +103,78 @@ main ()
   EXEC SQL END DECLARE SECTION;
 */
 
-  ECPGdebug (1, stderr);
+   ECPGdebug(1, stderr);
 
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 19 "copystdout.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 19 "copystdout.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table foo ( a int   , b varchar    )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table foo ( a int   , b varchar    )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 20 "copystdout.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 20 "copystdout.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 5 , 'abc' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 5 , 'abc' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 21 "copystdout.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 21 "copystdout.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 6 , 'def' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 6 , 'def' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 22 "copystdout.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 22 "copystdout.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 7 , 'ghi' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into foo values( 7 , 'ghi' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 23 "copystdout.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 23 "copystdout.pgc"
 
 
-  /* produces expected file "/tmp/foo" */
-  /* EXEC SQL COPY foo TO:fname WITH DELIMITER ','; */
-  /* printf ("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); */
+   /* produces expected file "/tmp/foo" */
+   /* EXEC SQL COPY foo TO:fname WITH DELIMITER ','; */
+   /* printf ("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); */
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "copy  foo  to stdout  with  delimiter  ','", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "copy  foo  to stdout  with  delimiter  ','", ECPGt_EOIT, ECPGt_EORT);
 #line 29 "copystdout.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "copystdout.pgc"
 
-  printf ("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);
+   printf("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode);
 
-  { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 32 "copystdout.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "copystdout.pgc"
 
 
-  return 0;
+   return 0;
 }
index 44cd13bedb3e949b8ad1a27c48d7e6dd2a842e74..ed8dfb568166032189ad6d008122058e62ed34a2 100644 (file)
@@ -73,7 +73,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 1 "define.pgc"
@@ -92,114 +91,143 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-int main(void)
+int
+main(void)
 {
-   /* exec sql begin declare section */
-      
-      
-   
+   /* exec sql begin declare section */
+
+
+
 #line 10 "define.pgc"
int  i    ;
  int         i;
+
 #line 11 "define.pgc"
- char  s [ 200 ]    ;
+   char        s[200];
+
 /* exec sql end declare section */
 #line 12 "define.pgc"
 
 
-   ECPGdebug(1, stderr);
+   ECPGdebug(1, stderr);
 
-   /* exec sql whenever sqlerror  do sqlprint (  ) ; */
+   /* exec sql whenever sqlerror  do sqlprint (  ) ; */
 #line 16 "define.pgc"
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 17 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 17 "define.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a int   , b text   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a int   , b text   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 19 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 19 "define.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'abcdef' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'abcdef' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 20 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 20 "define.pgc"
 
 
-   
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'defined' ) ", ECPGt_EOIT, ECPGt_EORT);
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'defined' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 23 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 23 "define.pgc"
 
-   
 
-   
-           
-   
-           
-   
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'someothervar not defined' ) ", ECPGt_EOIT, ECPGt_EORT);
+
+
+
+
+
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'someothervar not defined' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 31 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 31 "define.pgc"
 
-   
 
-   
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  1 , 29 :: text  || '-' || 'abcdef'     ", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(s),(long)200,(long)1,(200)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  1 , 29 :: text  || '-' || 'abcdef'     ", ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (s), (long) 200, (long) 1, (200) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 36 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "define.pgc"
 
 
-   printf("i: %d, s: %s\n", i, s);
+   printf("i: %d, s: %s\n", i, s);
+
 
-   
-   
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'no string' ) ", ECPGt_EOIT, ECPGt_EORT);
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 29 , 'no string' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 42 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 42 "define.pgc"
 
-   
 
-     /* no value */
-   
 
-   
-        
-   
-        
-   
-   { ECPGdo(__LINE__, 0, 1, NULL, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT);
+   /* no value */
+
+
+
+
+
+
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "set TIMEZONE to 'UTC'", ECPGt_EOIT, ECPGt_EORT);
 #line 53 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 53 "define.pgc"
 
-   
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 56 "define.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 56 "define.pgc"
 
-   return 0;
+   return 0;
 }
index d1c776fca1d18f37a7cffc956cc6ff117df06e95..c54e67ee7eee3547528907aa70a2b5f94f20bebf 100644 (file)
@@ -25,39 +25,43 @@ int
 main(void)
 {
    /* exec sql begin declare section */
-      
-      
-      
-
-      
-         
-         
-      
-     
-   
+
+
+
+
+
+
+
+
+
+
 #line 8 "desc.pgc"
char * stmt1   = "INSERT INTO test1 VALUES (?, ?)" ;
  char       *stmt1 = "INSERT INTO test1 VALUES (?, ?)";
+
 #line 9 "desc.pgc"
char * stmt2   = "SELECT * from test1 where a = ? and b = ?" ;
  char       *stmt2 = "SELECT * from test1 where a = ? and b = ?";
+
 #line 10 "desc.pgc"
char * stmt3   = "SELECT * from test1 where a = ?" ;
  char       *stmt3 = "SELECT * from test1 where a = ?";
+
 #line 12 "desc.pgc"
int  val1   = 1 ;
  int         val1 = 1;
+
 #line 13 "desc.pgc"
- char  val2 [ 4 ]   = "one" ,  val2output []   = "AAA" ;
+   char        val2[4] = "one",
+               val2output[] = "AAA";
+
 #line 14 "desc.pgc"
- int  val1output   = 2 ,  val2i   = 0 ;
+   int         val1output = 2,
+               val2i = 0;
+
 #line 15 "desc.pgc"
int  val2null   = - 1 ;
  int         val2null = -1;
+
 #line 16 "desc.pgc"
- int  ind1    ,  ind2    ;
+   int         ind1,
+               ind2;
+
 /* exec sql end declare section */
 #line 17 "desc.pgc"
 
@@ -67,172 +71,228 @@ main(void)
    ECPGallocate_desc(__LINE__, "indesc");
 #line 21 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 21 "desc.pgc"
 
    ECPGallocate_desc(__LINE__, "outdesc");
 #line 22 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 22 "desc.pgc"
 
 
-   { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
-   ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data,
+           ECPGt_int, &(val1), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 24 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 24 "desc.pgc"
 
-   { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
-   ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
-   ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data,
+                    ECPGt_char, (val2), (long) 4, (long) 1, (4) * sizeof(char), ECPGd_indicator,
+          ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 25 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 25 "desc.pgc"
 
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 27 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 27 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test1 ( a int   , b text   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test1 ( a int   , b text   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 29 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "desc.pgc"
 
-   { ECPGprepare(__LINE__, "foo1" , stmt1);
+   {
+       ECPGprepare(__LINE__, "foo1", stmt1);
 #line 30 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 30 "desc.pgc"
 
-   { ECPGprepare(__LINE__, "foo2" , stmt2);
+   {
+       ECPGprepare(__LINE__, "foo2", stmt2);
 #line 31 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 31 "desc.pgc"
 
-   { ECPGprepare(__LINE__, "foo3" , stmt3);
+   {
+       ECPGprepare(__LINE__, "foo3", stmt3);
 #line 32 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(ECPGprepared_statement("foo1")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (ECPGprepared_statement("foo1")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_descriptor, "indesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 34 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 34 "desc.pgc"
 
 
-   { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
-   ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data,
+             ECPGt_const, "2", (long) 1, (long) 1, strlen("2"), ECPGd_EODT);
 
 #line 36 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "desc.pgc"
 
-   { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
-   ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
-   ECPGt_int,&(val2null),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data,
+                    ECPGt_char, (val2), (long) 4, (long) 1, (4) * sizeof(char), ECPGd_indicator,
+       ECPGt_int, &(val2null), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 37 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(ECPGprepared_statement("foo1")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (ECPGprepared_statement("foo1")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_descriptor, "indesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 39 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "desc.pgc"
 
 
-   { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
-   ECPGt_const,"3",(long)1,(long)1,strlen("3"), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data,
+             ECPGt_const, "3", (long) 1, (long) 1, strlen("3"), ECPGd_EODT);
 
 #line 41 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 41 "desc.pgc"
 
-   { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
-   ECPGt_const,"this is a long test",(long)19,(long)1,strlen("this is a long test"), ECPGd_indicator,
-   ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data,
+                    ECPGt_const, "this is a long test", (long) 19, (long) 1, strlen("this is a long test"), ECPGd_indicator,
+           ECPGt_int, &(val1), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 42 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 42 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(ECPGprepared_statement("foo1")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (ECPGprepared_statement("foo1")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_descriptor, "indesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 44 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 44 "desc.pgc"
 
 
-   { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
-   ECPGt_int,&(val1),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data,
+           ECPGt_int, &(val1), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 46 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 46 "desc.pgc"
 
-   { ECPGset_desc(__LINE__, "indesc", 2,ECPGd_data,
-   ECPGt_char,(val2),(long)4,(long)1,(4)*sizeof(char), ECPGd_indicator,
-   ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 2, ECPGd_data,
+                    ECPGt_char, (val2), (long) 4, (long) 1, (4) * sizeof(char), ECPGd_indicator,
+          ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 47 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 47 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-   ECPGt_descriptor, "outdesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (ECPGprepared_statement("foo2")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_descriptor, "indesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT,
+              ECPGt_descriptor, "outdesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 49 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 49 "desc.pgc"
 
 
-   { ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data,
-   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "outdesc", 1, ECPGd_data,
+                    ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char), ECPGd_EODT);
 
 #line 51 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 51 "desc.pgc"
 
    printf("output = %s\n", val2output);
@@ -240,121 +300,156 @@ if (sqlca.sqlcode < 0) sqlprint();}
    /* declare c1  cursor  for ? */
 #line 54 "desc.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "declare c1  cursor  for ?", 
-   ECPGt_char_variable,(ECPGprepared_statement("foo2")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare c1  cursor  for ?",
+              ECPGt_char_variable, (ECPGprepared_statement("foo2")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_descriptor, "indesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 55 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 55 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT, 
-   ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
-   ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), 
-   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
-   ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT,
+              ECPGt_int, &(val1output), (long) 1, (long) 1, sizeof(int),
+              ECPGt_int, &(ind1), (long) 1, (long) 1, sizeof(int),
+              ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char),
+           ECPGt_int, &(ind2), (long) 1, (long) 1, sizeof(int), ECPGt_EORT);
 #line 57 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 57 "desc.pgc"
 
    printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
-       val1output, ind1, val2output, ind2);
+          val1output, ind1, val2output, ind2);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "close c1", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close c1", ECPGt_EOIT, ECPGt_EORT);
 #line 61 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 61 "desc.pgc"
 
 
-   { ECPGset_desc_header(__LINE__, "indesc", (int)(1));
+   {
+       ECPGset_desc_header(__LINE__, "indesc", (int) (1));
 
 #line 63 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 63 "desc.pgc"
 
-   { ECPGset_desc(__LINE__, "indesc", 1,ECPGd_data,
-   ECPGt_const,"2",(long)1,(long)1,strlen("2"), ECPGd_EODT);
+   {
+       ECPGset_desc(__LINE__, "indesc", 1, ECPGd_data,
+             ECPGt_const, "2", (long) 1, (long) 1, strlen("2"), ECPGd_EODT);
 
 #line 64 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 64 "desc.pgc"
 
 
    /* declare c2  cursor  for ? */
 #line 66 "desc.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "declare c2  cursor  for ?", 
-   ECPGt_char_variable,(ECPGprepared_statement("foo3")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare c2  cursor  for ?",
+              ECPGt_char_variable, (ECPGprepared_statement("foo3")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_descriptor, "indesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 67 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 67 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT, 
-   ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
-   ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT,
+              ECPGt_int, &(val1output), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char),
+          ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGt_EORT);
 #line 69 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 69 "desc.pgc"
 
    printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "close c2", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close c2", ECPGt_EOIT, ECPGt_EORT);
 #line 72 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 72 "desc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test1 where a = 3  ", ECPGt_EOIT, 
-   ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), 
-   ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test1 where a = 3  ", ECPGt_EOIT,
+              ECPGt_int, &(val1output), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (val2output), (long) sizeof("AAA"), (long) 1, (sizeof("AAA")) *sizeof(char),
+          ECPGt_int, &(val2i), (long) 1, (long) 1, sizeof(int), ECPGt_EORT);
 #line 74 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 74 "desc.pgc"
 
    printf("val1=%d val2=%c%c%c%c warn=%c truncate=%d\n", val1output, val2output[0], val2output[1], val2output[2], val2output[3], sqlca.sqlwarn[0], val2i);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "drop table test1 ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test1 ", ECPGt_EOIT, ECPGt_EORT);
 #line 77 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 77 "desc.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 78 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 78 "desc.pgc"
 
 
    ECPGdeallocate_desc(__LINE__, "indesc");
 #line 80 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 80 "desc.pgc"
 
    ECPGdeallocate_desc(__LINE__, "outdesc");
 #line 81 "desc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 81 "desc.pgc"
 
 
index 77cfa52b199bba783c508cb5e0a7b2de5027e718..ac6e722af10cbbb37b5acd0414b204726a560c96 100644 (file)
@@ -74,7 +74,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 2 "dynalloc.pgc"
@@ -91,250 +90,315 @@ struct sqlca_t *ECPGget_sqlca(void);
 #line 4 "dynalloc.pgc"
 
 
-int main(void)
+int
+main(void)
 {
-   /* exec sql begin declare section */
-        
-     
-    
-    
-    
-    
-    
-/*   char **d8=0; */
-    
-    
-    
-    
-    
-    
-    
-    
-/*   int *i8=0; */
-    
-   
+   /* exec sql begin declare section */
+
+
+
+
+
+
+
+/*  char **d8=0; */
+
+
+
+
+
+
+
+
+/*  int *i8=0; */
+
+
 #line 9 "dynalloc.pgc"
int * d1   = 0 ;
  int        *d1 = 0;
+
 #line 10 "dynalloc.pgc"
double * d2   = 0 ;
  double     *d2 = 0;
+
 #line 11 "dynalloc.pgc"
char ** d3   = 0 ;
  char      **d3 = 0;
+
 #line 12 "dynalloc.pgc"
char ** d4   = 0 ;
  char      **d4 = 0;
+
 #line 13 "dynalloc.pgc"
char ** d5   = 0 ;
  char      **d5 = 0;
+
 #line 14 "dynalloc.pgc"
char ** d6   = 0 ;
  char      **d6 = 0;
+
 #line 15 "dynalloc.pgc"
char ** d7   = 0 ;
  char      **d7 = 0;
+
 #line 17 "dynalloc.pgc"
char ** d9   = 0 ;
  char      **d9 = 0;
+
 #line 18 "dynalloc.pgc"
int * i1   = 0 ;
  int        *i1 = 0;
+
 #line 19 "dynalloc.pgc"
int * i2   = 0 ;
  int        *i2 = 0;
+
 #line 20 "dynalloc.pgc"
int * i3   = 0 ;
  int        *i3 = 0;
+
 #line 21 "dynalloc.pgc"
int * i4   = 0 ;
  int        *i4 = 0;
+
 #line 22 "dynalloc.pgc"
int * i5   = 0 ;
  int        *i5 = 0;
+
 #line 23 "dynalloc.pgc"
int * i6   = 0 ;
  int        *i6 = 0;
+
 #line 24 "dynalloc.pgc"
int * i7   = 0 ;
  int        *i7 = 0;
+
 #line 26 "dynalloc.pgc"
- int * i9   = 0 ;
+   int        *i9 = 0;
+
 /* exec sql end declare section */
 #line 27 "dynalloc.pgc"
 
-   int i;
+   int         i;
 
-   ECPGdebug(1, stderr);
+   ECPGdebug(1, stderr);
 
-   /* exec sql whenever sqlerror  do sqlprint (  ) ; */
+   /* exec sql whenever sqlerror  do sqlprint (  ) ; */
 #line 32 "dynalloc.pgc"
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 33 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 33 "dynalloc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to mdy", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to mdy", ECPGt_EOIT, ECPGt_EORT);
 #line 35 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 35 "dynalloc.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a serial   , b numeric ( 12 , 3 )   , c varchar    , d varchar ( 3 )    , e char  ( 4 )    , f timestamptz   , g boolean   , h box   , i inet   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a serial   , b numeric ( 12 , 3 )   , c varchar    , d varchar ( 3 )    , e char  ( 4 )    , f timestamptz   , g boolean   , h box   , i inet   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "dynalloc.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b  , c  , d  , e  , f  , g  , h  , i  ) values( 23.456 , 'varchar' , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , true , '(1,2,3,4)' , '2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b  , c  , d  , e  , f  , g  , h  , i  ) values( 23.456 , 'varchar' , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , true , '(1,2,3,4)' , '2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 38 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 38 "dynalloc.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b  , c  , d  , e  , f  , g  , h  , i  ) values( 2.446456 , null , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , false , null , null ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( b  , c  , d  , e  , f  , g  , h  , i  ) values( 2.446456 , null , 'v' , 'c' , '2003-03-03 12:33:07 PDT' , false , null , null ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 39 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "dynalloc.pgc"
 
 
-   ECPGallocate_desc(__LINE__, "mydesc");
+   ECPGallocate_desc(__LINE__, "mydesc");
 #line 41 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 41 "dynalloc.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  a , b , c , d , e , f , g , h , i  from test    order by a", ECPGt_EOIT, 
-   ECPGt_descriptor, "mydesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  a , b , c , d , e , f , g , h , i  from test    order by a", ECPGt_EOIT,
+              ECPGt_descriptor, "mydesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 42 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 42 "dynalloc.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator,
-   ECPGt_int,&(i1),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_int,&(d1),(long)1,(long)0,sizeof(int), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 1, ECPGd_indicator,
+              ECPGt_int, &(i1), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+             ECPGt_int, &(d1), (long) 1, (long) 0, sizeof(int), ECPGd_EODT);
 
 #line 43 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 43 "dynalloc.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator,
-   ECPGt_int,&(i2),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_double,&(d2),(long)1,(long)0,sizeof(double), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 2, ECPGd_indicator,
+              ECPGt_int, &(i2), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+       ECPGt_double, &(d2), (long) 1, (long) 0, sizeof(double), ECPGd_EODT);
 
 #line 44 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 44 "dynalloc.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 3,ECPGd_indicator,
-   ECPGt_int,&(i3),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_char,&(d3),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 3, ECPGd_indicator,
+              ECPGt_int, &(i3), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+                    ECPGt_char, &(d3), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT);
 
 #line 45 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 45 "dynalloc.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 4,ECPGd_indicator,
-   ECPGt_int,&(i4),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_char,&(d4),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 4, ECPGd_indicator,
+              ECPGt_int, &(i4), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+                    ECPGt_char, &(d4), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT);
 
 #line 46 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 46 "dynalloc.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 5,ECPGd_indicator,
-   ECPGt_int,&(i5),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_char,&(d5),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 5, ECPGd_indicator,
+              ECPGt_int, &(i5), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+                    ECPGt_char, &(d5), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT);
 
 #line 47 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 47 "dynalloc.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 6,ECPGd_indicator,
-   ECPGt_int,&(i6),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_char,&(d6),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 6, ECPGd_indicator,
+              ECPGt_int, &(i6), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+                    ECPGt_char, &(d6), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT);
 
 #line 48 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 48 "dynalloc.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 7,ECPGd_indicator,
-   ECPGt_int,&(i7),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_char,&(d7),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 7, ECPGd_indicator,
+              ECPGt_int, &(i7), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+                    ECPGt_char, &(d7), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT);
 
 #line 49 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 49 "dynalloc.pgc"
 
-   /* skip box for now */
-   /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */
-   { ECPGget_desc(__LINE__, "mydesc", 9,ECPGd_indicator,
-   ECPGt_int,&(i9),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_char,&(d9),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
+   /* skip box for now */
+   /* exec sql get descriptor mydesc value 8 :d8=DATA, :i8=INDICATOR; */
+   {
+       ECPGget_desc(__LINE__, "mydesc", 9, ECPGd_indicator,
+              ECPGt_int, &(i9), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+                    ECPGt_char, &(d9), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT);
 
 #line 52 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 52 "dynalloc.pgc"
 
 
-   printf("Result:\n");
-   for (i=0;i
-   {
-      if (i1[i]) printf("NULL, ");
-      else printf("%d, ",d1[i]); 
-
-      if (i2[i]) printf("NULL, ");
-      else printf("%f, ",d2[i]); 
-
-      if (i3[i]) printf("NULL, ");
-      else printf("'%s', ",d3[i]); 
-
-      if (i4[i]) printf("NULL, ");
-      else printf("'%s', ",d4[i]); 
-
-      if (i5[i]) printf("NULL, ");
-      else printf("'%s', ",d5[i]); 
-
-      if (i6[i]) printf("NULL, ");
-      else printf("'%s', ",d6[i]); 
-
-      if (i7[i]) printf("NULL, ");
-      else printf("'%s', ",d7[i]); 
-
-      if (i9[i]) printf("NULL, ");
-      else printf("'%s', ",d9[i]); 
-
-      printf("\n");
-   }
-   ECPGfree_auto_mem();
-   printf("\n");
-
-   ECPGdeallocate_desc(__LINE__, "mydesc");
+   printf("Result:\n");
+   for (i = 0; i < sqlca.sqlerrd[2]; ++i)
+   {
+       if (i1[i])
+           printf("NULL, ");
+       else
+           printf("%d, ", d1[i]);
+
+       if (i2[i])
+           printf("NULL, ");
+       else
+           printf("%f, ", d2[i]);
+
+       if (i3[i])
+           printf("NULL, ");
+       else
+           printf("'%s', ", d3[i]);
+
+       if (i4[i])
+           printf("NULL, ");
+       else
+           printf("'%s', ", d4[i]);
+
+       if (i5[i])
+           printf("NULL, ");
+       else
+           printf("'%s', ", d5[i]);
+
+       if (i6[i])
+           printf("NULL, ");
+       else
+           printf("'%s', ", d6[i]);
+
+       if (i7[i])
+           printf("NULL, ");
+       else
+           printf("'%s', ", d7[i]);
+
+       if (i9[i])
+           printf("NULL, ");
+       else
+           printf("'%s', ", d9[i]);
+
+       printf("\n");
+   }
+   ECPGfree_auto_mem();
+   printf("\n");
+
+   ECPGdeallocate_desc(__LINE__, "mydesc");
 #line 86 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 86 "dynalloc.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 87 "dynalloc.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 87 "dynalloc.pgc"
 
-   return 0;
+   return 0;
 }
index 69d9446169aa103f3840d123234862b38f74093c..2f9faf6fa9801f183e9ad3188f822f7413f9aff5 100644 (file)
@@ -74,7 +74,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 2 "dynalloc2.pgc"
@@ -91,166 +90,219 @@ struct sqlca_t *ECPGget_sqlca(void);
 #line 4 "dynalloc2.pgc"
 
 
-int main(void)
+int
+main(void)
 {
-   /* exec sql begin declare section */
-    
-    
-    
-    
-    
-   
+   /* exec sql begin declare section */
+
+
+
+
+
+
 #line 9 "dynalloc2.pgc"
int * ip1   = 0 ;
  int        *ip1 = 0;
+
 #line 10 "dynalloc2.pgc"
char ** cp2   = 0 ;
  char      **cp2 = 0;
+
 #line 11 "dynalloc2.pgc"
int * ipointer1   = 0 ;
  int        *ipointer1 = 0;
+
 #line 12 "dynalloc2.pgc"
int * ipointer2   = 0 ;
  int        *ipointer2 = 0;
+
 #line 13 "dynalloc2.pgc"
- int  colnum    ;
+   int         colnum;
+
 /* exec sql end declare section */
 #line 14 "dynalloc2.pgc"
 
-   int i;
+   int         i;
 
-   ECPGdebug(1, stderr);
+   ECPGdebug(1, stderr);
 
-   /* exec sql whenever sqlerror  do sqlprint (  ) ; */
+   /* exec sql whenever sqlerror  do sqlprint (  ) ; */
 #line 19 "dynalloc2.pgc"
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 20 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 20 "dynalloc2.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to postgres", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to postgres", ECPGt_EOIT, ECPGt_EORT);
 #line 22 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 22 "dynalloc2.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a int   , b text   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a int   , b text   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 24 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 24 "dynalloc2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 1 , 'one' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 1 , 'one' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 25 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 25 "dynalloc2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 2 , 'two' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 2 , 'two' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 26 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 26 "dynalloc2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'three' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , 'three' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 27 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 27 "dynalloc2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 4 , 'four' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 4 , 'four' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 28 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 28 "dynalloc2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 5 , null ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( 5 , null ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 29 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "dynalloc2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , null ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test values( null , null ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 30 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 30 "dynalloc2.pgc"
 
 
-   ECPGallocate_desc(__LINE__, "mydesc");
+   ECPGallocate_desc(__LINE__, "mydesc");
 #line 32 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 32 "dynalloc2.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test   ", ECPGt_EOIT, 
-   ECPGt_descriptor, "mydesc", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from test   ", ECPGt_EOIT,
+              ECPGt_descriptor, "mydesc", 0L, 0L, 0L,
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 33 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 33 "dynalloc2.pgc"
 
-   { ECPGget_desc_header(__LINE__, "mydesc", &(colnum));
+   {
+       ECPGget_desc_header(__LINE__, "mydesc", &(colnum));
 
 #line 34 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 34 "dynalloc2.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 1,ECPGd_indicator,
-   ECPGt_int,&(ipointer1),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_int,&(ip1),(long)1,(long)0,sizeof(int), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 1, ECPGd_indicator,
+       ECPGt_int, &(ipointer1), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+            ECPGt_int, &(ip1), (long) 1, (long) 0, sizeof(int), ECPGd_EODT);
 
 #line 35 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 35 "dynalloc2.pgc"
 
-   { ECPGget_desc(__LINE__, "mydesc", 2,ECPGd_indicator,
-   ECPGt_int,&(ipointer2),(long)1,(long)0,sizeof(int), ECPGd_data,
-   ECPGt_char,&(cp2),(long)0,(long)0,(1)*sizeof(char), ECPGd_EODT);
+   {
+       ECPGget_desc(__LINE__, "mydesc", 2, ECPGd_indicator,
+       ECPGt_int, &(ipointer2), (long) 1, (long) 0, sizeof(int), ECPGd_data,
+                    ECPGt_char, &(cp2), (long) 0, (long) 0, (1) * sizeof(char), ECPGd_EODT);
 
 #line 36 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "dynalloc2.pgc"
 
 
-   printf("Result (%d columns):\n", colnum);
-   for (i=0;i < sqlca.sqlerrd[2];++i)
-   {
-      if (ipointer1[i]) printf("NULL, ");
-      else printf("%d, ",ip1[i]); 
-
-      if (ipointer2[i]) printf("NULL, ");
-      else printf("'%s', ",cp2[i]); 
-      printf("\n");
-   }
-   ECPGfree_auto_mem();
-   printf("\n");
-
-   ECPGdeallocate_desc(__LINE__, "mydesc");
+   printf("Result (%d columns):\n", colnum);
+   for (i = 0; i < sqlca.sqlerrd[2]; ++i)
+   {
+       if (ipointer1[i])
+           printf("NULL, ");
+       else
+           printf("%d, ", ip1[i]);
+
+       if (ipointer2[i])
+           printf("NULL, ");
+       else
+           printf("'%s', ", cp2[i]);
+       printf("\n");
+   }
+   ECPGfree_auto_mem();
+   printf("\n");
+
+   ECPGdeallocate_desc(__LINE__, "mydesc");
 #line 51 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );
+   if (sqlca.sqlcode < 0)
+       sqlprint();
 #line 51 "dynalloc2.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "rollback");
+   {
+       ECPGtrans(__LINE__, NULL, "rollback");
 #line 52 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 52 "dynalloc2.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 53 "dynalloc2.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint (  );}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 53 "dynalloc2.pgc"
 
-   return 0;
+   return 0;
 }
index 5ecd7c65183c4a69d01274a4f3d9e5d5d46e1706..5ca8c356a4a8f1805d328ce740584000344fd201 100644 (file)
@@ -56,7 +56,6 @@ enum
    SQL3_DDT_ILLEGAL            /* not a datetime data type (not part of
                                 * standard) */
 };
-
 #endif   /* !_ECPG_SQL3TYPES_H */
 
 #line 7 "dyntest.pgc"
@@ -127,7 +126,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 8 "dyntest.pgc"
@@ -144,346 +142,409 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 static void
-error (void)
+error(void)
 {
-  printf ("\n#%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
-  exit (1);
+   printf("\n#%ld:%s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
+   exit(1);
 }
 
 int
-main (int argc, char **argv)
+main(int argc, char **argv)
 {
-  /* exec sql begin declare section */
-   
-   
-   
-   
-        
-   
-    
-   
-   
-   
-  
+   /* exec sql begin declare section */
+
+
+
+
+
+
+
+
+
+
+
 #line 22 "dyntest.pgc"
int  COUNT    ;
  int         COUNT;
+
 #line 23 "dyntest.pgc"
int  INTVAR    ;
  int         INTVAR;
+
 #line 24 "dyntest.pgc"
int  INDEX    ;
  int         INDEX;
+
 #line 25 "dyntest.pgc"
int  INDICATOR    ;
  int         INDICATOR;
+
 #line 26 "dyntest.pgc"
- int  TYPE    ,  LENGTH    ,  OCTET_LENGTH    ,  PRECISION    ,  SCALE    ,  RETURNED_OCTET_LENGTH    ;
+   int         TYPE,
+               LENGTH,
+               OCTET_LENGTH,
+               PRECISION,
+               SCALE,
+               RETURNED_OCTET_LENGTH;
+
 #line 27 "dyntest.pgc"
int  DATETIME_INTERVAL_CODE    ;
  int         DATETIME_INTERVAL_CODE;
+
 #line 28 "dyntest.pgc"
- char  NAME [ 120 ]    ,  BOOLVAR    ;
+   char        NAME[120],
+               BOOLVAR;
+
 #line 29 "dyntest.pgc"
char  STRINGVAR [ 1024 ]    ;
  char        STRINGVAR[1024];
+
 #line 30 "dyntest.pgc"
double  DOUBLEVAR    ;
  double      DOUBLEVAR;
+
 #line 31 "dyntest.pgc"
- char * QUERY    ;
+   char       *QUERY;
+
 /* exec sql end declare section */
 #line 32 "dyntest.pgc"
 
-  int done = 0;
+   int         done = 0;
 
-  /* exec sql var BOOLVAR is bool   */
+   /* exec sql var BOOLVAR is bool   */
 #line 35 "dyntest.pgc"
 
 
-  ECPGdebug (1, stderr);
+   ECPGdebug(1, stderr);
 
-  QUERY = "select * from dyntest";
+   QUERY = "select * from dyntest";
 
-  /* exec sql whenever sqlerror  do error (  ) ; */
+   /* exec sql whenever sqlerror  do error (  ) ; */
 #line 43 "dyntest.pgc"
 
 
-  ECPGallocate_desc(__LINE__, "MYDESC");
+   ECPGallocate_desc(__LINE__, "MYDESC");
 #line 45 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );
+   if (sqlca.sqlcode < 0)
+       error();
 #line 45 "dyntest.pgc"
 
 
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
 #line 47 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 47 "dyntest.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to german", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to german", ECPGt_EOIT, ECPGt_EORT);
 #line 49 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 49 "dyntest.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table dyntest ( name char  ( 14 )    , d float8   , i int   , bignumber int8   , b boolean   , comment text   , day date   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table dyntest ( name char  ( 14 )    , d float8   , i int   , bignumber int8   , b boolean   , comment text   , day date   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 53 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 53 "dyntest.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'first entry' , 14.7 , 14 , 123045607890 , true , 'The world''s most advanced open source database.' , '1987-07-14' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 54 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 54 "dyntest.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into dyntest values( 'second entry' , 1407.87 , 1407 , 987065403210 , false , 'The elephant never forgets.' , '1999-11-5' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 55 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 55 "dyntest.pgc"
 
 
-  { ECPGprepare(__LINE__, "MYQUERY" , QUERY);
+   {
+       ECPGprepare(__LINE__, "MYQUERY", QUERY);
 #line 57 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 57 "dyntest.pgc"
 
-  /* declare MYCURS  cursor  for ? */
+   /* declare MYCURS  cursor  for ? */
 #line 58 "dyntest.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "declare MYCURS  cursor  for ?", 
-   ECPGt_char_variable,(ECPGprepared_statement("MYQUERY")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare MYCURS  cursor  for ?",
+              ECPGt_char_variable, (ECPGprepared_statement("MYQUERY")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 60 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 60 "dyntest.pgc"
 
 
-  while (1)
-    {
-      { ECPGdo(__LINE__, 0, 1, NULL, "fetch in MYCURS", ECPGt_EOIT, 
-   ECPGt_descriptor, "MYDESC", 0L, 0L, 0L, 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   while (1)
+   {
+       {
+           ECPGdo(__LINE__, 0, 1, NULL, "fetch in MYCURS", ECPGt_EOIT,
+                  ECPGt_descriptor, "MYDESC", 0L, 0L, 0L,
+                  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 64 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+           if (sqlca.sqlcode < 0)
+               error();
+       }
 #line 64 "dyntest.pgc"
 
 
-      if (sqlca.sqlcode)
-   break;
+       if (sqlca.sqlcode)
+           break;
 
-      { ECPGget_desc_header(__LINE__, "MYDESC", &(COUNT));
+       {
+           ECPGget_desc_header(__LINE__, "MYDESC", &(COUNT));
 
 #line 69 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+           if (sqlca.sqlcode < 0)
+               error();
+       }
 #line 69 "dyntest.pgc"
 
-      if (!done)
-   {
-     printf ("Found %d columns\n", COUNT);
-     done = 1;
-   }
+       if (!done)
+       {
+           printf("Found %d columns\n", COUNT);
+           done = 1;
+       }
 
-      for (INDEX = 1; INDEX <= COUNT; ++INDEX)
-   {
-   { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_indicator,
-   ECPGt_int,&(INDICATOR),(long)1,(long)1,sizeof(int), ECPGd_name,
-   ECPGt_char,(NAME),(long)120,(long)1,(120)*sizeof(char), ECPGd_scale,
-   ECPGt_int,&(SCALE),(long)1,(long)1,sizeof(int), ECPGd_precision,
-   ECPGt_int,&(PRECISION),(long)1,(long)1,sizeof(int), ECPGd_ret_octet,
-   ECPGt_int,&(RETURNED_OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_octet,
-   ECPGt_int,&(OCTET_LENGTH),(long)1,(long)1,sizeof(int), ECPGd_length,
-   ECPGt_int,&(LENGTH),(long)1,(long)1,sizeof(int), ECPGd_type,
-   ECPGt_int,&(TYPE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+       for (INDEX = 1; INDEX <= COUNT; ++INDEX)
+       {
+           {
+               ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_indicator,
+                            ECPGt_int, &(INDICATOR), (long) 1, (long) 1, sizeof(int), ECPGd_name,
+                            ECPGt_char, (NAME), (long) 120, (long) 1, (120) * sizeof(char), ECPGd_scale,
+                            ECPGt_int, &(SCALE), (long) 1, (long) 1, sizeof(int), ECPGd_precision,
+                            ECPGt_int, &(PRECISION), (long) 1, (long) 1, sizeof(int), ECPGd_ret_octet,
+                            ECPGt_int, &(RETURNED_OCTET_LENGTH), (long) 1, (long) 1, sizeof(int), ECPGd_octet,
+                            ECPGt_int, &(OCTET_LENGTH), (long) 1, (long) 1, sizeof(int), ECPGd_length,
+                            ECPGt_int, &(LENGTH), (long) 1, (long) 1, sizeof(int), ECPGd_type,
+                            ECPGt_int, &(TYPE), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 86 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+               if (sqlca.sqlcode < 0)
+                   error();
+           }
 #line 86 "dyntest.pgc"
 
-     printf ("%2d\t%s (type: %d length: %d precision: %d scale: %d = " , INDEX, NAME, TYPE, LENGTH, PRECISION, SCALE);
-     switch (TYPE)
-       {
-       case SQL3_BOOLEAN:
-         printf ("bool");
-         break;
-       case SQL3_NUMERIC:
-         printf ("numeric(%d,%d)", PRECISION, SCALE);
-         break;
-       case SQL3_DECIMAL:
-         printf ("decimal(%d,%d)", PRECISION, SCALE);
-         break;
-       case SQL3_INTEGER:
-         printf ("integer");
-         break;
-       case SQL3_SMALLINT:
-         printf ("smallint");
-         break;
-       case SQL3_FLOAT:
-         printf ("float(%d,%d)", PRECISION, SCALE);
-         break;
-       case SQL3_REAL:
-         printf ("real");
-         break;
-       case SQL3_DOUBLE_PRECISION:
-         printf ("double precision");
-         break;
-       case SQL3_DATE_TIME_TIMESTAMP:
-       { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_di_code,
-   ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+           printf("%2d\t%s (type: %d length: %d precision: %d scale: %d = ", INDEX, NAME, TYPE, LENGTH, PRECISION, SCALE);
+           switch (TYPE)
+           {
+               case SQL3_BOOLEAN:
+                   printf("bool");
+                   break;
+               case SQL3_NUMERIC:
+                   printf("numeric(%d,%d)", PRECISION, SCALE);
+                   break;
+               case SQL3_DECIMAL:
+                   printf("decimal(%d,%d)", PRECISION, SCALE);
+                   break;
+               case SQL3_INTEGER:
+                   printf("integer");
+                   break;
+               case SQL3_SMALLINT:
+                   printf("smallint");
+                   break;
+               case SQL3_FLOAT:
+                   printf("float(%d,%d)", PRECISION, SCALE);
+                   break;
+               case SQL3_REAL:
+                   printf("real");
+                   break;
+               case SQL3_DOUBLE_PRECISION:
+                   printf("double precision");
+                   break;
+               case SQL3_DATE_TIME_TIMESTAMP:
+                   {
+                       ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_di_code,
+                                    ECPGt_int, &(DATETIME_INTERVAL_CODE), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 116 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+                       if (sqlca.sqlcode < 0)
+                           error();
+                   }
 #line 116 "dyntest.pgc"
 
-         switch (DATETIME_INTERVAL_CODE)
-       {
-       case SQL3_DDT_DATE:
-         printf ("date");
-         break;
-       case SQL3_DDT_TIME:
-         printf ("time");
-         break;
-       case SQL3_DDT_TIMESTAMP:
-         printf ("timestamp");
-         break;
-       case SQL3_DDT_TIME_WITH_TIME_ZONE:
-         printf ("time with time zone");
-         break;
-       case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE:
-         printf ("timestamp with time zone");
-         break;
-       }
-         break;
-       case SQL3_INTERVAL:
-         printf ("interval");
-         break;
-       case SQL3_CHARACTER:
-         if (LENGTH > 0)
-       printf ("char(%d)", LENGTH);
-         else
-       printf ("text");
-         break;
-       case SQL3_CHARACTER_VARYING:
-         if (LENGTH > 0)
-       printf ("varchar(%d)", LENGTH);
-         else
-       printf ("varchar()");
-         break;
-       default:
-         if (TYPE < 0)
-       printf ("", -TYPE);
-         else
-       printf ("", TYPE);
-         break;
-       }
-     printf (")\n\toctet_length: %d returned_octet_length: %d)\n\t= ",
-         OCTET_LENGTH, RETURNED_OCTET_LENGTH);
-     if (INDICATOR == -1)
-       printf ("NULL\n");
-     else
-       switch (TYPE)
-         {
-         case SQL3_BOOLEAN:
-         { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
-   ECPGt_bool,&(BOOLVAR),(long)1,(long)1,sizeof(bool), ECPGd_EODT);
+                   switch (DATETIME_INTERVAL_CODE)
+                   {
+                       case SQL3_DDT_DATE:
+                           printf("date");
+                           break;
+                       case SQL3_DDT_TIME:
+                           printf("time");
+                           break;
+                       case SQL3_DDT_TIMESTAMP:
+                           printf("timestamp");
+                           break;
+                       case SQL3_DDT_TIME_WITH_TIME_ZONE:
+                           printf("time with time zone");
+                           break;
+                       case SQL3_DDT_TIMESTAMP_WITH_TIME_ZONE:
+                           printf("timestamp with time zone");
+                           break;
+                   }
+                   break;
+               case SQL3_INTERVAL:
+                   printf("interval");
+                   break;
+               case SQL3_CHARACTER:
+                   if (LENGTH > 0)
+                       printf("char(%d)", LENGTH);
+                   else
+                       printf("text");
+                   break;
+               case SQL3_CHARACTER_VARYING:
+                   if (LENGTH > 0)
+                       printf("varchar(%d)", LENGTH);
+                   else
+                       printf("varchar()");
+                   break;
+               default:
+                   if (TYPE < 0)
+                       printf("", -TYPE);
+                   else
+                       printf("", TYPE);
+                   break;
+           }
+           printf(")\n\toctet_length: %d returned_octet_length: %d)\n\t= ",
+                  OCTET_LENGTH, RETURNED_OCTET_LENGTH);
+           if (INDICATOR == -1)
+               printf("NULL\n");
+           else
+               switch (TYPE)
+               {
+                   case SQL3_BOOLEAN:
+                       {
+                           ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data,
+                                        ECPGt_bool, &(BOOLVAR), (long) 1, (long) 1, sizeof(bool), ECPGd_EODT);
 
 #line 166 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+                           if (sqlca.sqlcode < 0)
+                               error();
+                       }
 #line 166 "dyntest.pgc"
 
-       printf ("%s\n", BOOLVAR ? "true" : "false");
-       break;
-         case SQL3_INTEGER:
-         case SQL3_SMALLINT:
-         { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
-   ECPGt_int,&(INTVAR),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+                       printf("%s\n", BOOLVAR ? "true" : "false");
+                       break;
+                   case SQL3_INTEGER:
+                   case SQL3_SMALLINT:
+                       {
+                           ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data,
+                                        ECPGt_int, &(INTVAR), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 171 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+                           if (sqlca.sqlcode < 0)
+                               error();
+                       }
 #line 171 "dyntest.pgc"
 
-       printf ("%d\n", INTVAR);
-       break;
-         case SQL3_DOUBLE_PRECISION:
-         { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
-   ECPGt_double,&(DOUBLEVAR),(long)1,(long)1,sizeof(double), ECPGd_EODT);
+                       printf("%d\n", INTVAR);
+                       break;
+                   case SQL3_DOUBLE_PRECISION:
+                       {
+                           ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data,
+                                        ECPGt_double, &(DOUBLEVAR), (long) 1, (long) 1, sizeof(double), ECPGd_EODT);
 
 #line 175 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+                           if (sqlca.sqlcode < 0)
+                               error();
+                       }
 #line 175 "dyntest.pgc"
 
-       printf ("%.*f\n", PRECISION, DOUBLEVAR);
-       break;
-         case SQL3_DATE_TIME_TIMESTAMP:
-         { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
-   ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_di_code,
-   ECPGt_int,&(DATETIME_INTERVAL_CODE),(long)1,(long)1,sizeof(int), ECPGd_EODT);
+                       printf("%.*f\n", PRECISION, DOUBLEVAR);
+                       break;
+                   case SQL3_DATE_TIME_TIMESTAMP:
+                       {
+                           ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data,
+                                        ECPGt_char, (STRINGVAR), (long) 1024, (long) 1, (1024) * sizeof(char), ECPGd_di_code,
+                                        ECPGt_int, &(DATETIME_INTERVAL_CODE), (long) 1, (long) 1, sizeof(int), ECPGd_EODT);
 
 #line 181 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+                           if (sqlca.sqlcode < 0)
+                               error();
+                       }
 #line 181 "dyntest.pgc"
 
-       printf ("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR);
-       break;
-         case SQL3_CHARACTER:
-         case SQL3_CHARACTER_VARYING:
-         { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
-   ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
+                       printf("%d \"%s\"\n", DATETIME_INTERVAL_CODE, STRINGVAR);
+                       break;
+                   case SQL3_CHARACTER:
+                   case SQL3_CHARACTER_VARYING:
+                       {
+                           ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data,
+                                        ECPGt_char, (STRINGVAR), (long) 1024, (long) 1, (1024) * sizeof(char), ECPGd_EODT);
 
 #line 186 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+                           if (sqlca.sqlcode < 0)
+                               error();
+                       }
 #line 186 "dyntest.pgc"
 
-       printf ("\"%s\"\n", STRINGVAR);
-       break;
-         default:
-         { ECPGget_desc(__LINE__, "MYDESC", INDEX,ECPGd_data,
-   ECPGt_char,(STRINGVAR),(long)1024,(long)1,(1024)*sizeof(char), ECPGd_EODT);
+                       printf("\"%s\"\n", STRINGVAR);
+                       break;
+                   default:
+                       {
+                           ECPGget_desc(__LINE__, "MYDESC", INDEX, ECPGd_data,
+                                        ECPGt_char, (STRINGVAR), (long) 1024, (long) 1, (1024) * sizeof(char), ECPGd_EODT);
 
 #line 190 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+                           if (sqlca.sqlcode < 0)
+                               error();
+                       }
 #line 190 "dyntest.pgc"
 
-       printf ("<\"%s\">\n", STRINGVAR);
-       break;
-         }
+                       printf("<\"%s\">\n", STRINGVAR);
+                       break;
+               }
+       }
    }
-    }
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "close MYCURS", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close MYCURS", ECPGt_EOIT, ECPGt_EORT);
 #line 197 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );}
+       if (sqlca.sqlcode < 0)
+           error();
+   }
 #line 197 "dyntest.pgc"
 
 
-  ECPGdeallocate_desc(__LINE__, "MYDESC");
+   ECPGdeallocate_desc(__LINE__, "MYDESC");
 #line 199 "dyntest.pgc"
 
-if (sqlca.sqlcode < 0) error (  );
+   if (sqlca.sqlcode < 0)
+       error();
 #line 199 "dyntest.pgc"
 
 
-  return 0;
-  }
+   return 0;
+}
index 662f554f4ee1989ef4a16fe3903a8fd6a6a4f829..d07d82cc97ab14ced41a84d524d83870a5c6db53 100644 (file)
@@ -31,155 +31,195 @@ int
 main(void)
 {
 /* exec sql begin declare section */
-    
-    
-    
-    
-    
+
+
+
+
+
 
 #line 14 "execute.pgc"
int  amount [ 8 ]    ;
  int         amount[8];
+
 #line 15 "execute.pgc"
int  increment   = 100 ;
  int         increment = 100;
+
 #line 16 "execute.pgc"
char  name [ 8 ] [ 8 ]    ;
  char        name[8][8];
+
 #line 17 "execute.pgc"
char  letter [ 8 ] [ 1 ]    ;
  char        letter[8][1];
+
 #line 18 "execute.pgc"
- char  command [ 128 ]    ;
+   char        command[128];
+
 /* exec sql end declare section */
 #line 19 "execute.pgc"
 
-   int i,j;
+   int         i,
+               j;
 
    ECPGdebug(1, stderr);
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , "main", 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, "main", 0);
 #line 24 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 24 "execute.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( name char  ( 8 )    , amount int   , letter char  ( 1 )    )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( name char  ( 8 )    , amount int   , letter char  ( 1 )    )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 25 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 25 "execute.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 26 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 26 "execute.pgc"
 
 
    sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (command), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 29 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "execute.pgc"
 
 
    sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (command), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 32 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "execute.pgc"
 
 
    sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(command),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (command), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 35 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 35 "execute.pgc"
 
 
    printf("Inserted %ld tuples via execute immediate\n", sqlca.sqlerrd[2]);
 
    sprintf(command, "insert into test (name, amount, letter) select name, amount+?, letter from test");
-   { ECPGprepare(__LINE__, "I" , command);
+   {
+       ECPGprepare(__LINE__, "I", command);
 #line 40 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 40 "execute.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "?", 
-   ECPGt_char_variable,(ECPGprepared_statement("I")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "?",
+              ECPGt_char_variable, (ECPGprepared_statement("I")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, &(increment), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 41 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 41 "execute.pgc"
 
 
    printf("Inserted %ld tuples via prepared execute\n", sqlca.sqlerrd[2]);
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 45 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 45 "execute.pgc"
 
 
-   sprintf (command, "select * from test");
+   sprintf(command, "select * from test");
 
-   { ECPGprepare(__LINE__, "F" , command);
+   {
+       ECPGprepare(__LINE__, "F", command);
 #line 49 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 49 "execute.pgc"
 
-   /* declare CUR  cursor  for ? */
+   /* declare CUR  cursor  for ? */
 #line 50 "execute.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "declare CUR  cursor  for ?", 
-   ECPGt_char_variable,(ECPGprepared_statement("F")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare CUR  cursor  for ?",
+              ECPGt_char_variable, (ECPGprepared_statement("F")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 52 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 52 "execute.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "fetch 8 in CUR", ECPGt_EOIT, 
-   ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "fetch 8 in CUR", ECPGt_EOIT,
+              ECPGt_char, (name), (long) 8, (long) 8, (8) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, (amount), (long) 1, (long) 8, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (letter), (long) 1, (long) 8, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 53 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 53 "execute.pgc"
 
 
-   for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
+   for (i = 0, j = sqlca.sqlerrd[2]; i < j; i++)
    {
        /* exec sql begin declare section */
-           
-          
-       
+
+
+
 #line 58 "execute.pgc"
- char  n [ 8 ]    ,  l   = letter [ i ] [ 0 ] ;
+       char        n[8],
+                   l = letter[i][0];
+
 #line 59 "execute.pgc"
- int  a   = amount [ i ] ;
+       int         a = amount[i];
+
 /* exec sql end declare section */
 #line 60 "execute.pgc"
 
@@ -188,59 +228,73 @@ if (sqlca.sqlcode < 0) sqlprint();}
        printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
    }
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "close CUR", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close CUR", ECPGt_EOIT, ECPGt_EORT);
 #line 66 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 66 "execute.pgc"
 
 
-   sprintf (command, "select * from test where amount = ?");
+   sprintf(command, "select * from test where amount = ?");
 
-   { ECPGprepare(__LINE__, "F" , command);
+   {
+       ECPGprepare(__LINE__, "F", command);
 #line 70 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 70 "execute.pgc"
 
    /* declare CUR2  cursor  for ? */
 #line 71 "execute.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "declare CUR2  cursor  for ?", 
-   ECPGt_char_variable,(ECPGprepared_statement("F")),(long)1,(long)1,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare CUR2  cursor  for ?",
+              ECPGt_char_variable, (ECPGprepared_statement("F")), (long) 1, (long) 1, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_const, "1", (long) 1, (long) 1, strlen("1"),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 73 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 73 "execute.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "fetch in CUR2", ECPGt_EOIT, 
-   ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,(amount),(long)1,(long)8,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(letter),(long)1,(long)8,(1)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "fetch in CUR2", ECPGt_EOIT,
+              ECPGt_char, (name), (long) 8, (long) 8, (8) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, (amount), (long) 1, (long) 8, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (letter), (long) 1, (long) 8, (1) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 74 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 74 "execute.pgc"
 
 
-   for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
+   for (i = 0, j = sqlca.sqlerrd[2]; i < j; i++)
    {
        /* exec sql begin declare section */
-           
-          
-       
+
+
+
 #line 79 "execute.pgc"
- char  n [ 8 ]    ,  l   = letter [ i ] [ 0 ] ;
+       char        n[8],
+                   l = letter[i][0];
+
 #line 80 "execute.pgc"
- int  a   = amount [ i ] ;
+       int         a = amount[i];
+
 /* exec sql end declare section */
 #line 81 "execute.pgc"
 
@@ -249,28 +303,40 @@ if (sqlca.sqlcode < 0) sqlprint();}
        printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
    }
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "close CUR2", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close CUR2", ECPGt_EOIT, ECPGt_EORT);
 #line 87 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 87 "execute.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
 #line 88 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 88 "execute.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 89 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 89 "execute.pgc"
 
-   { ECPGdisconnect(__LINE__, "CURRENT");
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
 #line 90 "execute.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 90 "execute.pgc"
 
 
index 2d6ff974262087c29bb82175c6203be7d9575d51..617eb80e4047cc8a28c525e82dcb7df25917d7c7 100644 (file)
 #line 5 "fetch.pgc"
 
 
-int main(int argc, char* argv[]) {
-  /* exec sql begin declare section */
-     
-        
-  
+int
+main(int argc, char *argv[])
+{
+   /* exec sql begin declare section */
+
+
+
 #line 9 "fetch.pgc"
char  str [ 25 ]    ;
  char        str[25];
+
 #line 10 "fetch.pgc"
- int  i    ,  how_many   = 1 ;
+   int         i,
+               how_many = 1;
+
 /* exec sql end declare section */
 #line 11 "fetch.pgc"
 
 
-  ECPGdebug(1, stderr);
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   ECPGdebug(1, stderr);
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 14 "fetch.pgc"
 
 
-  /* exec sql whenever sql_warning  sqlprint ; */
+   /* exec sql whenever sql_warning  sqlprint ; */
 #line 16 "fetch.pgc"
 
-  /* exec sql whenever sqlerror  sqlprint ; */
+   /* exec sql whenever sqlerror  sqlprint ; */
 #line 17 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table My_Table ( Item1 int   , Item2 text   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table My_Table ( Item1 int   , Item2 text   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 19 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 19 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 19 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 1 , 'text1' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 1 , 'text1' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 21 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 21 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 21 "fetch.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 2 , 'text2' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 2 , 'text2' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 22 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 22 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 22 "fetch.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 3 , 'text3' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 3 , 'text3' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 23 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 23 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 23 "fetch.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 4 , 'text4' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values ( 4 , 'text4' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 24 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 24 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 24 "fetch.pgc"
 
 
-  /* declare C  cursor  for select  *  from My_Table    */
+   /* declare C  cursor  for select  *  from My_Table    */
 #line 26 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "declare C  cursor  for select  *  from My_Table   ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "declare C  cursor  for select  *  from My_Table   ", ECPGt_EOIT, ECPGt_EORT);
 #line 28 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 28 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 28 "fetch.pgc"
 
 
-  /* exec sql whenever not found  break ; */
+   /* exec sql whenever not found  break ; */
 #line 30 "fetch.pgc"
 
-  while (1) {
-   { ECPGdo(__LINE__, 0, 1, NULL, "fetch 1 in C", ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   while (1)
+   {
+       {
+           ECPGdo(__LINE__, 0, 1, NULL, "fetch 1 in C", ECPGt_EOIT,
+                  ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+                  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+                ECPGt_char, (str), (long) 25, (long) 1, (25) * sizeof(char),
+                  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 32 "fetch.pgc"
 
-if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+           if (sqlca.sqlcode == ECPG_NOT_FOUND)
+               break;
 #line 32 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+           if (sqlca.sqlwarn[0] == 'W')
+               sqlprint();
 #line 32 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+           if (sqlca.sqlcode < 0)
+               sqlprint();
+       }
 #line 32 "fetch.pgc"
 
-   printf("%d: %s\n", i, str);
-  }
+       printf("%d: %s\n", i, str);
+   }
 
-  /* exec sql whenever not found  continue ; */
+   /* exec sql whenever not found  continue ; */
 #line 36 "fetch.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 37 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "fetch  ? in C", 
-   ECPGt_int,&(how_many),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
-   ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "fetch  ? in C",
+              ECPGt_int, &(how_many), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT,
+              ECPGt_int, &(i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_char, (str), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 39 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 39 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "fetch.pgc"
 
-  printf("%d: %s\n", i, str);
+   printf("%d: %s\n", i, str);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "close C", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "close C", ECPGt_EOIT, ECPGt_EORT);
 #line 42 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 42 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 42 "fetch.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT);
 #line 44 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 44 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 44 "fetch.pgc"
 
 
-  { ECPGdisconnect(__LINE__, "ALL");
+   {
+       ECPGdisconnect(__LINE__, "ALL");
 #line 46 "fetch.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 46 "fetch.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 46 "fetch.pgc"
 
 
-  return 0;
+   return 0;
 }
index 6f8bf3a17fb79da0afde1c776886e5917551a805..59e830bc5f68e582a57b671994ad5bcb1e33c1be 100644 (file)
 #line 5 "func.pgc"
 
 
-int main(int argc, char* argv[]) {
-
-  ECPGdebug(1, stderr);
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+int
+main(int argc, char *argv[])
+{
+
+   ECPGdebug(1, stderr);
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 10 "func.pgc"
 
 
-  { ECPGsetcommit(__LINE__, "on", NULL);}
+   {
+       ECPGsetcommit(__LINE__, "on", NULL);
+   }
 #line 12 "func.pgc"
 
-  /* exec sql whenever sql_warning  sqlprint ; */
+   /* exec sql whenever sql_warning  sqlprint ; */
 #line 13 "func.pgc"
 
-  /* exec sql whenever sqlerror  sqlprint ; */
+   /* exec sql whenever sqlerror  sqlprint ; */
 #line 14 "func.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table My_Table ( Item1 int   , Item2 text   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table My_Table ( Item1 int   , Item2 text   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 16 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 16 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 16 "func.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  function My_Table_Check () returns trigger  as $test$\
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  function My_Table_Check () returns trigger  as $test$\
     BEGIN\
    RAISE WARNING 'Notice: TG_NAME=%, TG WHEN=%', TG_NAME, TG_WHEN;\
    RETURN NEW;\
     END; $test$ language plpgsql", ECPGt_EOIT, ECPGt_EORT);
 #line 24 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 24 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 24 "func.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create trigger My_Table_Check_Trigger before insert on My_Table for each row execute procedure My_Table_Check (  )", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create trigger My_Table_Check_Trigger before insert on My_Table for each row execute procedure My_Table_Check (  )", ECPGt_EOIT, ECPGt_EORT);
 #line 30 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 30 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 30 "func.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 1234 , 'Some random text' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 1234 , 'Some random text' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 32 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 32 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "func.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 5678 , 'The Quick Brown' ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into My_Table values( 5678 , 'The Quick Brown' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 33 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 33 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 33 "func.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "drop trigger My_Table_Check_Trigger on My_Table ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop trigger My_Table_Check_Trigger on My_Table ", ECPGt_EOIT, ECPGt_EORT);
 #line 35 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 35 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 35 "func.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "drop function My_Table_Check () ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop function My_Table_Check () ", ECPGt_EOIT, ECPGt_EORT);
 #line 36 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 36 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "func.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table My_Table ", ECPGt_EOIT, ECPGt_EORT);
 #line 37 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 37 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 37 "func.pgc"
 
 
-  { ECPGdisconnect(__LINE__, "ALL");
+   {
+       ECPGdisconnect(__LINE__, "ALL");
 #line 39 "func.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 39 "func.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 39 "func.pgc"
 
 
-  return 0;
+   return 0;
 }
index cc7054d47311c6d6196f1c7869a568fde9c9ba1b..1a910ae03d772efe5201a13b68d9c6592d31a1f7 100644 (file)
@@ -75,7 +75,6 @@ struct sqlca_t *ECPGget_sqlca(void);
 #ifdef __cplusplus
 }
 #endif
-
 #endif
 
 #line 3 "indicators.pgc"
@@ -92,98 +91,133 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
 {
    /* exec sql begin declare section */
-          
-          
-   
+
+
+
 #line 10 "indicators.pgc"
int  intvar   = 5 ;
  int         intvar = 5;
+
 #line 11 "indicators.pgc"
- int  nullind   = - 1 ;
+   int         nullind = -1;
+
 /* exec sql end declare section */
 #line 12 "indicators.pgc"
 
 
-   ECPGdebug(1,stderr);
+   ECPGdebug(1, stderr);
 
-   { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 16 "indicators.pgc"
 
-   { ECPGsetcommit(__LINE__, "off", NULL);}
+   {
+       ECPGsetcommit(__LINE__, "off", NULL);
+   }
 #line 17 "indicators.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( \"id\" int   primary key   , \"str\" text   not null , val int   null )    ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( \"id\" int   primary key   , \"str\" text   not null , val int   null )    ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 22 "indicators.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");}
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 23 "indicators.pgc"
 
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id  , str  , val  ) values( 1 , 'Hello' , 0 ) ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id  , str  , val  ) values( 1 , 'Hello' , 0 ) ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 25 "indicators.pgc"
 
 
    /* use indicator in insert */
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id  , str  , val  ) values( 2 , 'Hi there' ,  ? ) ", 
-   ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
-   ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id  , str  , val  ) values( 2 , 'Hi there' ,  ? ) ",
+              ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int),
+              ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 28 "indicators.pgc"
 
    nullind = 0;
-   { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id  , str  , val  ) values( 3 , 'Good evening' ,  ? ) ", 
-   ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
-   ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( id  , str  , val  ) values( 3 , 'Good evening' ,  ? ) ",
+              ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int),
+              ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 30 "indicators.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");}
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 31 "indicators.pgc"
 
 
    /* use indicators to get information about selects */
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 1  ", ECPGt_EOIT, 
-   ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 1  ", ECPGt_EOIT,
+              ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 34 "indicators.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 2  ", ECPGt_EOIT, 
-   ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
-   ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 2  ", ECPGt_EOIT,
+              ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int),
+        ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EORT);
+   }
 #line 35 "indicators.pgc"
 
    printf("intvar: %d, nullind: %d\n", intvar, nullind);
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 3  ", ECPGt_EOIT, 
-   ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
-   ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 3  ", ECPGt_EOIT,
+              ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int),
+        ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EORT);
+   }
 #line 37 "indicators.pgc"
 
    printf("intvar: %d, nullind: %d\n", intvar, nullind);
 
    /* use indicators for update */
-   intvar = 5; nullind = -1;
-   { ECPGdo(__LINE__, 0, 1, NULL, "update test set val  =  ?  where id = 1 ", 
-   ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
-   ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
+   intvar = 5;
+   nullind = -1;
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "update test set val  =  ?  where id = 1 ",
+              ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int),
+              ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 42 "indicators.pgc"
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 1  ", ECPGt_EOIT, 
-   ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int), 
-   ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  val  from test where id = 1  ", ECPGt_EOIT,
+              ECPGt_int, &(intvar), (long) 1, (long) 1, sizeof(int),
+        ECPGt_int, &(nullind), (long) 1, (long) 1, sizeof(int), ECPGt_EORT);
+   }
 #line 43 "indicators.pgc"
 
    printf("intvar: %d, nullind: %d\n", intvar, nullind);
 
-   { ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 46 "indicators.pgc"
 
-   { ECPGtrans(__LINE__, NULL, "commit");}
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 47 "indicators.pgc"
 
 
-   { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 49 "indicators.pgc"
 
    return 0;
index 5bb9ab005acd16925c102ef60a1edc537945356c..7ab022d9b4e9ee252dac33f69f7bc147ceac0c0b 100644 (file)
 #line 5 "quote.pgc"
 
 
-int main(int argc, char* argv[]) {
-  /* exec sql begin declare section */
-     
-  
+int
+main(int argc, char *argv[])
+{
+   /* exec sql begin declare section */
+
+
 #line 9 "quote.pgc"
- char  var [ 25 ]    ;
+   char        var[25];
+
 /* exec sql end declare section */
 #line 10 "quote.pgc"
 
 
-  ECPGdebug(1, stderr);
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   ECPGdebug(1, stderr);
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 13 "quote.pgc"
 
 
-  { ECPGsetcommit(__LINE__, "on", NULL);}
+   {
+       ECPGsetcommit(__LINE__, "on", NULL);
+   }
 #line 15 "quote.pgc"
 
-  /* exec sql whenever sql_warning  sqlprint ; */
+   /* exec sql whenever sql_warning  sqlprint ; */
 #line 16 "quote.pgc"
 
-  /* exec sql whenever sqlerror  sqlprint ; */
+   /* exec sql whenever sqlerror  sqlprint ; */
 #line 17 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table \"My_Table\" ( Item1 int   , Item2 text   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table \"My_Table\" ( Item1 int   , Item2 text   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 19 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 19 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 19 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT, 
-   ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT,
+              ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 21 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 21 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 21 "quote.pgc"
 
-  printf("Standard conforming strings: %s\n", var);
+   printf("Standard conforming strings: %s\n", var);
 
-  /* this is a\\b actually */
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
+   /* this is a\\b actually */
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 25 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 25 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 25 "quote.pgc"
 
-  /* this is a\b */
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
+   /* this is a\b */
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 27 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 27 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 27 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
 #line 29 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 29 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 29 "quote.pgc"
 
 
-  /* this is a\\b actually */
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
+   /* this is a\\b actually */
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 32 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 32 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "quote.pgc"
 
-  /* this is a\b */
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
+   /* this is a\b */
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into \"My_Table\" values ( 1 , 'a\\\\b' ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 34 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 34 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 34 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "select  *  from \"My_Table\"   ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  *  from \"My_Table\"   ", ECPGt_EOIT, ECPGt_EORT);
 #line 36 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 36 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "quote.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "drop table \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table \"My_Table\" ", ECPGt_EOIT, ECPGt_EORT);
 #line 38 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 38 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 38 "quote.pgc"
 
 
-  { ECPGdisconnect(__LINE__, "ALL");
+   {
+       ECPGdisconnect(__LINE__, "ALL");
 #line 40 "quote.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 40 "quote.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 40 "quote.pgc"
 
 
-  return 0;
+   return 0;
 }
index e5c906b45eb89d831957659aefcb0d4508fa8688..a0cba021afcccc1ae3faac825a58603cf04afa19 100644 (file)
 #line 5 "show.pgc"
 
 
-int main(int argc, char* argv[]) {
-  /* exec sql begin declare section */
-     
-  
+int
+main(int argc, char *argv[])
+{
+   /* exec sql begin declare section */
+
+
 #line 9 "show.pgc"
- char  var [ 25 ]    ;
+   char        var[25];
+
 /* exec sql end declare section */
 #line 10 "show.pgc"
 
 
-  ECPGdebug(1, stderr);
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   ECPGdebug(1, stderr);
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 13 "show.pgc"
 
 
-  /* exec sql whenever sql_warning  sqlprint ; */
+   /* exec sql whenever sql_warning  sqlprint ; */
 #line 15 "show.pgc"
 
-  /* exec sql whenever sqlerror  sqlprint ; */
+   /* exec sql whenever sqlerror  sqlprint ; */
 #line 16 "show.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "show search_path", ECPGt_EOIT, 
-   ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "show search_path", ECPGt_EOIT,
+              ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 18 "show.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 18 "show.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 18 "show.pgc"
 
-  printf("Var: Search path: %s\n", var);
+   printf("Var: Search path: %s\n", var);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "show wal_buffers", ECPGt_EOIT, 
-   ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "show wal_buffers", ECPGt_EOIT,
+              ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 21 "show.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 21 "show.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 21 "show.pgc"
 
-  printf("Var: WAL buffers: %s\n", var);
+   printf("Var: WAL buffers: %s\n", var);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT, 
-   ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "show standard_conforming_strings", ECPGt_EOIT,
+              ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 24 "show.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 24 "show.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 24 "show.pgc"
 
-  printf("Var: Standard conforming strings: %s\n", var);
+   printf("Var: Standard conforming strings: %s\n", var);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "show time zone", ECPGt_EOIT, 
-   ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "show time zone", ECPGt_EOIT,
+              ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 27 "show.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 27 "show.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 27 "show.pgc"
 
-  printf("Time Zone: %s\n", var);
+   printf("Time Zone: %s\n", var);
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "show transaction isolation level", ECPGt_EOIT, 
-   ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "show transaction isolation level", ECPGt_EOIT,
+              ECPGt_char, (var), (long) 25, (long) 1, (25) * sizeof(char),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 30 "show.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 30 "show.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 30 "show.pgc"
 
-  printf("Transaction isolation level: %s\n", var);
+   printf("Transaction isolation level: %s\n", var);
 
-  /* Do not ask for the user name, it may differ in a regression test */
-  /* EXEC SQL SHOW SESSION AUTHORIZATION INTO :var; */
+   /* Do not ask for the user name, it may differ in a regression test */
+   /* EXEC SQL SHOW SESSION AUTHORIZATION INTO :var; */
 
-  { ECPGdisconnect(__LINE__, "ALL");
+   {
+       ECPGdisconnect(__LINE__, "ALL");
 #line 36 "show.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 36 "show.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 36 "show.pgc"
 
 
-  return 0;
+   return 0;
 }
index 39e4ddd6f60215de64b0d540ef639c71b1195a35..adfed5593dd17ebbab089554f8e4696c5f707c3a 100644 (file)
 #line 5 "update.pgc"
 
 
-int main(int argc, char* argv[]) {
-  /* exec sql begin declare section */
-     
-  
+int
+main(int argc, char *argv[])
+{
+   /* exec sql begin declare section */
+
+
 #line 9 "update.pgc"
- int  i1 [ 3 ]    ,  i2 [ 3 ]    ;
+   int         i1[3],
+               i2[3];
+
 /* exec sql end declare section */
 #line 10 "update.pgc"
 
 
-  ECPGdebug(1, stderr);
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   ECPGdebug(1, stderr);
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 13 "update.pgc"
 
 
-  /* exec sql whenever sql_warning  sqlprint ; */
+   /* exec sql whenever sql_warning  sqlprint ; */
 #line 15 "update.pgc"
 
-  /* exec sql whenever sqlerror  sqlprint ; */
+   /* exec sql whenever sqlerror  sqlprint ; */
 #line 16 "update.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a int   , b int   )    ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test ( a int   , b int   )    ", ECPGt_EOIT, ECPGt_EORT);
 #line 18 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 18 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 18 "update.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a  , b  ) values( 1 , 1 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a  , b  ) values( 1 , 1 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 20 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 20 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 20 "update.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a  , b  ) values( 2 , 2 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a  , b  ) values( 2 , 2 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 21 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 21 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 21 "update.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a  , b  ) values( 3 , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( a  , b  ) values( 3 , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
 #line 22 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 22 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 22 "update.pgc"
 
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "update test set a  = a + 1   ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "update test set a  = a + 1   ", ECPGt_EOIT, ECPGt_EORT);
 #line 24 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 24 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 24 "update.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "update test set ( a  , b  )=( 5 , 5 )  where a = 4 ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "update test set ( a  , b  )=( 5 , 5 )  where a = 4 ", ECPGt_EOIT, ECPGt_EORT);
 #line 25 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 25 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 25 "update.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "update test set a  = 4  where a = 3 ", ECPGt_EOIT, ECPGt_EORT);
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "update test set a  = 4  where a = 3 ", ECPGt_EOIT, ECPGt_EORT);
 #line 26 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 26 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 26 "update.pgc"
-;
-
-  { ECPGdo(__LINE__, 0, 1, NULL, "select  a , b  from test    order by a", ECPGt_EOIT, 
-   ECPGt_int,(i1),(long)1,(long)3,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,(i2),(long)1,(long)3,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+   ;
+
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  a , b  from test    order by a", ECPGt_EOIT,
+              ECPGt_int, (i1), (long) 1, (long) 3, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+              ECPGt_int, (i2), (long) 1, (long) 3, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
 #line 28 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 28 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 28 "update.pgc"
 
 
-  printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
+   printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
 
-  { ECPGdisconnect(__LINE__, "ALL");
+   {
+       ECPGdisconnect(__LINE__, "ALL");
 #line 32 "update.pgc"
 
-if (sqlca.sqlwarn[0] == 'W') sqlprint();
+       if (sqlca.sqlwarn[0] == 'W')
+           sqlprint();
 #line 32 "update.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 32 "update.pgc"
 
 
-  return 0;
+   return 0;
 }
index 96be500f6f13ff6d50b37097b1d3133cbad951b3..f2d4b3ff7af7a25cfcb0f580e9ea756762757d5d 100644 (file)
@@ -36,171 +36,215 @@ main(void)
 #line 19 "thread.pgc"
 
 
-void *test_thread(void *arg);
+void      *test_thread(void *arg);
 
-int nthreads   = 10;
-int iterations = 20;
+int            nthreads = 10;
+int            iterations = 20;
 
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
-  pthread_t *threads;
-  int n;
-  /* exec sql begin declare section */
-   
-  
+   pthread_t  *threads;
+   int         n;
+
+   /* exec sql begin declare section */
+
+
 #line 31 "thread.pgc"
- int  l_rows    ;
+   int         l_rows;
+
 /* exec sql end declare section */
 #line 32 "thread.pgc"
 
 
 
- /* Switch off debug output for regression tests. The threads get executed in
-  * more or less random order */
-  ECPGdebug(0, stderr);
+   /*
+    * Switch off debug output for regression tests. The threads get executed
+    * in more or less random order
+    */
+   ECPGdebug(0, stderr);
 
 
-  /* setup test_thread table */
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   /* setup test_thread table */
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 41 "thread.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 42 "thread.pgc"
- /* DROP might fail */
-  { ECPGtrans(__LINE__, NULL, "commit");}
+   /* DROP might fail */
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 43 "thread.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table test_thread ( tstamp timestamp    not null default cast( timeofday () as timestamp   ) , thread TEXT   not null , iteration integer   not null , primary key( thread , iteration )   )    ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test_thread ( tstamp timestamp    not null default cast( timeofday () as timestamp   ) , thread TEXT   not null , iteration integer   not null , primary key( thread , iteration )   )    ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 48 "thread.pgc"
 
-  { ECPGtrans(__LINE__, NULL, "commit");}
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 49 "thread.pgc"
 
-  { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 50 "thread.pgc"
 
 
-  /* create, and start, threads */
-  threads = calloc(nthreads, sizeof(pthread_t));
-  if( threads == NULL )
-    {
-      fprintf(stderr, "Cannot alloc memory\n");
-      return( 1 );
-    }
-  for( n = 0; n < nthreads; n++ )
-    {
-      pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
-    }
-
-  /* wait for thread completion */
-  for( n = 0; n < nthreads; n++ )
-    {
-      pthread_join(threads[n], NULL);
-    }
-  free(threads);
-
-  /* and check results */
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   /* create, and start, threads */
+   threads = calloc(nthreads, sizeof(pthread_t));
+   if (threads == NULL)
+   {
+       fprintf(stderr, "Cannot alloc memory\n");
+       return (1);
+   }
+   for (n = 0; n < nthreads; n++)
+   {
+       pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
+   }
+
+   /* wait for thread completion */
+   for (n = 0; n < nthreads; n++)
+   {
+       pthread_join(threads[n], NULL);
+   }
+   free(threads);
+
+   /* and check results */
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 72 "thread.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "select  count (*)  from test_thread   ", ECPGt_EOIT, 
-   ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  count (*)  from test_thread   ", ECPGt_EOIT,
+              ECPGt_int, &(l_rows), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 73 "thread.pgc"
 
-  { ECPGtrans(__LINE__, NULL, "commit");}
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 74 "thread.pgc"
 
-  { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 75 "thread.pgc"
 
-  if( l_rows == (nthreads * iterations) )
-    printf("Success.\n");
-  else
-    printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows);
+   if (l_rows == (nthreads * iterations))
+       printf("Success.\n");
+   else
+       printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows);
 
-  return( 0 );
+   return (0);
 }
 
-void *test_thread(void *arg)
+void *
+test_thread(void *arg)
 {
-  long threadnum = (long)arg;
-  /* exec sql begin declare section */
-    
-   
-  
+   long        threadnum = (long) arg;
+
+   /* exec sql begin declare section */
+
+
+
 #line 88 "thread.pgc"
int  l_i    ;
  int         l_i;
+
 #line 89 "thread.pgc"
- char  l_connection [ 128 ]    ;
+   char        l_connection[128];
+
 /* exec sql end declare section */
 #line 90 "thread.pgc"
 
 
-  /* build up connection name, and connect to database */
-  snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
-  /* exec sql whenever sqlerror  sqlprint ; */
+   /* build up connection name, and connect to database */
+   snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
+   /* exec sql whenever sqlerror  sqlprint ; */
 #line 94 "thread.pgc"
 
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , l_connection, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, l_connection, 0);
 #line 95 "thread.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 95 "thread.pgc"
 
-  if( sqlca.sqlcode != 0 )
-    {
-      printf("%s: ERROR: cannot connect to database!\n", l_connection);
-      return( NULL );
-    }
-  { ECPGtrans(__LINE__, l_connection, "begin transaction ");
+   if (sqlca.sqlcode != 0)
+   {
+       printf("%s: ERROR: cannot connect to database!\n", l_connection);
+       return (NULL);
+   }
+   {
+       ECPGtrans(__LINE__, l_connection, "begin transaction ");
 #line 101 "thread.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 101 "thread.pgc"
 
 
-  /* insert into test_thread table */
-  for( l_i = 1; l_i <= iterations; l_i++ )
-    {
+   /* insert into test_thread table */
+   for (l_i = 1; l_i <= iterations; l_i++)
+   {
 #ifdef DEBUG
-      printf("%s: inserting %d\n", l_connection, l_i);
+       printf("%s: inserting %d\n", l_connection, l_i);
 #endif
-      { ECPGdo(__LINE__, 0, 1, l_connection, "insert into test_thread ( thread  , iteration  ) values(  ? ,  ? ) ", 
-   ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+       {
+           ECPGdo(__LINE__, 0, 1, l_connection, "insert into test_thread ( thread  , iteration  ) values(  ? ,  ? ) ",
+                  ECPGt_char, (l_connection), (long) 128, (long) 1, (128) * sizeof(char),
+                  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+                  ECPGt_int, &(l_i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 109 "thread.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+           if (sqlca.sqlcode < 0)
+               sqlprint();
+       }
 #line 109 "thread.pgc"
 
 #ifdef DEBUG
-      if( sqlca.sqlcode == 0 )
-   printf("%s: insert done\n", l_connection);
-      else
-   printf("%s: ERROR: insert failed!\n", l_connection);
+       if (sqlca.sqlcode == 0)
+           printf("%s: insert done\n", l_connection);
+       else
+           printf("%s: ERROR: insert failed!\n", l_connection);
 #endif
-    }
+   }
 
-  /* all done */
-  { ECPGtrans(__LINE__, l_connection, "commit");
+   /* all done */
+   {
+       ECPGtrans(__LINE__, l_connection, "commit");
 #line 119 "thread.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 119 "thread.pgc"
 
-  { ECPGdisconnect(__LINE__, l_connection);
+   {
+       ECPGdisconnect(__LINE__, l_connection);
 #line 120 "thread.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 120 "thread.pgc"
 
 #ifdef DEBUG
-  printf("%s: done!\n", l_connection);
+   printf("%s: done!\n", l_connection);
 #endif
-  return( NULL );
+   return (NULL);
 }
-#endif /* ENABLE_THREAD_SAFETY */
+
+#endif   /* ENABLE_THREAD_SAFETY */
index b2a95d54006fadfca78a00b24df5b200e39c3449..f7bf6fab7632d7d8d97dcb560a903dd21e1a2e21 100644 (file)
@@ -37,171 +37,215 @@ main(void)
 #line 20 "thread_implicit.pgc"
 
 
-void *test_thread(void *arg);
+void      *test_thread(void *arg);
 
-int nthreads   = 10;
-int iterations = 20;
+int            nthreads = 10;
+int            iterations = 20;
 
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
-  pthread_t *threads;
-  int n;
-  /* exec sql begin declare section */
-   
-  
+   pthread_t  *threads;
+   int         n;
+
+   /* exec sql begin declare section */
+
+
 #line 32 "thread_implicit.pgc"
- int  l_rows    ;
+   int         l_rows;
+
 /* exec sql end declare section */
 #line 33 "thread_implicit.pgc"
 
 
 
- /* Switch off debug output for regression tests. The threads get executed in
-  * more or less random order */
-  ECPGdebug(0, stderr);
+   /*
+    * Switch off debug output for regression tests. The threads get executed
+    * in more or less random order
+    */
+   ECPGdebug(0, stderr);
 
 
-  /* setup test_thread table */
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   /* setup test_thread table */
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 42 "thread_implicit.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "drop table test_thread ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 43 "thread_implicit.pgc"
- /* DROP might fail */
-  { ECPGtrans(__LINE__, NULL, "commit");}
+   /* DROP might fail */
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 44 "thread_implicit.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "create  table test_thread ( tstamp timestamp    not null default cast( timeofday () as timestamp   ) , thread TEXT   not null , iteration integer   not null , primary key( thread , iteration )   )    ", ECPGt_EOIT, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "create  table test_thread ( tstamp timestamp    not null default cast( timeofday () as timestamp   ) , thread TEXT   not null , iteration integer   not null , primary key( thread , iteration )   )    ", ECPGt_EOIT, ECPGt_EORT);
+   }
 #line 49 "thread_implicit.pgc"
 
-  { ECPGtrans(__LINE__, NULL, "commit");}
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 50 "thread_implicit.pgc"
 
-  { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 51 "thread_implicit.pgc"
 
 
-  /* create, and start, threads */
-  threads = calloc(nthreads, sizeof(pthread_t));
-  if( threads == NULL )
-    {
-      fprintf(stderr, "Cannot alloc memory\n");
-      return( 1 );
-    }
-  for( n = 0; n < nthreads; n++ )
-    {
-      pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
-    }
-
-  /* wait for thread completion */
-  for( n = 0; n < nthreads; n++ )
-    {
-      pthread_join(threads[n], NULL);
-    }
-  free(threads);
-
-  /* and check results */
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
+   /* create, and start, threads */
+   threads = calloc(nthreads, sizeof(pthread_t));
+   if (threads == NULL)
+   {
+       fprintf(stderr, "Cannot alloc memory\n");
+       return (1);
+   }
+   for (n = 0; n < nthreads; n++)
+   {
+       pthread_create(&threads[n], NULL, test_thread, (void *) (n + 1));
+   }
+
+   /* wait for thread completion */
+   for (n = 0; n < nthreads; n++)
+   {
+       pthread_join(threads[n], NULL);
+   }
+   free(threads);
+
+   /* and check results */
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, NULL, 0);
+   }
 #line 73 "thread_implicit.pgc"
 
-  { ECPGdo(__LINE__, 0, 1, NULL, "select  count (*)  from test_thread   ", ECPGt_EOIT, 
-   ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+   {
+       ECPGdo(__LINE__, 0, 1, NULL, "select  count (*)  from test_thread   ", ECPGt_EOIT,
+              ECPGt_int, &(l_rows), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EORT);
+   }
 #line 74 "thread_implicit.pgc"
 
-  { ECPGtrans(__LINE__, NULL, "commit");}
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
+   }
 #line 75 "thread_implicit.pgc"
 
-  { ECPGdisconnect(__LINE__, "CURRENT");}
+   {
+       ECPGdisconnect(__LINE__, "CURRENT");
+   }
 #line 76 "thread_implicit.pgc"
 
-  if( l_rows == (nthreads * iterations) )
-    printf("Success.\n");
-  else
-    printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows);
+   if (l_rows == (nthreads * iterations))
+       printf("Success.\n");
+   else
+       printf("ERROR: Failure - expecting %d rows, got %d.\n", nthreads * iterations, l_rows);
 
-  return( 0 );
+   return (0);
 }
 
-void *test_thread(void *arg)
+void *
+test_thread(void *arg)
 {
-  long threadnum = (long)arg;
-  /* exec sql begin declare section */
-    
-   
-  
+   long        threadnum = (long) arg;
+
+   /* exec sql begin declare section */
+
+
+
 #line 89 "thread_implicit.pgc"
int  l_i    ;
  int         l_i;
+
 #line 90 "thread_implicit.pgc"
- char  l_connection [ 128 ]    ;
+   char        l_connection[128];
+
 /* exec sql end declare section */
 #line 91 "thread_implicit.pgc"
 
 
-  /* build up connection name, and connect to database */
-  snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
-  /* exec sql whenever sqlerror  sqlprint ; */
+   /* build up connection name, and connect to database */
+   snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
+   /* exec sql whenever sqlerror  sqlprint ; */
 #line 95 "thread_implicit.pgc"
 
-  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , l_connection, 0); 
+   {
+       ECPGconnect(__LINE__, 0, "regress1", NULL, NULL, l_connection, 0);
 #line 96 "thread_implicit.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 96 "thread_implicit.pgc"
 
-  if( sqlca.sqlcode != 0 )
-    {
-      printf("%s: ERROR: cannot connect to database!\n", l_connection);
-      return( NULL );
-    }
-  { ECPGtrans(__LINE__, NULL, "begin transaction ");
+   if (sqlca.sqlcode != 0)
+   {
+       printf("%s: ERROR: cannot connect to database!\n", l_connection);
+       return (NULL);
+   }
+   {
+       ECPGtrans(__LINE__, NULL, "begin transaction ");
 #line 102 "thread_implicit.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 102 "thread_implicit.pgc"
 
 
-  /* insert into test_thread table */
-  for( l_i = 1; l_i <= iterations; l_i++ )
-    {
+   /* insert into test_thread table */
+   for (l_i = 1; l_i <= iterations; l_i++)
+   {
 #ifdef DEBUG
-      printf("%s: inserting %d\n", l_connection, l_i);
+       printf("%s: inserting %d\n", l_connection, l_i);
 #endif
-      { ECPGdo(__LINE__, 0, 1, NULL, "insert into test_thread ( thread  , iteration  ) values(  ? ,  ? ) ", 
-   ECPGt_char,(l_connection),(long)128,(long)1,(128)*sizeof(char), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
-   ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int), 
-   ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+       {
+           ECPGdo(__LINE__, 0, 1, NULL, "insert into test_thread ( thread  , iteration  ) values(  ? ,  ? ) ",
+                  ECPGt_char, (l_connection), (long) 128, (long) 1, (128) * sizeof(char),
+                  ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L,
+                  ECPGt_int, &(l_i), (long) 1, (long) 1, sizeof(int),
+              ECPGt_NO_INDICATOR, NULL, 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
 #line 110 "thread_implicit.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+           if (sqlca.sqlcode < 0)
+               sqlprint();
+       }
 #line 110 "thread_implicit.pgc"
 
 #ifdef DEBUG
-      if( sqlca.sqlcode == 0 )
-   printf("%s: insert done\n", l_connection);
-      else
-   printf("%s: ERROR: insert failed!\n", l_connection);
+       if (sqlca.sqlcode == 0)
+           printf("%s: insert done\n", l_connection);
+       else
+           printf("%s: ERROR: insert failed!\n", l_connection);
 #endif
-    }
+   }
 
-  /* all done */
-  { ECPGtrans(__LINE__, NULL, "commit");
+   /* all done */
+   {
+       ECPGtrans(__LINE__, NULL, "commit");
 #line 120 "thread_implicit.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 120 "thread_implicit.pgc"
 
-  { ECPGdisconnect(__LINE__, l_connection);
+   {
+       ECPGdisconnect(__LINE__, l_connection);
 #line 121 "thread_implicit.pgc"
 
-if (sqlca.sqlcode < 0) sqlprint();}
+       if (sqlca.sqlcode < 0)
+           sqlprint();
+   }
 #line 121 "thread_implicit.pgc"
 
 #ifdef DEBUG
-  printf("%s: done!\n", l_connection);
+   printf("%s: done!\n", l_connection);
 #endif
-  return( NULL );
+   return (NULL);
 }
-#endif /* ENABLE_THREAD_SAFETY */
+
+#endif   /* ENABLE_THREAD_SAFETY */
index bcc4c570bf555aa4e9787697a10d315476790fb3..7725f52f35456b1b9f4146744c6a316a7dd83cb9 100644 (file)
@@ -10,7 +10,7 @@
  * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.120 2006/09/22 21:39:58 tgl Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.121 2006/10/04 00:30:12 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -100,7 +100,7 @@ pg_an_to_ln(char *aname)
  * Various krb5 state which is not connection specific, and a flag to
  * indicate whether we have initialised it yet.
  */
-/* 
+/*
 static int pg_krb5_initialised;
 static krb5_context pg_krb5_context;
 static krb5_ccache pg_krb5_ccache;
@@ -110,16 +110,16 @@ static char *pg_krb5_name;
 
 struct krb5_info
 {
-   int     pg_krb5_initialised;
-   krb5_context    pg_krb5_context;
-   krb5_ccache pg_krb5_ccache;
-   krb5_principal  pg_krb5_client;
-   char        *pg_krb5_name;
+   int         pg_krb5_initialised;
+   krb5_context pg_krb5_context;
+   krb5_ccache pg_krb5_ccache;
+   krb5_principal pg_krb5_client;
+   char       *pg_krb5_name;
 };
 
 
 static int
-pg_krb5_init(char *PQerrormsg, struct krb5_info *info)
+pg_krb5_init(char *PQerrormsg, struct krb5_info * info)
 {
    krb5_error_code retval;
 
@@ -175,8 +175,8 @@ pg_krb5_init(char *PQerrormsg, struct krb5_info *info)
    return STATUS_OK;
 }
 
-static void 
-pg_krb5_destroy(struct krb5_info *info)
+static void
+pg_krb5_destroy(struct krb5_info * info)
 {
    krb5_free_principal(info->pg_krb5_context, info->pg_krb5_client);
    krb5_cc_close(info->pg_krb5_context, info->pg_krb5_ccache);
@@ -193,8 +193,9 @@ pg_krb5_destroy(struct krb5_info *info)
 static char *
 pg_krb5_authname(char *PQerrormsg)
 {
-   char *tmp_name;
+   char       *tmp_name;
    struct krb5_info info;
+
    info.pg_krb5_initialised = 0;
 
    if (pg_krb5_init(PQerrormsg, &info) != STATUS_OK)
@@ -219,6 +220,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s
    krb5_auth_context auth_context = NULL;
    krb5_error *err_ret = NULL;
    struct krb5_info info;
+
    info.pg_krb5_initialised = 0;
 
    if (!hostname)
@@ -519,7 +521,7 @@ char *
 pg_fe_getauthname(char *PQerrormsg)
 {
 #ifdef KRB5
-   char       *krb5_name = NULL;
+   char       *krb5_name = NULL;
 #endif
    const char *name = NULL;
    char       *authn;
@@ -545,10 +547,12 @@ pg_fe_getauthname(char *PQerrormsg)
    pglock_thread();
 
 #ifdef KRB5
-   /* pg_krb5_authname gives us a strdup'd value that we need
-    * to free later, however, we don't want to free 'name' directly
-    * in case it's *not* a Kerberos login and we fall through to
-    * name = pw->pw_name; */
+
+   /*
+    * pg_krb5_authname gives us a strdup'd value that we need to free later,
+    * however, we don't want to free 'name' directly in case it's *not* a
+    * Kerberos login and we fall through to name = pw->pw_name;
+    */
    krb5_name = pg_krb5_authname(PQerrormsg);
    name = krb5_name;
 #endif
@@ -583,7 +587,7 @@ pg_fe_getauthname(char *PQerrormsg)
  *
  * This is intended to be used by client applications that wish to send
  * commands like ALTER USER joe PASSWORD 'pwd'.  The password need not
- * be sent in cleartext if it is encrypted on the client side.  This is
+ * be sent in cleartext if it is encrypted on the client side. This is
  * good because it ensures the cleartext password won't end up in logs,
  * pg_stat displays, etc.  We export the function so that clients won't
  * be dependent on low-level details like whether the enceyption is MD5
index 0dca43803f1bec78164c2cd0b57114a1bb1b4548..fd08023aae79982889a8e5e7aeb797955fe40967 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.336 2006/09/27 15:41:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.337 2006/10/04 00:30:12 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -66,7 +66,7 @@
 typedef struct timeval LDAP_TIMEVAL;
 #endif
 static int ldapServiceLookup(const char *purl, PQconninfoOption *options,
-                            PQExpBuffer errorMessage);
+                 PQExpBuffer errorMessage);
 #endif
 
 #include "libpq/ip.h"
@@ -513,9 +513,9 @@ connectOptions2(PGconn *conn)
        conn->sslmode = strdup(DefaultSSLMode);
 
    /*
-    * Only if we get this far is it appropriate to try to connect.
-    * (We need a state flag, rather than just the boolean result of
-    * this function, in case someone tries to PQreset() the PGconn.)
+    * Only if we get this far is it appropriate to try to connect. (We need a
+    * state flag, rather than just the boolean result of this function, in
+    * case someone tries to PQreset() the PGconn.)
     */
    conn->options_valid = true;
 
@@ -2385,13 +2385,31 @@ static int
 ldapServiceLookup(const char *purl, PQconninfoOption *options,
                  PQExpBuffer errorMessage)
 {
-   int         port = LDAP_DEF_PORT, scope, rc, msgid, size, state, oldstate, i;
+   int         port = LDAP_DEF_PORT,
+               scope,
+               rc,
+               msgid,
+               size,
+               state,
+               oldstate,
+               i;
    bool        found_keyword;
-   char       *url, *hostname, *portstr, *endptr, *dn, *scopestr, *filter,
-              *result, *p, *p1 = NULL, *optname = NULL, *optval = NULL;
+   char       *url,
+              *hostname,
+              *portstr,
+              *endptr,
+              *dn,
+              *scopestr,
+              *filter,
+              *result,
+              *p,
+              *p1 = NULL,
+              *optname = NULL,
+              *optval = NULL;
    char       *attrs[2] = {NULL, NULL};
    LDAP       *ld = NULL;
-   LDAPMessage *res, *entry;
+   LDAPMessage *res,
+              *entry;
    struct berval **values;
    LDAP_TIMEVAL time = {PGLDAP_TIMEOUT, 0};
 
@@ -2402,9 +2420,9 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
    }
 
    /*
-    *  Parse URL components, check for correctness.  Basically, url has
-    *  '\0' placed at component boundaries and variables are pointed
-    *  at each component.
+    * Parse URL components, check for correctness.  Basically, url has '\0'
+    * placed at component boundaries and variables are pointed at each
+    * component.
     */
 
    if (pg_strncasecmp(url, LDAP_URL, strlen(LDAP_URL)) != 0)
@@ -2417,26 +2435,26 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
 
    /* hostname */
    hostname = url + strlen(LDAP_URL);
-   if (*hostname == '/')   /* no hostname? */
-       hostname = "localhost"; /* the default */
+   if (*hostname == '/')       /* no hostname? */
+       hostname = "localhost"; /* the default */
 
    /* dn, "distinguished name" */
-   p = strchr(url +  strlen(LDAP_URL), '/');
+   p = strchr(url + strlen(LDAP_URL), '/');
    if (p == NULL || *(p + 1) == '\0' || *(p + 1) == '?')
    {
        printfPQExpBuffer(errorMessage, libpq_gettext(
-                       "bad LDAP URL \"%s\": missing distinguished name\n"), purl);
+                "bad LDAP URL \"%s\": missing distinguished name\n"), purl);
        free(url);
        return 3;
    }
-   *p = '\0';  /* terminate hostname */
+   *p = '\0';                  /* terminate hostname */
    dn = p + 1;
 
    /* attribute */
    if ((p = strchr(dn, '?')) == NULL || *(p + 1) == '\0' || *(p + 1) == '?')
    {
        printfPQExpBuffer(errorMessage, libpq_gettext(
-                           "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl);
+           "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl);
        free(url);
        return 3;
    }
@@ -2447,7 +2465,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
    if ((p = strchr(attrs[0], '?')) == NULL || *(p + 1) == '\0' || *(p + 1) == '?')
    {
        printfPQExpBuffer(errorMessage, libpq_gettext(
-                           "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl);
+                                                     "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl);
        free(url);
        return 3;
    }
@@ -2479,7 +2497,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
        if (*portstr == '\0' || *endptr != '\0' || errno || lport < 0 || lport > 65535)
        {
            printfPQExpBuffer(errorMessage, libpq_gettext(
-                           "bad LDAP URL \"%s\": invalid port number\n"), purl);
+                       "bad LDAP URL \"%s\": invalid port number\n"), purl);
            free(url);
            return 3;
        }
@@ -2490,7 +2508,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
    if (strchr(attrs[0], ',') != NULL)
    {
        printfPQExpBuffer(errorMessage, libpq_gettext(
-                           "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl);
+           "bad LDAP URL \"%s\": must have exactly one attribute\n"), purl);
        free(url);
        return 3;
    }
@@ -2505,7 +2523,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
    else
    {
        printfPQExpBuffer(errorMessage, libpq_gettext(
-                   "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl);
+                                                     "bad LDAP URL \"%s\": must have search scope (base/one/sub)\n"), purl);
        free(url);
        return 3;
    }
@@ -2520,8 +2538,8 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
    }
 
    /*
-    *  Initialize connection to the server.  We do an explicit bind because
-    *  we want to return 2 if the bind fails.
+    * Initialize connection to the server.  We do an explicit bind because we
+    * want to return 2 if the bind fails.
     */
    if ((msgid = ldap_simple_bind(ld, NULL, NULL)) == -1)
    {
@@ -2655,8 +2673,8 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
                else if (ld_is_nl_cr(*p))
                {
                    printfPQExpBuffer(errorMessage, libpq_gettext(
-                               "missing \"=\" after \"%s\" in connection info string\n"),
-                                 optname);
+                   "missing \"=\" after \"%s\" in connection info string\n"),
+                                     optname);
                    return 3;
                }
                else if (*p == '=')
@@ -2673,8 +2691,8 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
                else if (!ld_is_sp_tab(*p))
                {
                    printfPQExpBuffer(errorMessage, libpq_gettext(
-                               "missing \"=\" after \"%s\" in connection info string\n"),
-                                 optname);
+                   "missing \"=\" after \"%s\" in connection info string\n"),
+                                     optname);
                    return 3;
                }
                break;
@@ -2737,7 +2755,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
            {
                printfPQExpBuffer(errorMessage,
                         libpq_gettext("invalid connection option \"%s\"\n"),
-                         optname);
+                                 optname);
                return 1;
            }
            optname = NULL;
@@ -2749,7 +2767,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
    if (state == 5 || state == 6)
    {
        printfPQExpBuffer(errorMessage, libpq_gettext(
-                       "unterminated quoted string in connection info string\n"));
+                 "unterminated quoted string in connection info string\n"));
        return 3;
    }
 
@@ -2854,7 +2872,8 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
 #ifdef USE_LDAP
                    if (strncmp(line, "ldap", 4) == 0)
                    {
-                       int rc = ldapServiceLookup(line, options, errorMessage);
+                       int         rc = ldapServiceLookup(line, options, errorMessage);
+
                        /* if rc = 2, go on reading for fallback */
                        switch (rc)
                        {
@@ -3376,10 +3395,10 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
    else
    {
        /*
-        * In protocol 2 we have to assume the setting will stick, and
-        * adjust our state immediately.  In protocol 3 and up we can
-        * rely on the backend to report the parameter value, and we'll
-        * change state at that time.
+        * In protocol 2 we have to assume the setting will stick, and adjust
+        * our state immediately.  In protocol 3 and up we can rely on the
+        * backend to report the parameter value, and we'll change state at
+        * that time.
         */
        if (PG_PROTOCOL_MAJOR(conn->pversion) < 3)
            pqSaveParameterStatus(conn, "client_encoding", encoding);
@@ -3547,14 +3566,14 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
    if (hostname == NULL)
        hostname = DefaultHost;
    else if (is_absolute_path(hostname))
+
        /*
-        *  We should probably use canonicalize_path(), but then
-        *  we have to bring path.c into libpq, and it doesn't
-        *  seem worth it.
+        * We should probably use canonicalize_path(), but then we have to
+        * bring path.c into libpq, and it doesn't seem worth it.
         */
        if (strcmp(hostname, DEFAULT_PGSOCKET_DIR) == 0)
            hostname = DefaultHost;
-   
+
    if (port == NULL)
        port = DEF_PGPORT_STR;
 
index 71d9c02eb1ed79085eabb10069d7cd60fa7af845..5a7adb2ff8b4f6d645d0d19de7c19371087bc54d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.190 2006/08/18 19:52:39 tgl Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.191 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -45,7 +45,7 @@ char     *const pgresStatus[] = {
  * values that result in backward-compatible behavior
  */
 static int static_client_encoding = PG_SQL_ASCII;
-static bool    static_std_strings = false;
+static bool static_std_strings = false;
 
 
 static bool PQsendQueryStart(PGconn *conn);
@@ -61,8 +61,8 @@ static int PQsendQueryGuts(PGconn *conn,
 static void parseInput(PGconn *conn);
 static bool PQexecStart(PGconn *conn);
 static PGresult *PQexecFinish(PGconn *conn);
-static int PQsendDescribe(PGconn *conn, char desc_type,
-                          const char *desc_target);
+static int PQsendDescribe(PGconn *conn, char desc_type,
+              const char *desc_target);
 
 
 /* ----------------
@@ -626,11 +626,11 @@ pqSaveParameterStatus(PGconn *conn, const char *name, const char *value)
    }
 
    /*
-    * Special hacks: remember client_encoding and standard_conforming_strings,
-    * and convert server version to a numeric form.  We keep the first two of
-    * these in static variables as well, so that PQescapeString and
-    * PQescapeBytea can behave somewhat sanely (at least in single-
-    * connection-using programs).
+    * Special hacks: remember client_encoding and
+    * standard_conforming_strings, and convert server version to a numeric
+    * form.  We keep the first two of these in static variables as well, so
+    * that PQescapeString and PQescapeBytea can behave somewhat sanely (at
+    * least in single- connection-using programs).
     */
    if (strcmp(name, "client_encoding") == 0)
    {
@@ -1483,7 +1483,7 @@ PQexecFinish(PGconn *conn)
  * If the query was not even sent, return NULL; conn->errorMessage is set to
  * a relevant message.
  * If the query was sent, a new PGresult is returned (which could indicate
- * either success or failure).  On success, the PGresult contains status
+ * either success or failure). On success, the PGresult contains status
  * PGRES_COMMAND_OK, and its parameter and column-heading fields describe
  * the statement's inputs and outputs respectively.
  * The user is responsible for freeing the PGresult via PQclear()
@@ -1549,8 +1549,8 @@ PQsendDescribePortal(PGconn *conn, const char *portal)
  *  Common code to send a Describe command
  *
  * Available options for desc_type are
- *   'S' to describe a prepared statement; or
- *   'P' to describe a portal.
+ *  'S' to describe a prepared statement; or
+ *  'P' to describe a portal.
  * Returns 1 on success and 0 on failure.
  */
 static int
@@ -1661,11 +1661,11 @@ PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
 
    /*
     * Process any NOTICE or NOTIFY messages that might be pending in the
-    * input buffer.  Since the server might generate many notices during
-    * the COPY, we want to clean those out reasonably promptly to prevent
-    * indefinite expansion of the input buffer.  (Note: the actual read
-    * of input data into the input buffer happens down inside pqSendSome,
-    * but it's not authorized to get rid of the data again.)
+    * input buffer.  Since the server might generate many notices during the
+    * COPY, we want to clean those out reasonably promptly to prevent
+    * indefinite expansion of the input buffer.  (Note: the actual read of
+    * input data into the input buffer happens down inside pqSendSome, but
+    * it's not authorized to get rid of the data again.)
     */
    parseInput(conn);
 
@@ -2134,7 +2134,7 @@ check_param_number(const PGresult *res, int param_num)
                         param_num, res->numParameters - 1);
        return FALSE;
    }
-   
+
    return TRUE;
 }
 
@@ -2377,7 +2377,8 @@ PQoidValue(const PGresult *res)
 char *
 PQcmdTuples(PGresult *res)
 {
-   char       *p, *c;
+   char       *p,
+              *c;
 
    if (!res)
        return "";
@@ -2389,7 +2390,7 @@ PQcmdTuples(PGresult *res)
        while (*p && *p != ' ')
            p++;
        if (*p == 0)
-           goto interpret_error;               /* no space? */
+           goto interpret_error;       /* no space? */
        p++;
    }
    else if (strncmp(res->cmdStatus, "DELETE ", 7) == 0 ||
@@ -2413,7 +2414,7 @@ PQcmdTuples(PGresult *res)
        goto interpret_error;
 
    return p;
-   
+
 interpret_error:
    pqInternalNotice(&res->noticeHooks,
                     "could not interpret result from server: %s",
@@ -2462,7 +2463,7 @@ PQgetisnull(const PGresult *res, int tup_num, int field_num)
 }
 
 /* PQnparams:
- *     returns the number of input parameters of a prepared statement.
+ * returns the number of input parameters of a prepared statement.
  */
 int
 PQnparams(const PGresult *res)
@@ -2473,7 +2474,7 @@ PQnparams(const PGresult *res)
 }
 
 /* PQparamtype:
- *     returns type Oid of the specified statement parameter.
+ * returns type Oid of the specified statement parameter.
  */
 Oid
 PQparamtype(const PGresult *res, int param_num)
@@ -2612,9 +2613,9 @@ PQescapeStringInternal(PGconn *conn,
 
    while (remaining > 0 && *source != '\0')
    {
-       char    c = *source;
-       int     len;
-       int     i;
+       char        c = *source;
+       int         len;
+       int         i;
 
        /* Fast path for plain ASCII */
        if (!IS_HIGHBIT_SET(c))
@@ -2643,9 +2644,9 @@ PQescapeStringInternal(PGconn *conn,
 
        /*
         * If we hit premature end of string (ie, incomplete multibyte
-        * character), try to pad out to the correct length with spaces.
-        * We may not be able to pad completely, but we will always be able
-        * to insert at least one pad space (since we'd not have quoted a
+        * character), try to pad out to the correct length with spaces. We
+        * may not be able to pad completely, but we will always be able to
+        * insert at least one pad space (since we'd not have quoted a
         * multibyte character).  This should be enough to make a string that
         * the server will error out on.
         */
@@ -2655,7 +2656,7 @@ PQescapeStringInternal(PGconn *conn,
                *error = 1;
            if (conn)
                printfPQExpBuffer(&conn->errorMessage,
-                       libpq_gettext("incomplete multibyte character\n"));
+                         libpq_gettext("incomplete multibyte character\n"));
            for (; i < len; i++)
            {
                if (((size_t) (target - to)) / 2 >= length)
index 998a5648992766db6a58f9b27a4953b9a0953d82..10e8a91ed3e488e2cf8d263b0bab576bc35b28e3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.59 2006/09/07 15:37:25 momjian Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.60 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -479,10 +479,10 @@ lo_import(PGconn *conn, const char *filename)
        if (tmp != nbytes)
        {
            /*
-            * If lo_write() failed, we are now in an aborted transaction
-            * so there's no need for lo_close(); furthermore, if we tried
-            * it we'd overwrite the useful error result with a useless one.
-            * So just nail the doors shut and get out of town.
+            * If lo_write() failed, we are now in an aborted transaction so
+            * there's no need for lo_close(); furthermore, if we tried it
+            * we'd overwrite the useful error result with a useless one. So
+            * just nail the doors shut and get out of town.
             */
            (void) close(fd);
            return InvalidOid;
@@ -492,7 +492,7 @@ lo_import(PGconn *conn, const char *filename)
    if (nbytes < 0)
    {
        printfPQExpBuffer(&conn->errorMessage,
-                       libpq_gettext("could not read from file \"%s\": %s\n"),
+                     libpq_gettext("could not read from file \"%s\": %s\n"),
                          filename, pqStrerror(errno, sebuf, sizeof(sebuf)));
        lobjOid = InvalidOid;
    }
@@ -565,10 +565,10 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
    }
 
    /*
-    * If lo_read() failed, we are now in an aborted transaction
-    * so there's no need for lo_close(); furthermore, if we tried
-    * it we'd overwrite the useful error result with a useless one.
-    * So skip lo_close() if we got a failure result.
+    * If lo_read() failed, we are now in an aborted transaction so there's no
+    * need for lo_close(); furthermore, if we tried it we'd overwrite the
+    * useful error result with a useless one. So skip lo_close() if we got a
+    * failure result.
     */
    if (nbytes < 0 ||
        lo_close(conn, lobj) != 0)
index 2c76dfdde36dea8bf0187260d7bb0b3b69c09d94..635c3f0674d1080412f88b343c359ceccd6e4d5e 100644 (file)
@@ -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.129 2006/07/14 05:28:29 tgl Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.130 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -62,7 +62,7 @@
 
 static int pqPutMsgBytes(const void *buf, size_t len, PGconn *conn);
 static int pqSendSome(PGconn *conn, int len);
-static int pqSocketCheck(PGconn *conn, int forRead, int forWrite,
+static int pqSocketCheck(PGconn *conn, int forRead, int forWrite,
              time_t end_time);
 static int pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time);
 
index 0ecbcf4ad0359bb54c4de58b9ac5da7cb1c8a6c4..9ae7a1fa076450fa88410b3c78dafcd3153f32e1 100644 (file)
@@ -10,7 +10,7 @@
  * didn't really belong there.
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.72 2006/07/14 16:59:19 tgl Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.73 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -276,7 +276,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
                {
                    if (po->caption)
                        fprintf(fout,
-                             "%s\n",
+                          "%s\n",
                                po->tableOpt ? po->tableOpt : "",
                                po->caption);
                    else
index 1feae23a4375b273dd5bd284833a986b9e0bb6c6..8f75577c859623dc06d024b9be6a86293c7601a3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.28 2006/10/01 22:25:48 tgl Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.29 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -52,7 +52,7 @@ static int    getNotify(PGconn *conn);
 static int getCopyStart(PGconn *conn, ExecStatusType copytype);
 static int getReadyForQuery(PGconn *conn);
 static void reportErrorPosition(PQExpBuffer msg, const char *query,
-                               int loc, int encoding);
+                   int loc, int encoding);
 static int build_startup_packet(const PGconn *conn, char *packet,
                     const PQEnvironmentOption *options);
 
@@ -270,9 +270,10 @@ pqParseInput3(PGconn *conn)
                        /* First 'T' in a query sequence */
                        if (getRowDescriptions(conn))
                            return;
+
                        /*
-                        * If we're doing a Describe, we're ready to pass
-                        * the result back to the client.
+                        * If we're doing a Describe, we're ready to pass the
+                        * result back to the client.
                         */
                        if (conn->queryclass == PGQUERY_DESCRIBE)
                            conn->asyncStatus = PGASYNC_READY;
@@ -301,9 +302,10 @@ pqParseInput3(PGconn *conn)
                    if (conn->result == NULL)
                        conn->result = PQmakeEmptyPGresult(conn,
                                                           PGRES_COMMAND_OK);
+
                    /*
-                    * If we're doing a Describe, we're ready to pass
-                    * the result back to the client.
+                    * If we're doing a Describe, we're ready to pass the
+                    * result back to the client.
                     */
                    if (conn->queryclass == PGQUERY_DESCRIBE)
                        conn->asyncStatus = PGASYNC_READY;
@@ -443,9 +445,9 @@ getRowDescriptions(PGconn *conn)
    int         i;
 
    /*
-    * When doing Describe for a prepared statement, there'll already be
-    * a PGresult created by getParamDescriptions, and we should fill
-    * data into that.  Otherwise, create a new, empty PGresult.
+    * When doing Describe for a prepared statement, there'll already be a
+    * PGresult created by getParamDescriptions, and we should fill data into
+    * that.  Otherwise, create a new, empty PGresult.
     */
    if (conn->queryclass == PGQUERY_DESCRIBE)
    {
@@ -527,14 +529,15 @@ getRowDescriptions(PGconn *conn)
    return 0;
 
 failure:
+
    /*
     * Discard incomplete result, unless it's from getParamDescriptions.
     *
     * Note that if we hit a bufferload boundary while handling the
     * describe-statement case, we'll forget any PGresult space we just
-    * allocated, and then reallocate it on next try.  This will bloat
-    * the PGresult a little bit but the space will be freed at PQclear,
-    * so it doesn't seem worth trying to be smarter.
+    * allocated, and then reallocate it on next try.  This will bloat the
+    * PGresult a little bit but the space will be freed at PQclear, so it
+    * doesn't seem worth trying to be smarter.
     */
    if (result != conn->result)
        PQclear(result);
@@ -553,10 +556,10 @@ failure:
 static int
 getParamDescriptions(PGconn *conn)
 {
-   PGresult    *result;
-   int          nparams;
-   int          i;
-   
+   PGresult   *result;
+   int         nparams;
+   int         i;
+
    result = PQmakeEmptyPGresult(conn, PGRES_COMMAND_OK);
    if (!result)
        goto failure;
@@ -580,8 +583,8 @@ getParamDescriptions(PGconn *conn)
    /* get parameter info */
    for (i = 0; i < nparams; i++)
    {
-       int     typid;
-       
+       int         typid;
+
        if (pqGetInt(&typid, 4, conn))
            goto failure;
        result->paramDescs[i].typid = typid;
@@ -910,7 +913,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding)
    /*
     * 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
+    * 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.
     */
@@ -936,13 +939,13 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding)
    mb_encoding = (pg_encoding_max_length(encoding) != 1);
 
    /*
-    * Within the scanning loop, cno is the current character's logical number,
-    * qoffset is its offset in wquery, and scroffset is its starting logical
-    * screen column (all indexed from 0).  "loc" is the logical character
-    * number of the error location.  We scan to determine loc_line (the
-    * 1-based line number containing loc) and ibeg/iend (first character
-    * number and last+1 character number of the line containing loc).
-    * Note that qidx[] and scridx[] are filled only as far as iend.
+    * Within the scanning loop, cno is the current character's logical
+    * number, qoffset is its offset in wquery, and scroffset is its starting
+    * logical screen column (all indexed from 0).  "loc" is the logical
+    * character number of the error location.  We scan to determine loc_line
+    * (the 1-based line number containing loc) and ibeg/iend (first character
+    * number and last+1 character number of the line containing loc). Note
+    * that qidx[] and scridx[] are filled only as far as iend.
     */
    qoffset = 0;
    scroffset = 0;
@@ -952,7 +955,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding)
 
    for (cno = 0; wquery[qoffset] != '\0'; cno++)
    {
-       char    ch = wquery[qoffset];
+       char        ch = wquery[qoffset];
 
        qidx[cno] = qoffset;
        scridx[cno] = scroffset;
@@ -966,8 +969,8 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding)
            wquery[qoffset] = ' ';
 
        /*
-        * If end-of-line, count lines and mark positions. Each \r or \n counts
-        * as a line except when \r \n appear together.
+        * If end-of-line, count lines and mark positions. Each \r or \n
+        * counts as a line except when \r \n appear together.
         */
        else if (ch == '\r' || ch == '\n')
        {
@@ -992,7 +995,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding)
        /* Advance */
        if (mb_encoding)
        {
-           int     w;
+           int         w;
 
            w = pg_encoding_dsplen(encoding, &wquery[qoffset]);
            /* treat any non-tab control chars as width 1 */
@@ -1069,7 +1072,7 @@ reportErrorPosition(PQExpBuffer msg, const char *query, int loc, int encoding)
        scroffset = 0;
        for (; i < msg->len; i += pg_encoding_mblen(encoding, &msg->data[i]))
        {
-           int     w = pg_encoding_dsplen(encoding, &msg->data[i]);
+           int         w = pg_encoding_dsplen(encoding, &msg->data[i]);
 
            if (w <= 0)
                w = 1;
index d886179f6d2365ee4243b3927ba260a02025b29b..859df9acf87704b84f198acc284b8758b8fda768 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.87 2006/09/27 15:41:24 tgl Exp $
+ *   $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.88 2006/10/04 00:30:13 momjian Exp $
  *
  * NOTES
  *   [ Most of these notes are wrong/obsolete, but perhaps not all ]
@@ -782,7 +782,7 @@ initialize_SSL(PGconn *conn)
        if (stat(fnbuf, &buf) == 0)
        {
            X509_STORE *cvstore;
-           
+
            if (!SSL_CTX_load_verify_locations(SSL_context, fnbuf, NULL))
            {
                char       *err = SSLerrmessage();
@@ -800,13 +800,13 @@ initialize_SSL(PGconn *conn)
                if (X509_STORE_load_locations(cvstore, ROOT_CRL_FILE, NULL) != 0)
 /* OpenSSL 0.96 does not support X509_V_FLAG_CRL_CHECK */
 #ifdef X509_V_FLAG_CRL_CHECK
-                  X509_STORE_set_flags(cvstore,
-                               X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL);
+                   X509_STORE_set_flags(cvstore,
+                         X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
                /* if not found, silently ignore;  we do not require CRL */
 #else
                {
                    char       *err = SSLerrmessage();
-   
+
                    printfPQExpBuffer(&conn->errorMessage,
                                      libpq_gettext("Installed SSL library does not support CRL certificates, file \"%s\"\n"),
                                      fnbuf);
@@ -815,7 +815,7 @@ initialize_SSL(PGconn *conn)
                }
 #endif
            }
-   
+
            SSL_CTX_set_verify(SSL_context, SSL_VERIFY_PEER, verify_cb);
        }
    }
index 135791a4f1e8ea2770e447a67db2362bd8fd8135..daa29cc3b128644188cc9f14ba0055db64dcf194 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.133 2006/09/07 15:37:25 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.134 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -410,8 +410,8 @@ extern int  PQnparams(const PGresult *res);
 extern Oid PQparamtype(const PGresult *res, int param_num);
 
 /* Describe prepared statements and portals */
-extern PGresult    *PQdescribePrepared(PGconn *conn, const char *stmt);
-extern PGresult    *PQdescribePortal(PGconn *conn, const char *portal);
+extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
+extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
 extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);
 extern int PQsendDescribePortal(PGconn *conn, const char *portal);
 
@@ -437,13 +437,14 @@ extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
 
 /* Quoting strings before inclusion in queries. */
 extern size_t PQescapeStringConn(PGconn *conn,
-                                char *to, const char *from, size_t length,
-                                int *error);
+                  char *to, const char *from, size_t length,
+                  int *error);
 extern unsigned char *PQescapeByteaConn(PGconn *conn,
                  const unsigned char *from, size_t from_length,
                  size_t *to_length);
 extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
                size_t *retbuflen);
+
 /* These forms are deprecated! */
 extern size_t PQescapeString(char *to, const char *from, size_t length);
 extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
index e3532fbf6f1f9f6eb4ab6c0a1b174e7268b1e7dc..e69200f5af9974e249c97415b5ae04b9b9d1a7e0 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.115 2006/08/18 19:52:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.116 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -285,7 +285,7 @@ struct pg_conn
    /* Status indicators */
    ConnStatusType status;
    PGAsyncStatusType asyncStatus;
-   PGTransactionStatusType xactStatus;     /* never changes to ACTIVE */
+   PGTransactionStatusType xactStatus; /* never changes to ACTIVE */
    PGQueryClass queryclass;
    char       *last_query;     /* last SQL command, or NULL if unknown */
    bool        options_valid;  /* true if OK to attempt connection */
index 2867aba2d55675dfd75a25a90a6a0788d82c29bd..a4ec2ebb70c9849a176d67e51c38b500bbe81c9c 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "win32.h"
 
-/* Declared here to avoid pulling in all includes, which causes name collissions */ 
+/* Declared here to avoid pulling in all includes, which causes name collissions */
 #ifdef ENABLE_NLS
 extern char *
 libpq_gettext(const char *msgid)
index 0906d3186acd78956ab331a6697500168ffa376f..d683e42cf546f3beb35045446b21aa28d319cd87 100644 (file)
@@ -1,7 +1,7 @@
 /**********************************************************************
  * plperl.c - perl as a procedural language for PostgreSQL
  *
- *   $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.118 2006/08/27 23:47:58 tgl Exp $
+ *   $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.119 2006/10/04 00:30:13 momjian Exp $
  *
  **********************************************************************/
 
@@ -64,11 +64,11 @@ typedef struct plperl_proc_desc
 typedef struct plperl_call_data
 {
    plperl_proc_desc *prodesc;
-   FunctionCallInfo  fcinfo;
-   Tuplestorestate  *tuple_store;
-   TupleDesc         ret_tdesc;
-   AttInMetadata    *attinmeta;
-   MemoryContext     tmp_cxt;
+   FunctionCallInfo fcinfo;
+   Tuplestorestate *tuple_store;
+   TupleDesc   ret_tdesc;
+   AttInMetadata *attinmeta;
+   MemoryContext tmp_cxt;
 } plperl_call_data;
 
 /**********************************************************************
@@ -244,13 +244,13 @@ plperl_init_interp(void)
 
 #ifdef WIN32
 
-   /* 
+   /*
     * The perl library on startup does horrible things like call
-    * setlocale(LC_ALL,""). We have protected against that on most
-    * platforms by setting the environment appropriately. However, on
-    * Windows, setlocale() does not consult the environment, so we need
-    * to save the existing locale settings before perl has a chance to 
-    * mangle them and restore them after its dirty deeds are done.
+    * setlocale(LC_ALL,""). We have protected against that on most platforms
+    * by setting the environment appropriately. However, on Windows,
+    * setlocale() does not consult the environment, so we need to save the
+    * existing locale settings before perl has a chance to mangle them and
+    * restore them after its dirty deeds are done.
     *
     * MSDN ref:
     * http://msdn.microsoft.com/library/en-us/vclib/html/_crt_locale.asp
@@ -259,26 +259,29 @@ plperl_init_interp(void)
     * subsequent calls to the interpreter don't mess with the locale
     * settings.
     *
-    * We restore them using Perl's POSIX::setlocale() function so that
-    * Perl doesn't have a different idea of the locale from Postgres.
+    * We restore them using Perl's POSIX::setlocale() function so that Perl
+    * doesn't have a different idea of the locale from Postgres.
     *
     */
 
-   char *loc;
-   char *save_collate, *save_ctype, *save_monetary, *save_numeric, *save_time;
-   char buf[1024];
+   char       *loc;
+   char       *save_collate,
+              *save_ctype,
+              *save_monetary,
+              *save_numeric,
+              *save_time;
+   char        buf[1024];
 
-   loc = setlocale(LC_COLLATE,NULL);
+   loc = setlocale(LC_COLLATE, NULL);
    save_collate = loc ? pstrdup(loc) : NULL;
-   loc = setlocale(LC_CTYPE,NULL);
+   loc = setlocale(LC_CTYPE, NULL);
    save_ctype = loc ? pstrdup(loc) : NULL;
-   loc = setlocale(LC_MONETARY,NULL);
+   loc = setlocale(LC_MONETARY, NULL);
    save_monetary = loc ? pstrdup(loc) : NULL;
-   loc = setlocale(LC_NUMERIC,NULL);
+   loc = setlocale(LC_NUMERIC, NULL);
    save_numeric = loc ? pstrdup(loc) : NULL;
-   loc = setlocale(LC_TIME,NULL);
+   loc = setlocale(LC_TIME, NULL);
    save_time = loc ? pstrdup(loc) : NULL;
-
 #endif
 
    plperl_interp = perl_alloc();
@@ -294,44 +297,43 @@ plperl_init_interp(void)
 
 #ifdef WIN32
 
-   eval_pv("use POSIX qw(locale_h);", TRUE); /* croak on failure */
+   eval_pv("use POSIX qw(locale_h);", TRUE);   /* croak on failure */
 
    if (save_collate != NULL)
    {
-       snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
-                "LC_COLLATE",save_collate);
-       eval_pv(buf,TRUE);
+       snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+                "LC_COLLATE", save_collate);
+       eval_pv(buf, TRUE);
        pfree(save_collate);
    }
    if (save_ctype != NULL)
    {
-       snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
-                "LC_CTYPE",save_ctype);
-       eval_pv(buf,TRUE);
+       snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+                "LC_CTYPE", save_ctype);
+       eval_pv(buf, TRUE);
        pfree(save_ctype);
    }
    if (save_monetary != NULL)
    {
-       snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
-                "LC_MONETARY",save_monetary);
-       eval_pv(buf,TRUE);
+       snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+                "LC_MONETARY", save_monetary);
+       eval_pv(buf, TRUE);
        pfree(save_monetary);
    }
    if (save_numeric != NULL)
    {
-       snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
-                "LC_NUMERIC",save_numeric);
-       eval_pv(buf,TRUE);
+       snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+                "LC_NUMERIC", save_numeric);
+       eval_pv(buf, TRUE);
        pfree(save_numeric);
    }
    if (save_time != NULL)
    {
-       snprintf(buf, sizeof(buf),"setlocale(%s,'%s');",
-                "LC_TIME",save_time);
-       eval_pv(buf,TRUE);
+       snprintf(buf, sizeof(buf), "setlocale(%s,'%s');",
+                "LC_TIME", save_time);
+       eval_pv(buf, TRUE);
        pfree(save_time);
    }
-
 #endif
 
 }
@@ -1011,8 +1013,8 @@ plperl_func_handler(PG_FUNCTION_ARGS)
    SV         *array_ret = NULL;
 
    /*
-    * Create the call_data beforing connecting to SPI, so that it is
-    * not allocated in the SPI memory context
+    * Create the call_data beforing connecting to SPI, so that it is not
+    * allocated in the SPI memory context
     */
    current_call_data = (plperl_call_data *) palloc0(sizeof(plperl_call_data));
    current_call_data->fcinfo = fcinfo;
@@ -1160,8 +1162,8 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
    HV         *hvTD;
 
    /*
-    * Create the call_data beforing connecting to SPI, so that it is
-    * not allocated in the SPI memory context
+    * Create the call_data beforing connecting to SPI, so that it is not
+    * allocated in the SPI memory context
     */
    current_call_data = (plperl_call_data *) palloc0(sizeof(plperl_call_data));
    current_call_data->fcinfo = fcinfo;
@@ -1285,7 +1287,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
    {
        bool        uptodate;
 
-       prodesc = INT2PTR( plperl_proc_desc *, SvUV(*svp));
+       prodesc = INT2PTR(plperl_proc_desc *, SvUV(*svp));
 
        /************************************************************
         * If it's present, must check whether it's still up to date.
@@ -1483,7 +1485,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
        }
 
        hv_store(plperl_proc_hash, internal_proname, proname_len,
-                newSVuv( PTR2UV( prodesc)), 0);
+                newSVuv(PTR2UV(prodesc)), 0);
    }
 
    ReleaseSysCache(procTup);
@@ -1690,14 +1692,14 @@ plperl_return_next(SV *sv)
 
    if (!current_call_data->ret_tdesc)
    {
-       TupleDesc tupdesc;
+       TupleDesc   tupdesc;
 
        Assert(!current_call_data->tuple_store);
        Assert(!current_call_data->attinmeta);
 
        /*
-        * This is the first call to return_next in the current
-        * PL/Perl function call, so memoize some lookups
+        * This is the first call to return_next in the current PL/Perl
+        * function call, so memoize some lookups
         */
        if (prodesc->fn_retistuple)
            (void) get_call_result_type(fcinfo, NULL, &tupdesc);
@@ -1720,14 +1722,13 @@ plperl_return_next(SV *sv)
        }
 
        MemoryContextSwitchTo(old_cxt);
-   }       
+   }
 
    /*
     * Producing the tuple we want to return requires making plenty of
-    * palloc() allocations that are not cleaned up. Since this
-    * function can be called many times before the current memory
-    * context is reset, we need to do those allocations in a
-    * temporary context.
+    * palloc() allocations that are not cleaned up. Since this function can
+    * be called many times before the current memory context is reset, we
+    * need to do those allocations in a temporary context.
     */
    if (!current_call_data->tmp_cxt)
    {
@@ -1801,15 +1802,15 @@ plperl_spi_query(char *query)
 
        /* Create a cursor for the query */
        plan = SPI_prepare(query, 0, NULL);
-       if ( plan == NULL)
+       if (plan == NULL)
            elog(ERROR, "SPI_prepare() failed:%s",
-               SPI_result_code_string(SPI_result));
+                SPI_result_code_string(SPI_result));
 
        portal = SPI_cursor_open(NULL, plan, NULL, NULL, false);
-       SPI_freeplan( plan);
-       if ( portal == NULL) 
+       SPI_freeplan(plan);
+       if (portal == NULL)
            elog(ERROR, "SPI_cursor_open() failed:%s",
-               SPI_result_code_string(SPI_result));
+                SPI_result_code_string(SPI_result));
        cursor = newSVpv(portal->name, 0);
 
        /* Commit the inner transaction, return to outer xact context */
@@ -1942,13 +1943,14 @@ plperl_spi_fetchrow(char *cursor)
 void
 plperl_spi_cursor_close(char *cursor)
 {
-   Portal p = SPI_cursor_find(cursor);
+   Portal      p = SPI_cursor_find(cursor);
+
    if (p)
        SPI_cursor_close(p);
 }
 
 SV *
-plperl_spi_prepare(char* query, int argc, SV ** argv)
+plperl_spi_prepare(char *query, int argc, SV **argv)
 {
    plperl_query_desc *qdesc;
    void       *plan;
@@ -1965,11 +1967,11 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
     ************************************************************/
    qdesc = (plperl_query_desc *) malloc(sizeof(plperl_query_desc));
    MemSet(qdesc, 0, sizeof(plperl_query_desc));
-   snprintf(qdesc-> qname, sizeof(qdesc-> qname), "%lx", (long) qdesc);
-   qdesc-> nargs = argc;
-   qdesc-> argtypes = (Oid *) malloc(argc * sizeof(Oid));
-   qdesc-> arginfuncs = (FmgrInfo *) malloc(argc * sizeof(FmgrInfo));
-   qdesc-> argtypioparams = (Oid *) malloc(argc * sizeof(Oid));
+   snprintf(qdesc->qname, sizeof(qdesc->qname), "%lx", (long) qdesc);
+   qdesc->nargs = argc;
+   qdesc->argtypes = (Oid *) malloc(argc * sizeof(Oid));
+   qdesc->arginfuncs = (FmgrInfo *) malloc(argc * sizeof(FmgrInfo));
+   qdesc->argtypioparams = (Oid *) malloc(argc * sizeof(Oid));
 
    PG_TRY();
    {
@@ -2000,7 +2002,7 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
 
        if (plan == NULL)
            elog(ERROR, "SPI_prepare() failed:%s",
-               SPI_result_code_string(SPI_result));
+                SPI_result_code_string(SPI_result));
 
        /************************************************************
         * Save the plan into permanent memory (right now it's in the
@@ -2008,8 +2010,8 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
         ************************************************************/
        qdesc->plan = SPI_saveplan(plan);
        if (qdesc->plan == NULL)
-           elog(ERROR, "SPI_saveplan() failed: %s", 
-               SPI_result_code_string(SPI_result));
+           elog(ERROR, "SPI_saveplan() failed: %s",
+                SPI_result_code_string(SPI_result));
 
        /* Release the procCxt copy to avoid within-function memory leak */
        SPI_freeplan(plan);
@@ -2018,19 +2020,20 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
        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();
    }
    PG_CATCH();
    {
        ErrorData  *edata;
-       
-       free(qdesc-> argtypes);
-       free(qdesc-> arginfuncs);
-       free(qdesc-> argtypioparams);
+
+       free(qdesc->argtypes);
+       free(qdesc->arginfuncs);
+       free(qdesc->argtypioparams);
        free(qdesc);
 
        /* Save error info */
@@ -2044,9 +2047,9 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
        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();
 
@@ -2062,24 +2065,26 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
     * Insert a hashtable entry for the plan and return
     * the key to the caller.
     ************************************************************/
-   hv_store( plperl_query_hash, qdesc->qname, strlen(qdesc->qname), newSVuv( PTR2UV( qdesc)), 0);
+   hv_store(plperl_query_hash, qdesc->qname, strlen(qdesc->qname), newSVuv(PTR2UV(qdesc)), 0);
 
-   return newSVpv( qdesc->qname, strlen(qdesc->qname));
-}  
+   return newSVpv(qdesc->qname, strlen(qdesc->qname));
+}
 
 HV *
-plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
+plperl_spi_exec_prepared(char *query, HV *attr, int argc, SV **argv)
 {
    HV         *ret_hv;
-   SV **sv;
-   int i, limit, spi_rv;
-   char * nulls;
+   SV        **sv;
+   int         i,
+               limit,
+               spi_rv;
+   char       *nulls;
    Datum      *argvalues;
    plperl_query_desc *qdesc;
 
    /*
-    * 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;
@@ -2094,54 +2099,54 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
         * Fetch the saved plan descriptor, see if it's o.k.
         ************************************************************/
        sv = hv_fetch(plperl_query_hash, query, strlen(query), 0);
-       if ( sv == NULL) 
+       if (sv == NULL)
            elog(ERROR, "spi_exec_prepared: Invalid prepared query passed");
-       if ( *sv == NULL || !SvOK( *sv))
+       if (*sv == NULL || !SvOK(*sv))
            elog(ERROR, "spi_exec_prepared: panic - plperl_query_hash value corrupted");
 
-       qdesc = INT2PTR( plperl_query_desc *, SvUV(*sv));
-       if ( qdesc == NULL)
+       qdesc = INT2PTR(plperl_query_desc *, SvUV(*sv));
+       if (qdesc == NULL)
            elog(ERROR, "spi_exec_prepared: panic - plperl_query_hash value vanished");
 
-       if ( qdesc-> nargs != argc) 
-           elog(ERROR, "spi_exec_prepared: expected %d argument(s), %d passed", 
-               qdesc-> nargs, argc);
-       
+       if (qdesc->nargs != argc)
+           elog(ERROR, "spi_exec_prepared: expected %d argument(s), %d passed",
+                qdesc->nargs, argc);
+
        /************************************************************
         * Parse eventual attributes
         ************************************************************/
        limit = 0;
-       if ( attr != NULL) 
+       if (attr != NULL)
        {
-           sv = hv_fetch( attr, "limit", 5, 0);
-           if ( *sv && SvIOK( *sv))
-               limit = SvIV( *sv);
+           sv = hv_fetch(attr, "limit", 5, 0);
+           if (*sv && SvIOK(*sv))
+               limit = SvIV(*sv);
        }
        /************************************************************
         * Set up arguments
         ************************************************************/
-       if (argc > 0) 
+       if (argc > 0)
        {
            nulls = (char *) palloc(argc);
            argvalues = (Datum *) palloc(argc * sizeof(Datum));
-       } 
-       else 
+       }
+       else
        {
            nulls = NULL;
            argvalues = NULL;
        }
 
-       for (i = 0; i < argc; i++) 
+       for (i = 0; i < argc; i++)
        {
-           if (SvTYPE(argv[i]) != SVt_NULL) 
+           if (SvTYPE(argv[i]) != SVt_NULL)
            {
                argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
                                                 SvPV(argv[i], PL_na),
                                                 qdesc->argtypioparams[i],
                                                 -1);
                nulls[i] = ' ';
-           } 
-           else 
+           }
+           else
            {
                argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
                                                 NULL,
@@ -2154,23 +2159,24 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
        /************************************************************
         * go
         ************************************************************/
-       spi_rv = SPI_execute_plan(qdesc-> plan, argvalues, nulls, 
+       spi_rv = SPI_execute_plan(qdesc->plan, argvalues, nulls,
                             current_call_data->prodesc->fn_readonly, limit);
        ret_hv = plperl_spi_execute_fetch_result(SPI_tuptable, SPI_processed,
                                                 spi_rv);
-       if ( argc > 0) 
+       if (argc > 0)
        {
-           pfree( argvalues);
-           pfree( nulls);
+           pfree(argvalues);
+           pfree(nulls);
        }
 
        /* Commit the inner transaction, return to outer xact context */
        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();
    }
@@ -2189,9 +2195,9 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
        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();
 
@@ -2207,19 +2213,19 @@ plperl_spi_exec_prepared(char* query, HV * attr, int argc, SV ** argv)
 }
 
 SV *
-plperl_spi_query_prepared(char* query, int argc, SV ** argv)
+plperl_spi_query_prepared(char *query, int argc, SV **argv)
 {
-   SV **sv;
-   int i;
-   char nulls;
+   SV        **sv;
+   int         i;
+   char       *nulls;
    Datum      *argvalues;
    plperl_query_desc *qdesc;
-   SV *cursor;
-   Portal portal = NULL;
+   SV         *cursor;
+   Portal      portal = NULL;
 
    /*
-    * 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;
@@ -2234,44 +2240,44 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
         * Fetch the saved plan descriptor, see if it's o.k.
         ************************************************************/
        sv = hv_fetch(plperl_query_hash, query, strlen(query), 0);
-       if ( sv == NULL) 
+       if (sv == NULL)
            elog(ERROR, "spi_query_prepared: Invalid prepared query passed");
-       if ( *sv == NULL || !SvOK( *sv))
+       if (*sv == NULL || !SvOK(*sv))
            elog(ERROR, "spi_query_prepared: panic - plperl_query_hash value corrupted");
 
-       qdesc = INT2PTR( plperl_query_desc *, SvUV(*sv));
-       if ( qdesc == NULL)
+       qdesc = INT2PTR(plperl_query_desc *, SvUV(*sv));
+       if (qdesc == NULL)
            elog(ERROR, "spi_query_prepared: panic - plperl_query_hash value vanished");
 
-       if ( qdesc-> nargs != argc) 
-           elog(ERROR, "spi_query_prepared: expected %d argument(s), %d passed", 
-               qdesc-> nargs, argc);
-       
+       if (qdesc->nargs != argc)
+           elog(ERROR, "spi_query_prepared: expected %d argument(s), %d passed",
+                qdesc->nargs, argc);
+
        /************************************************************
         * Set up arguments
         ************************************************************/
-       if (argc > 0) 
+       if (argc > 0)
        {
            nulls = (char *) palloc(argc);
            argvalues = (Datum *) palloc(argc * sizeof(Datum));
-       } 
-       else 
+       }
+       else
        {
            nulls = NULL;
            argvalues = NULL;
        }
 
-       for (i = 0; i < argc; i++) 
+       for (i = 0; i < argc; i++)
        {
-           if (SvTYPE(argv[i]) != SVt_NULL) 
+           if (SvTYPE(argv[i]) != SVt_NULL)
            {
                argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
                                                 SvPV(argv[i], PL_na),
                                                 qdesc->argtypioparams[i],
                                                 -1);
                nulls[i] = ' ';
-           } 
-           else 
+           }
+           else
            {
                argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
                                                 NULL,
@@ -2284,16 +2290,16 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
        /************************************************************
         * go
         ************************************************************/
-       portal = SPI_cursor_open(NULL, qdesc-> plan, argvalues, nulls, 
-                           current_call_data->prodesc->fn_readonly);
-       if ( argc > 0) 
+       portal = SPI_cursor_open(NULL, qdesc->plan, argvalues, nulls,
+                                current_call_data->prodesc->fn_readonly);
+       if (argc > 0)
        {
-           pfree( argvalues);
-           pfree( nulls);
+           pfree(argvalues);
+           pfree(nulls);
        }
-       if ( portal == NULL) 
+       if (portal == NULL)
            elog(ERROR, "SPI_cursor_open() failed:%s",
-               SPI_result_code_string(SPI_result));
+                SPI_result_code_string(SPI_result));
 
        cursor = newSVpv(portal->name, 0);
 
@@ -2301,9 +2307,10 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
        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();
    }
@@ -2322,9 +2329,9 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
        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();
 
@@ -2342,29 +2349,30 @@ plperl_spi_query_prepared(char* query, int argc, SV ** argv)
 void
 plperl_spi_freeplan(char *query)
 {
-   SV ** sv;
-   void plan;
+   SV        **sv;
+   void       *plan;
    plperl_query_desc *qdesc;
 
    sv = hv_fetch(plperl_query_hash, query, strlen(query), 0);
-   if ( sv == NULL) 
+   if (sv == NULL)
        elog(ERROR, "spi_exec_freeplan: Invalid prepared query passed");
-   if ( *sv == NULL || !SvOK( *sv))
+   if (*sv == NULL || !SvOK(*sv))
        elog(ERROR, "spi_exec_freeplan: panic - plperl_query_hash value corrupted");
 
-   qdesc = INT2PTR( plperl_query_desc *, SvUV(*sv));
-   if ( qdesc == NULL)
+   qdesc = INT2PTR(plperl_query_desc *, SvUV(*sv));
+   if (qdesc == NULL)
        elog(ERROR, "spi_exec_freeplan: panic - plperl_query_hash value vanished");
 
    /*
-   *   free all memory before SPI_freeplan, so if it dies, nothing will be left over
-   */
+    * free all memory before SPI_freeplan, so if it dies, nothing will be
+    * left over
+    */
    hv_delete(plperl_query_hash, query, strlen(query), G_DISCARD);
-   plan = qdesc-> plan;
-   free(qdesc-> argtypes);
-   free(qdesc-> arginfuncs);
-   free(qdesc-> argtypioparams);
+   plan = qdesc->plan;
+   free(qdesc->argtypes);
+   free(qdesc->arginfuncs);
+   free(qdesc->argtypioparams);
    free(qdesc);
 
-   SPI_freeplan( plan);
+   SPI_freeplan(plan);
 }
index 53c7b164faf07cd1ad398f95ce0d37e4514b0870..8feccb45cd30402fa7ee2c97fa1b988707d2be9e 100644 (file)
@@ -1,14 +1,14 @@
 /*-------------------------------------------------------------------------
  *
  * plperl.h
- *    Common include file for PL/Perl files
+ *   Common include file for PL/Perl files
  *
  * This should be included _AFTER_ postgres.h and system include files
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1995, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.h,v 1.4 2006/03/05 16:40:51 adunstan Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.h,v 1.5 2006/10/04 00:30:13 momjian Exp $
  */
 
 #ifndef PL_PERL_H
 /* stop perl headers from hijacking stdio and other stuff on Windows */
 #ifdef WIN32
 #define WIN32IO_IS_STDIO
-/* 
+/*
  * isnan is defined in both the perl and mingw headers. We don't use it,
  * so this just clears up the compile warning.
  */
 #ifdef isnan
 #undef isnan
 #endif
-#endif 
+#endif
 
 /* required for perl API */
 #include "EXTERN.h"
@@ -51,12 +51,12 @@ HV         *plperl_spi_exec(char *, int);
 void       plperl_return_next(SV *);
 SV        *plperl_spi_query(char *);
 SV        *plperl_spi_fetchrow(char *);
-SV *plperl_spi_prepare(char *, int, SV **);
-HV *plperl_spi_exec_prepared(char *, HV *, int, SV **);
-SV *plperl_spi_query_prepared(char *, int, SV **);
-void plperl_spi_freeplan(char *);
-void plperl_spi_cursor_close(char *);
+SV        *plperl_spi_prepare(char *, int, SV **);
+HV        *plperl_spi_exec_prepared(char *, HV *, int, SV **);
+SV        *plperl_spi_query_prepared(char *, int, SV **);
+void       plperl_spi_freeplan(char *);
+void       plperl_spi_cursor_close(char *);
 
 
 
-#endif /* PL_PERL_H */
+#endif   /* PL_PERL_H */
index 6670ac657166e48e01d1838bdd585bed55b9d32e..654e8ccf43f9c060f6a074efaa53b5ba0d2b4f99 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.107 2006/07/11 17:26:59 momjian Exp $
+ *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.108 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -587,14 +587,14 @@ do_compile(FunctionCallInfo fcinfo,
                                         true);
            function->tg_table_name_varno = var->dno;
 
-           
+
            /* add variable tg_table_schema */
            var = plpgsql_build_variable("tg_table_schema", 0,
                                         plpgsql_build_datatype(NAMEOID, -1),
                                         true);
            function->tg_table_schema_varno = var->dno;
 
-           
+
            /* Add the variable tg_nargs */
            var = plpgsql_build_variable("tg_nargs", 0,
                                         plpgsql_build_datatype(INT4OID, -1),
index c5e036ccb77954c193aacd1b5e6805c4c8a4ce63..c28c2c6c8f3597a5535029b383afb6c3c23bc94e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.179 2006/09/22 21:39:58 tgl Exp $
+ *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.180 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -257,7 +257,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
     * Let the instrumentation plugin peek at this function
     */
    if (*plugin_ptr && (*plugin_ptr)->func_beg)
-       ((*plugin_ptr)->func_beg)(&estate, func);
+       ((*plugin_ptr)->func_beg) (&estate, func);
 
    /*
     * Now call the toplevel block of statements
@@ -325,9 +325,9 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
        if (estate.retistuple)
        {
            /*
-            * We have to check that the returned tuple actually matches
-            * the expected result type.  XXX would be better to cache the
-            * tupdesc instead of repeating get_call_result_type()
+            * We have to check that the returned tuple actually matches the
+            * expected result type.  XXX would be better to cache the tupdesc
+            * instead of repeating get_call_result_type()
             */
            TupleDesc   tupdesc;
 
@@ -342,12 +342,13 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
                                 errmsg("returned record type does not match expected record type")));
                    break;
                case TYPEFUNC_RECORD:
+
                    /*
                     * Failed to determine actual type of RECORD.  We could
-                    * raise an error here, but what this means in practice
-                    * is that the caller is expecting any old generic
-                    * rowtype, so we don't really need to be restrictive.
-                    * Pass back the generated result type, instead.
+                    * raise an error here, but what this means in practice is
+                    * that the caller is expecting any old generic rowtype,
+                    * so we don't really need to be restrictive. Pass back
+                    * the generated result type, instead.
                     */
                    tupdesc = estate.rettupdesc;
                    if (tupdesc == NULL)        /* shouldn't happen */
@@ -360,8 +361,8 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
            }
 
            /*
-            * Copy tuple to upper executor memory, as a tuple Datum.
-            * Make sure it is labeled with the caller-supplied tuple type.
+            * Copy tuple to upper executor memory, as a tuple Datum. Make
+            * sure it is labeled with the caller-supplied tuple type.
             */
            estate.retval =
                PointerGetDatum(SPI_returntuple((HeapTuple) (estate.retval),
@@ -398,7 +399,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
     * Let the instrumentation plugin peek at this function
     */
    if (*plugin_ptr && (*plugin_ptr)->func_end)
-       ((*plugin_ptr)->func_end)(&estate, func);
+       ((*plugin_ptr)->func_end) (&estate, func);
 
    /* Clean up any leftover temporary memory */
    FreeExprContext(estate.eval_econtext);
@@ -561,9 +562,9 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
    var = (PLpgSQL_var *) (estate.datums[func->tg_table_schema_varno]);
    var->value = DirectFunctionCall1(namein,
                                     CStringGetDatum(
-                                        get_namespace_name(
-                                            RelationGetNamespace(
-                                                trigdata->tg_relation))));
+                                                    get_namespace_name(
+                                                       RelationGetNamespace(
+                                                  trigdata->tg_relation))));
    var->isnull = false;
    var->freeval = true;
 
@@ -597,7 +598,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
     * Let the instrumentation plugin peek at this function
     */
    if (*plugin_ptr && (*plugin_ptr)->func_beg)
-       ((*plugin_ptr)->func_beg)(&estate, func);
+       ((*plugin_ptr)->func_beg) (&estate, func);
 
    /*
     * Now call the toplevel block of statements
@@ -656,7 +657,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func,
     * Let the instrumentation plugin peek at this function
     */
    if (*plugin_ptr && (*plugin_ptr)->func_end)
-       ((*plugin_ptr)->func_end)(&estate, func);
+       ((*plugin_ptr)->func_end) (&estate, func);
 
    /* Clean up any leftover temporary memory */
    FreeExprContext(estate.eval_econtext);
@@ -1064,7 +1065,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
 
    /* Let the plugin know that we are about to execute this statement */
    if (*plugin_ptr && (*plugin_ptr)->stmt_beg)
-       ((*plugin_ptr)->stmt_beg)(estate, stmt);
+       ((*plugin_ptr)->stmt_beg) (estate, stmt);
 
    CHECK_FOR_INTERRUPTS();
 
@@ -1153,7 +1154,7 @@ exec_stmt(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
 
    /* Let the plugin know that we have finished executing this statement */
    if (*plugin_ptr && (*plugin_ptr)->stmt_end)
-       ((*plugin_ptr)->stmt_end)(estate, stmt);
+       ((*plugin_ptr)->stmt_end) (estate, stmt);
 
    estate->err_stmt = save_estmt;
 
@@ -1439,7 +1440,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
    exec_eval_cleanup(estate);
 
    /*
-    * Get the by value 
+    * Get the by value
     */
    by_value = exec_eval_expr(estate, stmt->by, &isnull, &valtype);
    by_value = exec_cast_value(by_value, valtype, var->datatype->typoid,
@@ -2158,10 +2159,10 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
    estate->eval_econtext = CreateExprContext(simple_eval_estate);
 
    /*
-    * Let the plugin see this function before we initialize any
-    * local PL/pgSQL variables - note that we also give the plugin
-    * a few function pointers so it can call back into PL/pgSQL
-    * for doing things like variable assignments and stack traces
+    * Let the plugin see this function before we initialize any local
+    * PL/pgSQL variables - note that we also give the plugin a few function
+    * pointers so it can call back into PL/pgSQL for doing things like
+    * variable assignments and stack traces
     */
    if (*plugin_ptr)
    {
@@ -2169,7 +2170,7 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
        (*plugin_ptr)->assign_expr = exec_assign_expr;
 
        if ((*plugin_ptr)->func_setup)
-           ((*plugin_ptr)->func_setup)(estate, func);
+           ((*plugin_ptr)->func_setup) (estate, func);
    }
 }
 
@@ -2278,8 +2279,8 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
    PLpgSQL_expr *expr = stmt->sqlstmt;
 
    /*
-    * On the first call for this statement generate the plan, and
-    * detect whether the statement is INSERT/UPDATE/DELETE
+    * On the first call for this statement generate the plan, and detect
+    * whether the statement is INSERT/UPDATE/DELETE
     */
    if (expr->plan == NULL)
    {
@@ -2295,7 +2296,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
 
            foreach(l2, (List *) lfirst(l))
            {
-               Query *q = (Query *) lfirst(l2);
+               Query      *q = (Query *) lfirst(l2);
 
                Assert(IsA(q, Query));
                if (q->canSetTag)
@@ -2330,15 +2331,15 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
    }
 
    /*
-    * If we have INTO, then we only need one row back ... but if we have
-    * INTO STRICT, ask for two rows, so that we can verify the statement
-    * returns only one.  INSERT/UPDATE/DELETE are always treated strictly.
-    * Without INTO, just run the statement to completion (tcount = 0).
+    * If we have INTO, then we only need one row back ... but if we have INTO
+    * STRICT, ask for two rows, so that we can verify the statement returns
+    * only one.  INSERT/UPDATE/DELETE are always treated strictly. Without
+    * INTO, just run the statement to completion (tcount = 0).
     *
-    * We could just ask for two rows always when using INTO, but there
-    * are some cases where demanding the extra row costs significant time,
-    * eg by forcing completion of a sequential scan.  So don't do it unless
-    * we need to enforce strictness.
+    * We could just ask for two rows always when using INTO, but there are
+    * some cases where demanding the extra row costs significant time, eg by
+    * forcing completion of a sequential scan.  So don't do it unless we need
+    * to enforce strictness.
     */
    if (stmt->into)
    {
@@ -2358,7 +2359,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
 
    /*
     * Check for error, and set FOUND if appropriate (for historical reasons
-    * we set FOUND only for certain query types).  Also Assert that we
+    * we set FOUND only for certain query types).  Also Assert that we
     * identified the statement type the same as SPI did.
     */
    switch (rc)
@@ -2404,7 +2405,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
        if (tuptab == NULL)
            ereport(ERROR,
                    (errcode(ERRCODE_SYNTAX_ERROR),
-                    errmsg("INTO used with a command that cannot return data")));
+               errmsg("INTO used with a command that cannot return data")));
 
        /* Determine if we assign to a record or a row */
        if (stmt->rec != NULL)
@@ -2415,9 +2416,9 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
            elog(ERROR, "unsupported target");
 
        /*
-        * If SELECT ... INTO specified STRICT, and the query didn't
-        * find exactly one row, throw an error.  If STRICT was not specified,
-        * then allow the query to find any number of rows.
+        * If SELECT ... INTO specified STRICT, and the query didn't find
+        * exactly one row, throw an error.  If STRICT was not specified, then
+        * allow the query to find any number of rows.
         */
        if (n == 0)
        {
@@ -2474,8 +2475,8 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
    int         exec_res;
 
    /*
-    * First we evaluate the string expression after the EXECUTE keyword.
-    * Its result is the querystring we have to execute.
+    * First we evaluate the string expression after the EXECUTE keyword. Its
+    * result is the querystring we have to execute.
     */
    query = exec_eval_expr(estate, stmt->query, &isnull, &restype);
    if (isnull)
@@ -2575,7 +2576,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
        if (tuptab == NULL)
            ereport(ERROR,
                    (errcode(ERRCODE_SYNTAX_ERROR),
-                    errmsg("INTO used with a command that cannot return data")));
+               errmsg("INTO used with a command that cannot return data")));
 
        /* Determine if we assign to a record or a row */
        if (stmt->rec != NULL)
@@ -2586,9 +2587,9 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
            elog(ERROR, "unsupported target");
 
        /*
-        * If SELECT ... INTO specified STRICT, and the query didn't
-        * find exactly one row, throw an error.  If STRICT was not specified,
-        * then allow the query to find any number of rows.
+        * If SELECT ... INTO specified STRICT, and the query didn't find
+        * exactly one row, throw an error.  If STRICT was not specified, then
+        * allow the query to find any number of rows.
         */
        if (n == 0)
        {
@@ -3951,7 +3952,7 @@ exec_eval_simple_expr(PLpgSQL_execstate *estate,
        paramLI = (ParamListInfo)
            MemoryContextAlloc(econtext->ecxt_per_tuple_memory,
                               sizeof(ParamListInfoData) +
-                              (expr->nparams - 1) * sizeof(ParamExternData));
+                              (expr->nparams - 1) *sizeof(ParamExternData));
        paramLI->numParams = expr->nparams;
 
        for (i = 0; i < expr->nparams; i++)
@@ -4462,7 +4463,7 @@ exec_simple_check_node(Node *node)
 
        case T_RowCompareExpr:
            {
-               RowCompareExpr    *expr = (RowCompareExpr *) node;
+               RowCompareExpr *expr = (RowCompareExpr *) node;
 
                if (!exec_simple_check_node((Node *) expr->largs))
                    return FALSE;
index a0f2cb465503b2b04d846854fc547e0ae120d443..5f08107f91a0a6ebca67c508efdd946b4dbee673 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.31 2006/08/15 19:01:17 tgl Exp $
+ *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.32 2006/10/04 00:30:13 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -162,7 +162,7 @@ plpgsql_validator(PG_FUNCTION_ARGS)
                ereport(ERROR,
                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                         errmsg("plpgsql functions cannot take type %s",
-                             format_type_be(argtypes[i]))));
+                               format_type_be(argtypes[i]))));
        }
    }
 
index 206f9b9875e78f6c4c4cfc678911867803b4f359..051dd9e3c48fe154bf5bbf0f3ee8e18b12600489 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.80 2006/08/15 19:01:17 tgl Exp $
+ *   $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.81 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -178,6 +178,7 @@ typedef struct PLpgSQL_expr
    /* fields for "simple expression" fast-path execution: */
    Expr       *expr_simple_expr;       /* NULL means not a simple expr */
    Oid         expr_simple_type;
+
    /*
     * if expr is simple AND in use in current xact, expr_simple_state is
     * valid.  Test validity by seeing if expr_simple_xid matches current XID.
@@ -570,8 +571,8 @@ typedef struct PLpgSQL_function
    int         tg_op_varno;
    int         tg_relid_varno;
    int         tg_relname_varno;
-   int         tg_table_name_varno;
-   int         tg_table_schema_varno;
+   int         tg_table_name_varno;
+   int         tg_table_schema_varno;
    int         tg_nargs_varno;
 
    int         ndatums;
@@ -629,42 +630,42 @@ typedef struct
  * We expect that a plugin would do this at library load time (_PG_init()).
  * It must also be careful to set the rendezvous variable back to NULL
  * if it is unloaded (_PG_fini()).
- * 
+ *
  * This structure is basically a collection of function pointers --- at
  * various interesting points in pl_exec.c, we call these functions
  * (if the pointers are non-NULL) to give the plugin a chance to watch
  * what we are doing.
  *
- *  func_setup is called when we start a function, before we've initialized
- *  the local variables defined by the function.
+ * func_setup is called when we start a function, before we've initialized
+ * the local variables defined by the function.
  *
- *  func_beg is called when we start a function, after we've initialized
- *  the local variables.
+ * func_beg is called when we start a function, after we've initialized
+ * the local variables.
  *
- *  func_end is called at the end of a function.
+ * func_end is called at the end of a function.
  *
- *  stmt_beg and stmt_end are called before and after (respectively) each
- *  statement.
+ * stmt_beg and stmt_end are called before and after (respectively) each
+ * statement.
  *
  * Also, immediately before any call to func_setup, PL/pgSQL fills in the
  * error_callback and assign_expr fields with pointers to its own
- * plpgsql_exec_error_callback and exec_assign_expr functions.  This is
+ * plpgsql_exec_error_callback and exec_assign_expr functions. This is
  * a somewhat ad-hoc expedient to simplify life for debugger plugins.
  */
 
 typedef struct
 {
    /* Function pointers set up by the plugin */
-   void (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
-   void (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
-   void (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
-   void (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
-   void (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
+   void        (*func_setup) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
+   void        (*func_beg) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
+   void        (*func_end) (PLpgSQL_execstate *estate, PLpgSQL_function *func);
+   void        (*stmt_beg) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
+   void        (*stmt_end) (PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt);
 
    /* Function pointers set by PL/pgSQL itself */
-   void (*error_callback) (void *arg);
-   void (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
-                        PLpgSQL_expr *expr);
+   void        (*error_callback) (void *arg);
+   void        (*assign_expr) (PLpgSQL_execstate *estate, PLpgSQL_datum *target,
+                                           PLpgSQL_expr *expr);
 } PLpgSQL_plugin;
 
 
index 1a80a74d8298bb7425c5b7c4700b5b843ddc2a6e..6445837ac9c800142d2d028bd49c6c27896460fb 100644 (file)
@@ -1,7 +1,7 @@
 /**********************************************************************
  * plpython.c - python as a procedural language for PostgreSQL
  *
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.88 2006/09/16 13:35:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.89 2006/10/04 00:30:14 momjian Exp $
  *
  *********************************************************************
  */
@@ -122,9 +122,9 @@ typedef struct PLyProcedure
    bool        fn_readonly;
    PLyTypeInfo result;         /* also used to store info for trigger tuple
                                 * type */
-   bool        is_setof;       /* true, if procedure returns result set */
-   PyObject    *setof;     /* contents of result set. */
-   char        **argnames;     /* Argument names */
+   bool        is_setof;       /* true, if procedure returns result set */
+   PyObject   *setof;          /* contents of result set. */
+   char      **argnames;       /* Argument names */
    PLyTypeInfo args[FUNC_MAX_ARGS];
    int         nargs;
    PyObject   *code;           /* compiled procedure code */
@@ -150,7 +150,7 @@ typedef struct PLyResultObject
 {
    PyObject_HEAD
    /* HeapTuple *tuples; */
-   PyObject   *nrows;          /* number of rows returned by query */
+   PyObject * nrows;           /* number of rows returned by query */
    PyObject   *rows;           /* data rows, or None if no data returned */
    PyObject   *status;         /* query status, SPI_OK_*, or SPI_ERR_* */
 }  PLyResultObject;
@@ -391,7 +391,7 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
            if (!PyString_Check(plrv))
                ereport(ERROR,
                        (errcode(ERRCODE_DATA_EXCEPTION),
-                        errmsg("unexpected return value from trigger procedure"),
+                   errmsg("unexpected return value from trigger procedure"),
                         errdetail("Expected None or a String.")));
 
            srv = PyString_AsString(plrv);
@@ -410,12 +410,12 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
            else if (pg_strcasecmp(srv, "OK") != 0)
            {
                /*
-                * accept "OK" as an alternative to None; otherwise,
-                * raise an error
+                * accept "OK" as an alternative to None; otherwise, raise an
+                * error
                 */
                ereport(ERROR,
                        (errcode(ERRCODE_DATA_EXCEPTION),
-                        errmsg("unexpected return value from trigger procedure"),
+                   errmsg("unexpected return value from trigger procedure"),
                         errdetail("Expected None, \"OK\", \"SKIP\", or \"MODIFY\".")));
            }
        }
@@ -513,7 +513,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
                modvalues[i] =
                    InputFunctionCall(&proc->result.out.r.atts[atti].typfunc,
                                      src,
-                                     proc->result.out.r.atts[atti].typioparam,
+                                   proc->result.out.r.atts[atti].typioparam,
                                      tupdesc->attrs[atti]->atttypmod);
                modnulls[i] = ' ';
 
@@ -525,7 +525,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
                modvalues[i] =
                    InputFunctionCall(&proc->result.out.r.atts[atti].typfunc,
                                      NULL,
-                                     proc->result.out.r.atts[atti].typioparam,
+                                   proc->result.out.r.atts[atti].typioparam,
                                      tupdesc->attrs[atti]->atttypmod);
                modnulls[i] = 'n';
            }
@@ -575,9 +575,9 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
               *pltevent,
               *pltwhen,
               *pltlevel,
-              *pltrelid,
-              *plttablename,
-              *plttableschema;
+              *pltrelid,
+              *plttablename,
+              *plttableschema;
    PyObject   *pltargs,
               *pytnew,
               *pytold;
@@ -606,13 +606,13 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
        PyDict_SetItemString(pltdata, "table_name", plttablename);
        Py_DECREF(plttablename);
        pfree(stroid);
-       
+
        stroid = SPI_getnspname(tdata->tg_relation);
        plttableschema = PyString_FromString(stroid);
        PyDict_SetItemString(pltdata, "table_schema", plttableschema);
        Py_DECREF(plttableschema);
        pfree(stroid);
-       
+
 
        if (TRIGGER_FIRED_BEFORE(tdata->tg_event))
            pltwhen = PyString_FromString("BEFORE");
@@ -762,7 +762,11 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
            plargs = PLy_function_build_args(fcinfo, proc);
            plrv = PLy_procedure_call(proc, "args", plargs);
            if (!proc->is_setof)
-               /* SETOF function parameters will be deleted when last row is returned */
+
+               /*
+                * SETOF function parameters will be deleted when last row is
+                * returned
+                */
                PLy_function_delete_args(proc);
            Assert(plrv != NULL);
            Assert(!PLy_error_in_progress);
@@ -779,14 +783,14 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
 
        if (proc->is_setof)
        {
-           bool has_error = false;
-           ReturnSetInfo *rsi = (ReturnSetInfo *)fcinfo->resultinfo;
+           bool        has_error = false;
+           ReturnSetInfo *rsi = (ReturnSetInfo *) fcinfo->resultinfo;
 
            if (proc->setof == NULL)
            {
                /* first time -- do checks and setup */
                if (!rsi || !IsA(rsi, ReturnSetInfo) ||
-                       (rsi->allowedModes & SFRM_ValuePerCall) == 0)
+                   (rsi->allowedModes & SFRM_ValuePerCall) == 0)
                {
                    ereport(ERROR,
                            (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -803,7 +807,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
                    ereport(ERROR,
                            (errcode(ERRCODE_DATATYPE_MISMATCH),
                             errmsg("returned object can not be iterated"),
-                            errdetail("SETOF must be returned as iterable object")));
+                   errdetail("SETOF must be returned as iterable object")));
            }
 
            /* Fetch next from iterator */
@@ -831,26 +835,25 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
                if (has_error)
                    ereport(ERROR,
                            (errcode(ERRCODE_DATA_EXCEPTION),
-                            errmsg("error fetching next item from iterator")));
+                         errmsg("error fetching next item from iterator")));
 
                fcinfo->isnull = true;
-               return (Datum)NULL;
+               return (Datum) NULL;
            }
        }
 
        /*
-        * If the function is declared to return void, the Python
-        * return value must be None. For void-returning functions, we
-        * also treat a None return value as a special "void datum"
-        * rather than NULL (as is the case for non-void-returning
-        * functions).
+        * If the function is declared to return void, the Python return value
+        * must be None. For void-returning functions, we also treat a None
+        * return value as a special "void datum" rather than NULL (as is the
+        * case for non-void-returning functions).
         */
        if (proc->result.out.d.typoid == VOIDOID)
        {
            if (plrv != Py_None)
                ereport(ERROR,
                        (errcode(ERRCODE_DATATYPE_MISMATCH),
-                        errmsg("invalid return value from plpython function"),
+                      errmsg("invalid return value from plpython function"),
                         errdetail("Functions returning type \"void\" must return None.")));
 
            fcinfo->isnull = false;
@@ -861,16 +864,16 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
            fcinfo->isnull = true;
            if (proc->result.is_rowtype < 1)
                rv = InputFunctionCall(&proc->result.out.d.typfunc,
-                       NULL,
-                       proc->result.out.d.typioparam,
-                       -1);
+                                      NULL,
+                                      proc->result.out.d.typioparam,
+                                      -1);
            else
                /* Tuple as None */
                rv = (Datum) NULL;
        }
        else if (proc->result.is_rowtype >= 1)
        {
-           HeapTuple   tuple = NULL;
+           HeapTuple   tuple = NULL;
 
            if (PySequence_Check(plrv))
                /* composite type as sequence (tuple, list etc) */
@@ -1017,8 +1020,8 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
            }
 
            if (PyList_SetItem(args, i, arg) == -1 ||
-                   (proc->argnames &&
-                    PyDict_SetItemString(proc->globals, proc->argnames[i], arg) == -1))
+               (proc->argnames &&
+                PyDict_SetItemString(proc->globals, proc->argnames[i], arg) == -1))
                PLy_elog(ERROR, "problem setting up arguments for \"%s\"", proc->proname);
            arg = NULL;
        }
@@ -1037,14 +1040,14 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
 
 
 static void
-PLy_function_delete_args(PLyProcedure *proc)
+PLy_function_delete_args(PLyProcedure * proc)
 {
-   int i;
+   int         i;
 
    if (!proc->argnames)
        return;
 
-   for (i = 0;  i < proc->nargs;  i++)
+   for (i = 0; i < proc->nargs; i++)
        PyDict_DelItemString(proc->globals, proc->argnames[i]);
 }
 
@@ -1120,8 +1123,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
    int         i,
                rv;
    Datum       argnames;
-   Datum           *elems;
-   int     nelems;
+   Datum      *elems;
+   int         nelems;
 
    procStruct = (Form_pg_proc) GETSTRUCT(procTup);
 
@@ -1193,7 +1196,10 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
 
            if (rvTypeStruct->typtype == 'c')
            {
-               /* Tuple: set up later, during first call to PLy_function_handler */
+               /*
+                * Tuple: set up later, during first call to
+                * PLy_function_handler
+                */
                proc->result.out.d.typoid = procStruct->prorettype;
                proc->result.is_rowtype = 2;
            }
@@ -1215,8 +1221,8 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
        }
 
        /*
-        * now get information required for input conversion of the procedure's
-        * arguments.
+        * now get information required for input conversion of the
+        * procedure's arguments.
         */
        proc->nargs = fcinfo->nargs;
        if (proc->nargs)
@@ -1225,12 +1231,12 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
            if (!isnull)
            {
                deconstruct_array(DatumGetArrayTypeP(argnames), TEXTOID, -1, false, 'i',
-                       &elems, NULL, &nelems);
+                                 &elems, NULL, &nelems);
                if (nelems != proc->nargs)
                    elog(ERROR,
-                           "proargnames must have the same number of elements "
-                           "as the function has arguments");
-               proc->argnames = (char **) PLy_malloc(sizeof(char *)*proc->nargs);
+                        "proargnames must have the same number of elements "
+                        "as the function has arguments");
+               proc->argnames = (char **) PLy_malloc(sizeof(char *) * proc->nargs);
            }
        }
        for (i = 0; i < fcinfo->nargs; i++)
@@ -1306,8 +1312,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);
@@ -1674,13 +1680,13 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
 
 
 static HeapTuple
-PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
+PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
 {
    TupleDesc   desc;
    HeapTuple   tuple;
-   Datum       *values;
-   char        *nulls;
-   int     i;
+   Datum      *values;
+   char       *nulls;
+   int         i;
 
    Assert(PyMapping_Check(mapping));
 
@@ -1690,13 +1696,13 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
    Assert(info->is_rowtype == 1);
 
    /* Build tuple */
-   values = palloc(sizeof(Datum)*desc->natts);
-   nulls = palloc(sizeof(char)*desc->natts);
-   for (i = 0;  i < desc->natts;  ++i)
+   values = palloc(sizeof(Datum) * desc->natts);
+   nulls = palloc(sizeof(char) * desc->natts);
+   for (i = 0; i < desc->natts; ++i)
    {
-       char        *key;
-       PyObject    *value,
-               *so;
+       char       *key;
+       PyObject   *value,
+                  *so;
 
        key = NameStr(desc->attrs[i]->attname);
        value = so = NULL;
@@ -1710,7 +1716,7 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
            }
            else if (value)
            {
-               char *valuestr;
+               char       *valuestr;
 
                so = PyObject_Str(value);
                if (so == NULL)
@@ -1718,9 +1724,9 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
                valuestr = PyString_AsString(so);
 
                values[i] = InputFunctionCall(&info->out.r.atts[i].typfunc
-                       valuestr
-                       info->out.r.atts[i].typioparam
-                       -1);
+                                             ,valuestr
+                                             ,info->out.r.atts[i].typioparam
+                                             ,-1);
                Py_DECREF(so);
                so = NULL;
                nulls[i] = ' ';
@@ -1730,7 +1736,7 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
                        (errcode(ERRCODE_UNDEFINED_COLUMN),
                         errmsg("no mapping found with key \"%s\"", key),
                         errhint("to return null in specific column, "
-                            "add value None to map with key named after column")));
+                     "add value None to map with key named after column")));
 
            Py_XDECREF(value);
            value = NULL;
@@ -1754,38 +1760,38 @@ PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
 
 
 static HeapTuple
-PLySequence_ToTuple(PLyTypeInfo *info, PyObject *sequence)
+PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
 {
    TupleDesc   desc;
    HeapTuple   tuple;
-   Datum       *values;
-   char        *nulls;
-   int     i;
+   Datum      *values;
+   char       *nulls;
+   int         i;
 
    Assert(PySequence_Check(sequence));
 
    /*
     * Check that sequence length is exactly same as PG tuple's. We actually
-    * can ignore exceeding items or assume missing ones as null but to
-    * avoid plpython developer's errors we are strict here
+    * can ignore exceeding items or assume missing ones as null but to avoid
+    * plpython developer's errors we are strict here
     */
    desc = lookup_rowtype_tupdesc(info->out.d.typoid, -1);
    if (PySequence_Length(sequence) != desc->natts)
        ereport(ERROR,
                (errcode(ERRCODE_DATATYPE_MISMATCH),
-                errmsg("returned sequence's length must be same as tuple's length")));
+       errmsg("returned sequence's length must be same as tuple's length")));
 
    if (info->is_rowtype == 2)
        PLy_output_tuple_funcs(info, desc);
    Assert(info->is_rowtype == 1);
 
    /* Build tuple */
-   values = palloc(sizeof(Datum)*desc->natts);
-   nulls = palloc(sizeof(char)*desc->natts);
-   for (i = 0;  i < desc->natts;  ++i)
+   values = palloc(sizeof(Datum) * desc->natts);
+   nulls = palloc(sizeof(char) * desc->natts);
+   for (i = 0; i < desc->natts; ++i)
    {
-       PyObject    *value,
-               *so;
+       PyObject   *value,
+                  *so;
 
        value = so = NULL;
        PG_TRY();
@@ -1799,16 +1805,16 @@ PLySequence_ToTuple(PLyTypeInfo *info, PyObject *sequence)
            }
            else if (value)
            {
-               char *valuestr;
+               char       *valuestr;
 
                so = PyObject_Str(value);
                if (so == NULL)
                    PLy_elog(ERROR, "can't convert sequence type");
                valuestr = PyString_AsString(so);
                values[i] = InputFunctionCall(&info->out.r.atts[i].typfunc
-                       valuestr
-                       info->out.r.atts[i].typioparam
-                       -1);
+                                             ,valuestr
+                                             ,info->out.r.atts[i].typioparam
+                                             ,-1);
                Py_DECREF(so);
                so = NULL;
                nulls[i] = ' ';
@@ -1836,13 +1842,13 @@ PLySequence_ToTuple(PLyTypeInfo *info, PyObject *sequence)
 
 
 static HeapTuple
-PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
+PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
 {
    TupleDesc   desc;
    HeapTuple   tuple;
-   Datum       *values;
-   char        *nulls;
-   int     i;
+   Datum      *values;
+   char       *nulls;
+   int         i;
 
    desc = lookup_rowtype_tupdesc(info->out.d.typoid, -1);
    if (info->is_rowtype == 2)
@@ -1850,13 +1856,13 @@ PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
    Assert(info->is_rowtype == 1);
 
    /* Build tuple */
-   values = palloc(sizeof(Datum)*desc->natts);
-   nulls = palloc(sizeof(char)*desc->natts);
-   for (i = 0;  i < desc->natts;  ++i)
+   values = palloc(sizeof(Datum) * desc->natts);
+   nulls = palloc(sizeof(char) * desc->natts);
+   for (i = 0; i < desc->natts; ++i)
    {
-       char        *key;
-       PyObject    *value,
-               *so;
+       char       *key;
+       PyObject   *value,
+                  *so;
 
        key = NameStr(desc->attrs[i]->attname);
        value = so = NULL;
@@ -1870,16 +1876,16 @@ PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
            }
            else if (value)
            {
-               char *valuestr;
+               char       *valuestr;
 
                so = PyObject_Str(value);
                if (so == NULL)
                    PLy_elog(ERROR, "can't convert object type");
                valuestr = PyString_AsString(so);
                values[i] = InputFunctionCall(&info->out.r.atts[i].typfunc
-                       valuestr
-                       info->out.r.atts[i].typioparam
-                       -1);
+                                             ,valuestr
+                                             ,info->out.r.atts[i].typioparam
+                                             ,-1);
                Py_DECREF(so);
                so = NULL;
                nulls[i] = ' ';
@@ -1889,8 +1895,8 @@ PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
                        (errcode(ERRCODE_UNDEFINED_COLUMN),
                         errmsg("no attribute named \"%s\"", key),
                         errhint("to return null in specific column, "
-                            "let returned object to have attribute named "
-                            "after column with value None")));
+                              "let returned object to have attribute named "
+                                "after column with value None")));
 
            Py_XDECREF(value);
            value = NULL;
@@ -2450,7 +2456,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
 
                PG_TRY();
                {
-                   char *sv = PyString_AsString(so);
+                   char       *sv = PyString_AsString(so);
 
                    plan->values[i] =
                        InputFunctionCall(&(plan->args[i].out.d.typfunc),
index 44b2e405f32fd788d2f5de53049dff2c979791ef..c6efa75331fdb949d534a09175aff4de2ac81f65 100644 (file)
@@ -2,7 +2,7 @@
  * pltcl.c     - PostgreSQL support for Tcl as
  *               procedural language (PL)
  *
- *   $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.107 2006/08/27 23:47:58 tgl Exp $
+ *   $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.108 2006/10/04 00:30:14 momjian Exp $
  *
  **********************************************************************/
 
@@ -652,15 +652,15 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
        pfree(stroid);
 
        /* The name of the table the trigger is acting on: TG_table_name */
-        stroid = SPI_getrelname(trigdata->tg_relation);
+       stroid = SPI_getrelname(trigdata->tg_relation);
        Tcl_DStringAppendElement(&tcl_cmd, stroid);
-        pfree(stroid);
-       
+       pfree(stroid);
+
        /* The schema of the table the trigger is acting on: TG_table_schema */
-        stroid = SPI_getnspname(trigdata->tg_relation);
+       stroid = SPI_getnspname(trigdata->tg_relation);
        Tcl_DStringAppendElement(&tcl_cmd, stroid);
-        pfree(stroid);
-       
+       pfree(stroid);
+
        /* A list of attribute names for argument TG_relatts */
        Tcl_DStringAppendElement(&tcl_trigtup, "");
        for (i = 0; i < tupdesc->natts; i++)
@@ -878,9 +878,9 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
            fmgr_info(typinput, &finfo);
            UTF_BEGIN;
            modvalues[attnum - 1] = InputFunctionCall(&finfo,
-                                                     (char *) UTF_U2E(ret_value),
+                                                (char *) UTF_U2E(ret_value),
                                                      typioparam,
-                                                     tupdesc->attrs[attnum - 1]->atttypmod);
+                                     tupdesc->attrs[attnum - 1]->atttypmod);
            UTF_END;
        }
 
@@ -2062,7 +2062,7 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
            {
                UTF_BEGIN;
                argvalues[j] = InputFunctionCall(&qdesc->arginfuncs[j],
-                                                (char *) UTF_U2E(callargs[j]),
+                                              (char *) UTF_U2E(callargs[j]),
                                                 qdesc->argtypioparams[j],
                                                 -1);
                UTF_END;
index 18e8d84f698cf280ccff378766db83a4d6ff300e..b267896639e522d81987b11cfcb5dd1e9f6767a3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/port/dirent.c,v 1.2 2006/06/26 12:58:17 momjian Exp $
+ *   $PostgreSQL: pgsql/src/port/dirent.c,v 1.3 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include 
 
 
-struct DIR {
-   char *dirname;
-   struct dirent ret; /* Used to return to caller */
-   HANDLE handle;
+struct DIR
+{
+   char       *dirname;
+   struct dirent ret;          /* Used to return to caller */
+   HANDLE      handle;
 };
 
-DIR* opendir(const char *dirname)
+DIR *
+opendir(const char *dirname)
 {
-   DWORD attr;
-   DIR *d;
+   DWORD       attr;
+   DIR        *d;
 
    /* Make sure it is a directory */
    attr = GetFileAttributes(dirname);
-   if (attr == INVALID_FILE_ATTRIBUTES) 
+   if (attr == INVALID_FILE_ATTRIBUTES)
    {
        errno = ENOENT;
        return NULL;
@@ -47,7 +49,7 @@ DIR* opendir(const char *dirname)
        errno = ENOMEM;
        return NULL;
    }
-   d->dirname = malloc(strlen(dirname)+4);
+   d->dirname = malloc(strlen(dirname) + 4);
    if (!d->dirname)
    {
        errno = ENOMEM;
@@ -55,18 +57,20 @@ DIR* opendir(const char *dirname)
        return NULL;
    }
    strcpy(d->dirname, dirname);
-   if (d->dirname[strlen(d->dirname)-1] != '/' &&
-       d->dirname[strlen(d->dirname)-1] != '\\')
-       strcat(d->dirname,"\\"); /* Append backslash if not already there */
-   strcat(d->dirname,"*");          /* Search for entries named anything */
+   if (d->dirname[strlen(d->dirname) - 1] != '/' &&
+       d->dirname[strlen(d->dirname) - 1] != '\\')
+       strcat(d->dirname, "\\");       /* Append backslash if not already
+                                        * there */
+   strcat(d->dirname, "*");    /* Search for entries named anything */
    d->handle = INVALID_HANDLE_VALUE;
-   d->ret.d_ino = 0; /* no inodes on win32 */
-   d->ret.d_reclen =  0; /* not used on win32 */
+   d->ret.d_ino = 0;           /* no inodes on win32 */
+   d->ret.d_reclen = 0;        /* not used on win32 */
 
    return d;
 }
 
-struct dirent* readdir(DIR * d)
+struct dirent *
+readdir(DIR *d)
 {
    WIN32_FIND_DATA fd;
 
@@ -79,7 +83,7 @@ struct dirent* readdir(DIR * d)
            return NULL;
        }
    }
-   else 
+   else
    {
        if (!FindNextFile(d->handle, &fd))
        {
@@ -93,12 +97,14 @@ struct dirent* readdir(DIR * d)
            return NULL;
        }
    }
-   strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */
+   strcpy(d->ret.d_name, fd.cFileName);        /* Both strings are MAX_PATH
+                                                * long */
    d->ret.d_namlen = strlen(d->ret.d_name);
    return &d->ret;
 }
 
-int closedir(DIR *d)
+int
+closedir(DIR *d)
 {
    if (d->handle != INVALID_HANDLE_VALUE)
        FindClose(d->handle);
index 6ebfdc926a7d6cabd8e889aa817e5e850d4942f4..b25db737a14f53cfc9549aff518dae02295ea63f 100644 (file)
@@ -16,7 +16,7 @@
  * Copyright (c) 2003-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.25 2006/07/16 20:28:01 tgl Exp $
+ *   $PostgreSQL: pgsql/src/port/getaddrinfo.c,v 1.26 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -329,7 +329,8 @@ gai_strerror(int errcode)
            return "Not enough memory";
 #endif
 #ifdef EAI_NODATA
-#ifndef WIN32_ONLY_COMPILER    /* MSVC complains because another case has the same value */
+#ifndef WIN32_ONLY_COMPILER        /* MSVC complains because another case has the
+                                * same value */
        case EAI_NODATA:
            return "No host data of that type was found";
 #endif
index d08e99c6453e37bf81a1c20b9adc04de8a688655..809361b55d2cd0af6f8345b71b0145d579289326 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/port/isinf.c,v 1.9 2006/03/05 15:59:10 momjian Exp $
+ *   $PostgreSQL: pgsql/src/port/isinf.c,v 1.10 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -73,4 +73,5 @@ isinf(double x)
    return 0;
 }
 #endif
+
 #endif
index 125cad0550357c48c0f25dce84dd9c2eb02fa084..83fc1ca2818da30b1d2b1c97cca54c8df3ade241 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/port/open.c,v 1.16 2006/10/03 20:44:18 momjian Exp $
+ * $PostgreSQL: pgsql/src/port/open.c,v 1.17 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -108,7 +108,7 @@ pgwin32_open(const char *fileName, int fileFlags,...)
    if ((fd = _open_osfhandle((long) h, fileFlags & O_APPEND)) < 0)
        CloseHandle(h);         /* will not affect errno */
    else if (fileFlags & (O_TEXT | O_BINARY) &&
-       _setmode(fd, fileFlags & (O_TEXT | O_BINARY)) < 0)
+            _setmode(fd, fileFlags & (O_TEXT | O_BINARY)) < 0)
    {
        _close(fd);
        return -1;
@@ -120,9 +120,9 @@ pgwin32_open(const char *fileName, int fileFlags,...)
 FILE *
 pgwin32_fopen(const char *fileName, const char *mode)
 {
-   int openmode = 0;
-   int fd;
-   
+   int         openmode = 0;
+   int         fd;
+
    if (strstr(mode, "r+"))
        openmode |= O_RDWR;
    else if (strchr(mode, 'r'))
@@ -138,7 +138,7 @@ pgwin32_fopen(const char *fileName, const char *mode)
        openmode |= O_BINARY;
    if (strchr(mode, 't'))
        openmode |= O_TEXT;
-   
+
    fd = pgwin32_open(fileName, openmode);
    if (fd == -1)
        return NULL;
index a7d5ec7c4528b94e6a149f93fb14ef6ae6f73ae7..28608e979cf29e5a699a94f8fcd467dcd0c6db21 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/port/path.c,v 1.69 2006/09/27 18:40:10 tgl Exp $
+ *   $PostgreSQL: pgsql/src/port/path.c,v 1.70 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -388,8 +388,8 @@ path_is_prefix_of_path(const char *path1, const char *path2)
 const char *
 get_progname(const char *argv0)
 {
-   const char  *nodir_name;
-   char        *progname;
+   const char *nodir_name;
+   char       *progname;
 
    nodir_name = last_dir_separator(argv0);
    if (nodir_name)
@@ -398,20 +398,20 @@ get_progname(const char *argv0)
        nodir_name = skip_drive(argv0);
 
    /*
-    *  Make a copy in case argv[0] is modified by ps_status.
-    *  Leaks memory, but called only once.
+    * Make a copy in case argv[0] is modified by ps_status. Leaks memory, but
+    * called only once.
     */
    progname = strdup(nodir_name);
    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 */
    }
 
 #if defined(__CYGWIN__) || defined(WIN32)
    /* strip ".exe" suffix, regardless of case */
    if (strlen(progname) > sizeof(EXE) - 1 &&
-       pg_strcasecmp(progname + strlen(progname) - (sizeof(EXE) - 1), EXE) == 0)
+   pg_strcasecmp(progname + strlen(progname) - (sizeof(EXE) - 1), EXE) == 0)
        progname[strlen(progname) - (sizeof(EXE) - 1)] = '\0';
 #endif
 
@@ -502,7 +502,7 @@ make_relative_path(char *ret_path, const char *target_path,
     */
    tail_start = (int) strlen(ret_path) - tail_len;
    if (tail_start > 0 &&
-       IS_DIR_SEP(ret_path[tail_start-1]) &&
+       IS_DIR_SEP(ret_path[tail_start - 1]) &&
        dir_strcmp(ret_path + tail_start, bin_path + prefix_len) == 0)
    {
        ret_path[tail_start] = '\0';
index b003d3494db9ba28bc7c88c06e76b0398fce2d06..595812b3567d149a9eeb1d4965af3d0bbedf6da1 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.8 2006/07/16 20:17:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/port/pgsleep.c,v 1.9 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,4 +47,4 @@ pg_usleep(long microsec)
    }
 }
 
-#endif /* defined(FRONTEND) || !defined(WIN32) */
+#endif   /* defined(FRONTEND) || !defined(WIN32) */
index ac7b149b5ff202864efda554be946ebd98318211..9e69462f0ad4791780727e69bac62e1d8b354afc 100644 (file)
@@ -9,7 +9,7 @@
  *
  * CAUTION: if you change this file, see also qsort.c
  *
- * $PostgreSQL: pgsql/src/port/qsort_arg.c,v 1.1 2006/10/03 22:18:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/port/qsort_arg.c,v 1.2 2006/10/04 00:30:14 momjian Exp $
  */
 
 /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $   */
@@ -47,7 +47,7 @@
 
 
 static char *med3(char *a, char *b, char *c,
-                 qsort_arg_comparator cmp, void *arg);
+    qsort_arg_comparator cmp, void *arg);
 static void swapfunc(char *, char *, size_t, int);
 
 #define min(a, b)  ((a) < (b) ? (a) : (b))
index dffe0fe359b950d8b1400064203dfdd3a63f0fb9..e4472e5bdb47ad91558e88ea0e4d4924a2a65518 100644 (file)
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $PostgreSQL: pgsql/src/port/snprintf.c,v 1.31 2005/12/05 21:57:00 tgl Exp $
+ * $PostgreSQL: pgsql/src/port/snprintf.c,v 1.32 2006/10/04 00:30:14 momjian Exp $
  */
 
 #include "c.h"
@@ -70,7 +70,7 @@
  * platforms.  This implementation is compatible with the Single Unix Spec:
  *
  * 1. -1 is returned only if processing is abandoned due to an invalid
- * parameter, such as incorrect format string.  (Although not required by
+ * parameter, such as incorrect format string. (Although not required by
  * the spec, this happens only when no characters have yet been transmitted
  * to the destination.)
  *
@@ -146,7 +146,7 @@ static int  dopr(PrintfTarget *target, const char *format, va_list args);
 int
 pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args)
 {
-   PrintfTarget    target;
+   PrintfTarget target;
 
    if (str == NULL || count == 0)
        return 0;
@@ -179,7 +179,7 @@ pg_snprintf(char *str, size_t count, const char *fmt,...)
 static int
 pg_vsprintf(char *str, const char *fmt, va_list args)
 {
-   PrintfTarget    target;
+   PrintfTarget target;
 
    if (str == NULL)
        return 0;
@@ -212,7 +212,7 @@ pg_sprintf(char *str, const char *fmt,...)
 static int
 pg_vfprintf(FILE *stream, const char *fmt, va_list args)
 {
-   PrintfTarget    target;
+   PrintfTarget target;
    char        buffer[1024];   /* size is arbitrary */
 
    if (stream == NULL)
@@ -262,7 +262,7 @@ pg_printf(const char *fmt,...)
 static void
 flushbuffer(PrintfTarget *target)
 {
-   size_t  nc = target->bufptr - target->bufstart;
+   size_t      nc = target->bufptr - target->bufstart;
 
    if (nc > 0)
        target->nchars += fwrite(target->bufstart, 1, nc, target->stream);
@@ -278,8 +278,8 @@ static void fmtint(int64 value, char type, int forcesign,
       PrintfTarget *target);
 static void fmtchar(int value, int leftjust, int minlen, PrintfTarget *target);
 static void fmtfloat(double value, char type, int forcesign,
-       int leftjust, int minlen, int zpad, int precision, int pointflag,
-       PrintfTarget *target);
+        int leftjust, int minlen, int zpad, int precision, int pointflag,
+        PrintfTarget *target);
 static void dostr(const char *str, int slen, PrintfTarget *target);
 static void dopr_outch(int c, PrintfTarget *target);
 static int adjust_sign(int is_negative, int forcesign, int *signvalue);
@@ -317,8 +317,8 @@ dopr(PrintfTarget *target, const char *format, va_list args)
    double      fvalue;
    char       *strvalue;
    int         i;
-   PrintfArgType argtypes[NL_ARGMAX+1];
-   PrintfArgValue argvalues[NL_ARGMAX+1];
+   PrintfArgType argtypes[NL_ARGMAX + 1];
+   PrintfArgValue argvalues[NL_ARGMAX + 1];
 
    /*
     * Parse the format string to determine whether there are %n$ format
@@ -335,7 +335,7 @@ dopr(PrintfTarget *target, const char *format, va_list args)
        longflag = longlongflag = pointflag = 0;
        fmtpos = accum = 0;
        afterstar = false;
-   nextch1:
+nextch1:
        ch = *format++;
        if (ch == '\0')
            break;              /* illegal, but we don't complain */
@@ -362,7 +362,7 @@ dopr(PrintfTarget *target, const char *format, va_list args)
                goto nextch1;
            case '*':
                if (afterstar)
-                   have_non_dollar = true; /* multiple stars */
+                   have_non_dollar = true;     /* multiple stars */
                afterstar = true;
                accum = 0;
                goto nextch1;
@@ -462,6 +462,7 @@ dopr(PrintfTarget *target, const char *format, va_list args)
            case '%':
                break;
        }
+
        /*
         * If we finish the spec with afterstar still set, there's a
         * non-dollar star in there.
@@ -516,7 +517,7 @@ dopr(PrintfTarget *target, const char *format, va_list args)
        longflag = longlongflag = pointflag = 0;
        fmtpos = accum = 0;
        have_star = afterstar = false;
-   nextch2:
+nextch2:
        ch = *format++;
        if (ch == '\0')
            break;              /* illegal, but we don't complain */
@@ -561,7 +562,7 @@ dopr(PrintfTarget *target, const char *format, va_list args)
                else
                {
                    /* fetch and process value now */
-                   int     starval = va_arg(args, int);
+                   int         starval = va_arg(args, int);
 
                    if (pointflag)
                    {
@@ -586,7 +587,7 @@ dopr(PrintfTarget *target, const char *format, va_list args)
                if (afterstar)
                {
                    /* fetch and process star value */
-                   int     starval = argvalues[accum].i;
+                   int         starval = argvalues[accum].i;
 
                    if (pointflag)
                    {
@@ -854,7 +855,7 @@ fmtint(int64 value, char type, int forcesign, int leftjust,
    else
    {
        /* make integer string */
-       uint64  uvalue = (uint64) value;
+       uint64      uvalue = (uint64) value;
 
        do
        {
@@ -932,17 +933,17 @@ dostr(const char *str, int slen, PrintfTarget *target)
 {
    while (slen > 0)
    {
-       int     avail;
+       int         avail;
 
        if (target->bufend != NULL)
            avail = target->bufend - target->bufptr;
-       else 
+       else
            avail = slen;
        if (avail <= 0)
        {
            /* buffer full, can we dump to stream? */
            if (target->stream == NULL)
-               return;             /* no, lose the data */
+               return;         /* no, lose the data */
            flushbuffer(target);
            continue;
        }
index eff3fa5ad1325c96895ca06a0fb46f333e0fd4f7..8681fb20dce0cc1fca0da44f9df1d98aba4759ed 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/port/sprompt.c,v 1.17 2006/06/14 16:49:03 tgl Exp $
+ *   $PostgreSQL: pgsql/src/port/sprompt.c,v 1.18 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -64,7 +64,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
    termout = fopen(DEVTTY, "w");
    if (!termin || !termout
 #ifdef WIN32
-       /* See DEVTTY comment for msys */
+   /* See DEVTTY comment for msys */
        || (getenv("OSTYPE") && strcmp(getenv("OSTYPE"), "msys") == 0)
 #endif
        )
index aef53da2faca9818577b59a678a2ad29f12bb0ed..00738bfef85f1d14e5157feba92fdbd9b67e47a3 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/port/strlcpy.c,v 1.2 2006/10/02 23:58:59 momjian Exp $
+ *   $PostgreSQL: pgsql/src/port/strlcpy.c,v 1.3 2006/10/04 00:30:14 momjian Exp $
  *
  * This file was taken from OpenBSD and is used on platforms that don't
  * provide strlcpy().  The OpenBSD copyright terms follow.
 
 
 /*
- * Copy src to string dst of size siz.  At most siz-1 characters
- * will be copied.  Always NUL terminates (unless siz == 0).
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
  * Returns strlen(src); if retval >= siz, truncation occurred.
  * Function creation history:  http://www.gratisoft.us/todd/papers/strlcpy.html
  */
 size_t
 strlcpy(char *dst, const char *src, size_t siz)
 {
-   char *d = dst;
+   char       *d = dst;
    const char *s = src;
-   size_t n = siz;
+   size_t      n = siz;
 
    /* Copy as many bytes as will fit */
-   if (n != 0) {
-       while (--n != 0) {
+   if (n != 0)
+   {
+       while (--n != 0)
+       {
            if ((*d++ = *s++) == '\0')
                break;
        }
    }
 
    /* Not enough room in dst, add NUL and traverse rest of src */
-   if (n == 0) {
+   if (n == 0)
+   {
        if (siz != 0)
-           *d = '\0';      /* NUL-terminate dst */
+           *d = '\0';          /* NUL-terminate dst */
        while (*s++)
            ;
    }
 
-   return(s - src - 1);    /* count does not include NUL */
+   return (s - src - 1);       /* count does not include NUL */
 }
index 0a9a4e713474a5aeba831b17f860d0aa9d9e8fd1..2f4fac1fd63debcf5eb082909bad99ba4981d97c 100644 (file)
@@ -52,7 +52,7 @@ static char sccsid[] = "@(#)strtol.c  5.4 (Berkeley) 2/23/91";
  * before calling this function, and then errno != 0 can be tested
  * after the function completes.
  */
+
 /*
  * Convert a string to a long integer.
  *
index de70348815f821e91d345297401d36575c4a1020..5daf28a666d93791894f5871211b31bf2c7900e6 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.22 2006/09/24 17:10:18 tgl Exp $
+ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.23 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 /* simple list of strings */
 typedef struct _stringlist
 {
-   char *str;
+   char       *str;
    struct _stringlist *next;
-} _stringlist;
+}  _stringlist;
 
 /* for resultmap we need a list of pairs of strings */
 typedef struct _resultmap
 {
-   char *test;
-   char *resultfile;
+   char       *test;
+   char       *resultfile;
    struct _resultmap *next;
-} _resultmap;
+}  _resultmap;
 
 /*
  * Values obtained from pg_config_paths.h and Makefile.  The PG installation
@@ -63,6 +63,7 @@ static char *libdir = LIBDIR;
 static char *datadir = PGSHAREDIR;
 static char *host_platform = HOST_TUPLE;
 static char *makeprog = MAKEPROG;
+
 #ifndef WIN32                  /* not used in WIN32 case */
 static char *shellprog = SHELLPROG;
 #endif
@@ -77,17 +78,17 @@ static bool debug = false;
 static char *inputdir = ".";
 static char *outputdir = ".";
 static _stringlist *loadlanguage = NULL;
-static int max_connections = 0;
+static int max_connections = 0;
 static char *encoding = NULL;
 static _stringlist *schedulelist = NULL;
 static _stringlist *extra_tests = NULL;
 static char *temp_install = NULL;
 static char *top_builddir = NULL;
-static int temp_port = 65432;
+static int temp_port = 65432;
 static bool nolocale = false;
 static char *psqldir = NULL;
 static char *hostname = NULL;
-static int port = -1;
+static int port = -1;
 static char *user = NULL;
 
 /* internal variables */
@@ -101,9 +102,9 @@ static _resultmap *resultmap = NULL;
 static PID_TYPE postmaster_pid = INVALID_PID;
 static bool postmaster_running = false;
 
-static int success_count = 0;
-static int fail_count = 0;
-static int fail_ignore_count = 0;
+static int success_count = 0;
+static int fail_count = 0;
+static int fail_ignore_count = 0;
 
 static void
 header(const char *fmt,...)
@@ -116,7 +117,7 @@ status(const char *fmt,...)
    the supplied arguments. */
 __attribute__((format(printf, 1, 2)));
 static void
-psql_command(const char *database, const char *query, ...)
+psql_command(const char *database, const char *query,...)
 /* This extension allows gcc to check the format string for consistency with
    the supplied arguments. */
 __attribute__((format(printf, 2, 3)));
@@ -126,7 +127,7 @@ __attribute__((format(printf, 2, 3)));
  * Add an item at the end of a stringlist.
  */
 static void
-add_stringlist_item(_stringlist **listhead, const char *str)
+add_stringlist_item(_stringlist ** listhead, const char *str)
 {
    _stringlist *newentry = malloc(sizeof(_stringlist));
    _stringlist *oldentry;
@@ -138,7 +139,7 @@ add_stringlist_item(_stringlist **listhead, const char *str)
    else
    {
        for (oldentry = *listhead; oldentry->next; oldentry = oldentry->next)
-           /*skip*/;
+            /* skip */ ;
        oldentry->next = newentry;
    }
 }
@@ -202,7 +203,7 @@ stop_postmaster(void)
    if (postmaster_running)
    {
        /* We use pg_ctl to issue the kill and wait for stop */
-       char buf[MAXPGPATH * 2];
+       char        buf[MAXPGPATH * 2];
 
        /* On Windows, system() seems not to force fflush, so... */
        fflush(stdout);
@@ -304,24 +305,24 @@ string_matches_pattern(const char *str, const char *pattern)
  * Scan resultmap file to find which platform-specific expected files to use.
  *
  * The format of each line of the file is
- *         testname/hostplatformpattern=substitutefile
+ *        testname/hostplatformpattern=substitutefile
  * where the hostplatformpattern is evaluated per the rules of expr(1),
  * namely, it is a standard regular expression with an implicit ^ at the start.
  * (We currently support only a very limited subset of regular expressions,
  * see string_matches_pattern() above.)  What hostplatformpattern will be
- * matched against is the config.guess output.  (In the shell-script version,
+ * matched against is the config.guess output. (In the shell-script version,
  * we also provided an indication of whether gcc or another compiler was in
  * use, but that facility isn't used anymore.)
  */
 static void
 load_resultmap(void)
 {
-   char buf[MAXPGPATH];
-   FILE *f;
+   char        buf[MAXPGPATH];
+   FILE       *f;
 
    /* scan the file ... */
    snprintf(buf, sizeof(buf), "%s/resultmap", inputdir);
-   f = fopen(buf,"r");
+   f = fopen(buf, "r");
    if (!f)
    {
        /* OK if it doesn't exist, else complain */
@@ -334,13 +335,13 @@ load_resultmap(void)
 
    while (fgets(buf, sizeof(buf), f))
    {
-       char *platform;
-       char *expected;
-       int i;
+       char       *platform;
+       char       *expected;
+       int         i;
 
        /* strip trailing whitespace, especially the newline */
        i = strlen(buf);
-       while (i > 0 && isspace((unsigned char) buf[i-1]))
+       while (i > 0 && isspace((unsigned char) buf[i - 1]))
            buf[--i] = '\0';
 
        /* parse out the line fields */
@@ -362,10 +363,10 @@ load_resultmap(void)
        *expected++ = '\0';
 
        /*
-        * if it's for current platform, save it in resultmap list.
-        * Note: by adding at the front of the list, we ensure that in
-        * ambiguous cases, the last match in the resultmap file is used.
-        * This mimics the behavior of the old shell script.
+        * if it's for current platform, save it in resultmap list. Note: by
+        * adding at the front of the list, we ensure that in ambiguous cases,
+        * the last match in the resultmap file is used. This mimics the
+        * behavior of the old shell script.
         */
        if (string_matches_pattern(host_platform, platform))
        {
@@ -386,7 +387,7 @@ load_resultmap(void)
 static void
 doputenv(const char *var, const char *val)
 {
-   char *s = malloc(strlen(var)+strlen(val)+2);
+   char       *s = malloc(strlen(var) + strlen(val) + 2);
 
    sprintf(s, "%s=%s", var, val);
    putenv(s);
@@ -399,8 +400,8 @@ doputenv(const char *var, const char *val)
 static void
 add_to_path(const char *pathname, char separator, const char *addval)
 {
-   char *oldval = getenv(pathname);
-   char *newval;
+   char       *oldval = getenv(pathname);
+   char       *newval;
 
    if (!oldval || !oldval[0])
    {
@@ -411,7 +412,7 @@ add_to_path(const char *pathname, char separator, const char *addval)
    else
    {
        newval = malloc(strlen(pathname) + strlen(addval) + strlen(oldval) + 3);
-       sprintf(newval,"%s=%s%c%s",pathname,addval,separator,oldval);
+       sprintf(newval, "%s=%s%c%s", pathname, addval, separator, oldval);
    }
    putenv(newval);
 }
@@ -422,7 +423,7 @@ add_to_path(const char *pathname, char separator, const char *addval)
 static void
 initialize_environment(void)
 {
-   char *tmp;
+   char       *tmp;
 
    /*
     * Clear out any non-C locale settings
@@ -458,12 +459,12 @@ initialize_environment(void)
    if (temp_install)
    {
        /*
-        * Clear out any environment vars that might cause psql to connect
-        * to the wrong postmaster, or otherwise behave in nondefault ways.
-        * (Note we also use psql's -X switch consistently, so that ~/.psqlrc
-        * files won't mess things up.)  Also, set PGPORT to the temp port,
-        * and set or unset PGHOST depending on whether we are using TCP or
-        * Unix sockets.
+        * Clear out any environment vars that might cause psql to connect to
+        * the wrong postmaster, or otherwise behave in nondefault ways. (Note
+        * we also use psql's -X switch consistently, so that ~/.psqlrc files
+        * won't mess things up.)  Also, set PGPORT to the temp port, and set
+        * or unset PGHOST depending on whether we are using TCP or Unix
+        * sockets.
         */
        unsetenv("PGDATABASE");
        unsetenv("PGUSER");
@@ -479,10 +480,10 @@ initialize_environment(void)
        unsetenv("PGHOSTADDR");
        if (port != -1)
        {
-           char s[16];
+           char        s[16];
 
-           sprintf(s,"%d",port);
-           doputenv("PGPORT",s);
+           sprintf(s, "%d", port);
+           doputenv("PGPORT", s);
        }
 
        /*
@@ -507,10 +508,10 @@ initialize_environment(void)
         * Set up shared library paths to include the temp install.
         *
         * LD_LIBRARY_PATH covers many platforms.  DYLD_LIBRARY_PATH works on
-        * Darwin, and maybe other Mach-based systems.  LIBPATH is for AIX.
+        * Darwin, and maybe other Mach-based systems.  LIBPATH is for AIX.
         * Windows needs shared libraries in PATH (only those linked into
-        * executables, not dlopen'ed ones).
-        * Feel free to account for others as well.
+        * executables, not dlopen'ed ones). Feel free to account for others
+        * as well.
         */
        add_to_path("LD_LIBRARY_PATH", ':', libdir);
        add_to_path("DYLD_LIBRARY_PATH", ':', libdir);
@@ -535,10 +536,10 @@ initialize_environment(void)
        }
        if (port != -1)
        {
-           char s[16];
+           char        s[16];
 
-           sprintf(s,"%d",port);
-           doputenv("PGPORT",s);
+           sprintf(s, "%d", port);
+           doputenv("PGPORT", s);
        }
        if (user != NULL)
            doputenv("PGUSER", user);
@@ -572,14 +573,14 @@ initialize_environment(void)
  * Since we use system(), this doesn't return until the operation finishes
  */
 static void
-psql_command(const char *database, const char *query, ...)
+psql_command(const char *database, const char *query,...)
 {
-   char query_formatted[1024];
-   char query_escaped[2048];
-   char psql_cmd[MAXPGPATH + 2048];
-   va_list args;
-   char *s;
-   char *d;
+   char        query_formatted[1024];
+   char        query_escaped[2048];
+   char        psql_cmd[MAXPGPATH + 2048];
+   va_list     args;
+   char       *s;
+   char       *d;
 
    /* Generate the query with insertion of sprintf arguments */
    va_start(args, query);
@@ -621,10 +622,10 @@ static PID_TYPE
 spawn_process(const char *cmdline)
 {
 #ifndef WIN32
-   pid_t pid;
+   pid_t       pid;
 
    /*
-    * Must flush I/O buffers before fork.  Ideally we'd use fflush(NULL) here
+    * Must flush I/O buffers before fork.  Ideally we'd use fflush(NULL) here
     * ... does anyone still care about systems where that doesn't work?
     */
    fflush(stdout);
@@ -644,11 +645,11 @@ spawn_process(const char *cmdline)
        /*
         * In child
         *
-        * Instead of using system(), exec the shell directly, and tell it
-        * to "exec" the command too.  This saves two useless processes
-        * per parallel test case.
+        * Instead of using system(), exec the shell directly, and tell it to
+        * "exec" the command too.  This saves two useless processes per
+        * parallel test case.
         */
-       char *cmdline2 = malloc(strlen(cmdline) + 6);
+       char       *cmdline2 = malloc(strlen(cmdline) + 6);
 
        sprintf(cmdline2, "exec %s", cmdline);
        execl(shellprog, shellprog, "-c", cmdline2, NULL);
@@ -659,7 +660,7 @@ spawn_process(const char *cmdline)
    /* in parent */
    return pid;
 #else
-   char *cmdline2;
+   char       *cmdline2;
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
 
@@ -689,10 +690,10 @@ spawn_process(const char *cmdline)
 static PID_TYPE
 psql_start_test(const char *testname)
 {
-   PID_TYPE pid;
-   char infile[MAXPGPATH];
-   char outfile[MAXPGPATH];
-   char psql_cmd[MAXPGPATH * 3];
+   PID_TYPE    pid;
+   char        infile[MAXPGPATH];
+   char        outfile[MAXPGPATH];
+   char        psql_cmd[MAXPGPATH * 3];
 
    snprintf(infile, sizeof(infile), "%s/sql/%s.sql",
             inputdir, testname);
@@ -725,8 +726,8 @@ psql_start_test(const char *testname)
 static long
 file_size(const char *file)
 {
-   long r;
-   FILE *f = fopen(file,"r");
+   long        r;
+   FILE       *f = fopen(file, "r");
 
    if (!f)
    {
@@ -746,9 +747,9 @@ file_size(const char *file)
 static int
 file_line_count(const char *file)
 {
-   int c;
-   int l = 0;
-   FILE *f = fopen(file,"r");
+   int         c;
+   int         l = 0;
+   FILE       *f = fopen(file, "r");
 
    if (!f)
    {
@@ -768,7 +769,7 @@ file_line_count(const char *file)
 static bool
 file_exists(const char *file)
 {
-   FILE *f = fopen(file, "r");
+   FILE       *f = fopen(file, "r");
 
    if (!f)
        return false;
@@ -806,7 +807,7 @@ make_directory(const char *dir)
 static int
 run_diff(const char *cmd, const char *filename)
 {
-   int r;
+   int         r;
 
    r = system(cmd);
    if (!WIFEXITED(r) || WEXITSTATUS(r) > 1)
@@ -815,9 +816,10 @@ run_diff(const char *cmd, const char *filename)
        exit_nicely(2);
    }
 #ifdef WIN32
+
    /*
-    *  On WIN32, if the 'diff' command cannot be found, system() returns
-    *  1, but produces nothing to stdout, so we check for that here.
+    * On WIN32, if the 'diff' command cannot be found, system() returns 1,
+    * but produces nothing to stdout, so we check for that here.
     */
    if (WEXITSTATUS(r) == 1 && file_size(filename) <= 0)
    {
@@ -825,7 +827,7 @@ run_diff(const char *cmd, const char *filename)
        exit_nicely(2);
    }
 #endif
-   
+
    return WEXITSTATUS(r);
 }
 
@@ -839,17 +841,17 @@ static bool
 results_differ(const char *testname)
 {
    const char *expectname;
-   char resultsfile[MAXPGPATH];
-   char expectfile[MAXPGPATH];
-   char diff[MAXPGPATH];
-   char cmd[MAXPGPATH * 3];
-   char best_expect_file[MAXPGPATH];
+   char        resultsfile[MAXPGPATH];
+   char        expectfile[MAXPGPATH];
+   char        diff[MAXPGPATH];
+   char        cmd[MAXPGPATH * 3];
+   char        best_expect_file[MAXPGPATH];
    _resultmap *rm;
-   FILE *difffile;
-   int best_line_count;
-   int i;
-   int l;
-   
+   FILE       *difffile;
+   int         best_line_count;
+   int         i;
+   int         l;
+
    /* Check in resultmap if we should be looking at a different file */
    expectname = testname;
    for (rm = resultmap; rm != NULL; rm = rm->next)
@@ -915,9 +917,9 @@ results_differ(const char *testname)
        }
    }
 
-   /* 
-    * fall back on the canonical results file if we haven't tried it yet
-    * and haven't found a complete match yet.
+   /*
+    * fall back on the canonical results file if we haven't tried it yet and
+    * haven't found a complete match yet.
     */
 
    if (strcmp(expectname, testname) != 0)
@@ -946,8 +948,8 @@ results_differ(const char *testname)
    }
 
    /*
-    * Use the best comparison file to generate the "pretty" diff, which
-    * we append to the diffs summary file.
+    * Use the best comparison file to generate the "pretty" diff, which we
+    * append to the diffs summary file.
     */
    snprintf(cmd, sizeof(cmd),
             SYSTEMQUOTE "diff %s \"%s\" \"%s\" >> \"%s\"" SYSTEMQUOTE,
@@ -975,13 +977,13 @@ results_differ(const char *testname)
  * Note: it's OK to scribble on the pids array, but not on the names array
  */
 static void
-wait_for_tests(PID_TYPE *pids, char **names, int num_tests)
+wait_for_tests(PID_TYPE * pids, char **names, int num_tests)
 {
-   int tests_left;
-   int i;
+   int         tests_left;
+   int         i;
 
 #ifdef WIN32
-   PID_TYPE *active_pids = malloc(num_tests * sizeof(PID_TYPE));
+   PID_TYPE   *active_pids = malloc(num_tests * sizeof(PID_TYPE));
 
    memcpy(active_pids, pids, num_tests * sizeof(PID_TYPE));
 #endif
@@ -989,7 +991,7 @@ wait_for_tests(PID_TYPE *pids, char **names, int num_tests)
    tests_left = num_tests;
    while (tests_left > 0)
    {
-       PID_TYPE p;
+       PID_TYPE    p;
 
 #ifndef WIN32
        p = wait(NULL);
@@ -1001,7 +1003,7 @@ wait_for_tests(PID_TYPE *pids, char **names, int num_tests)
            exit_nicely(2);
        }
 #else
-       int r;
+       int         r;
 
        r = WaitForMultipleObjects(tests_left, active_pids, FALSE, INFINITE);
        if (r < WAIT_OBJECT_0 || r >= WAIT_OBJECT_0 + tests_left)
@@ -1013,9 +1015,9 @@ wait_for_tests(PID_TYPE *pids, char **names, int num_tests)
        p = active_pids[r - WAIT_OBJECT_0];
        /* compact the active_pids array */
        active_pids[r - WAIT_OBJECT_0] = active_pids[tests_left - 1];
-#endif /* WIN32 */
+#endif   /* WIN32 */
 
-       for (i=0; i < num_tests; i++)
+       for (i = 0; i < num_tests; i++)
        {
            if (p == pids[i])
            {
@@ -1043,12 +1045,12 @@ static void
 run_schedule(const char *schedule)
 {
 #define MAX_PARALLEL_TESTS 100
-   char *tests[MAX_PARALLEL_TESTS];
-   PID_TYPE pids[MAX_PARALLEL_TESTS];
+   char       *tests[MAX_PARALLEL_TESTS];
+   PID_TYPE    pids[MAX_PARALLEL_TESTS];
    _stringlist *ignorelist = NULL;
-   char scbuf[1024];
-   FILE *scf;
-   int line_num = 0;
+   char        scbuf[1024];
+   FILE       *scf;
+   int         line_num = 0;
 
    scf = fopen(schedule, "r");
    if (!scf)
@@ -1060,17 +1062,17 @@ run_schedule(const char *schedule)
 
    while (fgets(scbuf, sizeof(scbuf), scf))
    {
-       char *test = NULL;
-       char *c;
-       int num_tests;
-       bool inword;
-       int i;
+       char       *test = NULL;
+       char       *c;
+       int         num_tests;
+       bool        inword;
+       int         i;
 
        line_num++;
 
        /* strip trailing whitespace, especially the newline */
        i = strlen(scbuf);
-       while (i > 0 && isspace((unsigned char) scbuf[i-1]))
+       while (i > 0 && isspace((unsigned char) scbuf[i - 1]))
            scbuf[--i] = '\0';
 
        if (scbuf[0] == '\0' || scbuf[0] == '#')
@@ -1083,10 +1085,11 @@ run_schedule(const char *schedule)
            while (*c && isspace((unsigned char) *c))
                c++;
            add_stringlist_item(&ignorelist, c);
+
            /*
             * Note: ignore: lines do not run the test, they just say that
-            * failure of this test when run later on is to be ignored.
-            * A bit odd but that's how the shell-script version did it.
+            * failure of this test when run later on is to be ignored. A bit
+            * odd but that's how the shell-script version did it.
             */
            continue;
        }
@@ -1137,7 +1140,7 @@ run_schedule(const char *schedule)
        }
        else if (max_connections > 0 && max_connections < num_tests)
        {
-           int oldest = 0;
+           int         oldest = 0;
 
            status(_("parallel group (%d tests, in groups of %d): "),
                   num_tests, max_connections);
@@ -1172,7 +1175,7 @@ run_schedule(const char *schedule)
 
            if (results_differ(tests[i]))
            {
-               bool ignore = false;
+               bool        ignore = false;
                _stringlist *sl;
 
                for (sl = ignorelist; sl != NULL; sl = sl->next)
@@ -1213,7 +1216,7 @@ run_schedule(const char *schedule)
 static void
 run_single_test(const char *test)
 {
-   PID_TYPE pid;
+   PID_TYPE    pid;
 
    status(_("test %-20s ... "), test);
    pid = psql_start_test(test);
@@ -1238,8 +1241,8 @@ run_single_test(const char *test)
 static void
 open_result_files(void)
 {
-   char file[MAXPGPATH];
-   FILE *difffile;
+   char        file[MAXPGPATH];
+   FILE       *difffile;
 
    /* create the log file (copy of running status output) */
    snprintf(file, sizeof(file), "%s/regression.out", outputdir);
@@ -1313,10 +1316,10 @@ int
 main(int argc, char *argv[])
 {
    _stringlist *sl;
-   int c;
-   int i;
-   int option_index;
-   char buf[MAXPGPATH * 4];
+   int         c;
+   int         i;
+   int         option_index;
+   char        buf[MAXPGPATH * 4];
 
    static struct option long_options[] = {
        {"help", no_argument, NULL, 'h'},
@@ -1388,7 +1391,7 @@ main(int argc, char *argv[])
                    temp_install = strdup(optarg);
                else
                {
-                   char cwdbuf[MAXPGPATH];
+                   char        cwdbuf[MAXPGPATH];
 
                    if (!getcwd(cwdbuf, sizeof(cwdbuf)))
                    {
@@ -1396,7 +1399,7 @@ main(int argc, char *argv[])
                        exit_nicely(2);
                    }
                    temp_install = malloc(strlen(cwdbuf) + strlen(optarg) + 2);
-                   sprintf(temp_install,"%s/%s", cwdbuf, optarg);
+                   sprintf(temp_install, "%s/%s", cwdbuf, optarg);
                }
                canonicalize_path(temp_install);
                break;
@@ -1408,7 +1411,7 @@ main(int argc, char *argv[])
                break;
            case 12:
                {
-                   int p = atoi(optarg);
+                   int         p = atoi(optarg);
 
                    /* Since Makefile isn't very bright, check port range */
                    if (p >= 1024 && p <= 65535)
@@ -1470,7 +1473,7 @@ main(int argc, char *argv[])
        if (directory_exists(temp_install))
        {
            header(_("removing existing temp installation"));
-           rmtree(temp_install,true);
+           rmtree(temp_install, true);
        }
 
        header(_("creating temporary installation"));
@@ -1526,9 +1529,9 @@ main(int argc, char *argv[])
        }
 
        /*
-        * Wait till postmaster is able to accept connections (normally only
-        * a second or so, but Cygwin is reportedly *much* slower).  Don't
-        * wait forever, however.
+        * Wait till postmaster is able to accept connections (normally only a
+        * second or so, but Cygwin is reportedly *much* slower).  Don't wait
+        * forever, however.
         */
        snprintf(buf, sizeof(buf),
                 SYSTEMQUOTE "\"%s/psql\" -X postgres <%s 2>%s" SYSTEMQUOTE,
@@ -1559,9 +1562,9 @@ main(int argc, char *argv[])
            fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
 
            /*
-            * If we get here, the postmaster is probably wedged somewhere
-            * in startup.  Try to kill it ungracefully rather than leaving
-            * stuck postmaster that might interfere with subsequent test
+            * If we get here, the postmaster is probably wedged somewhere in
+            * startup.  Try to kill it ungracefully rather than leaving a
+            * stuck postmaster that might interfere with subsequent test
             * attempts.
             */
 #ifndef WIN32
@@ -1590,21 +1593,22 @@ main(int argc, char *argv[])
         * pre-existing database.
         */
        header(_("dropping database \"%s\""), dbname);
-       psql_command("postgres","DROP DATABASE IF EXISTS \"%s\"", dbname);
+       psql_command("postgres", "DROP DATABASE IF EXISTS \"%s\"", dbname);
    }
 
    /*
     * Create the test database
     *
-    * We use template0 so that any installation-local cruft in template1
-    * will not mess up the tests.
+    * We use template0 so that any installation-local cruft in template1 will
+    * not mess up the tests.
     */
    header(_("creating database \"%s\""), dbname);
    if (encoding)
        psql_command("postgres",
-                    "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'",
+                  "CREATE DATABASE \"%s\" TEMPLATE=template0 ENCODING='%s'",
                     dbname, encoding);
-   else                        /* use installation default */
+   else
+       /* use installation default */
        psql_command("postgres",
                     "CREATE DATABASE \"%s\" TEMPLATE=template0",
                     dbname);
@@ -1614,7 +1618,7 @@ main(int argc, char *argv[])
                 "ALTER DATABASE \"%s\" SET lc_monetary TO 'C';"
                 "ALTER DATABASE \"%s\" SET lc_numeric TO 'C';"
                 "ALTER DATABASE \"%s\" SET lc_time TO 'C';"
-                "ALTER DATABASE \"%s\" SET timezone_abbreviations TO 'Default';",
+           "ALTER DATABASE \"%s\" SET timezone_abbreviations TO 'Default';",
                 dbname, dbname, dbname, dbname, dbname);
 
    /*
@@ -1659,22 +1663,23 @@ main(int argc, char *argv[])
        snprintf(buf, sizeof(buf),
                 _(" All %d tests passed. "),
                 success_count);
-   else if (fail_count == 0) /* fail_count=0, fail_ignore_count>0 */
+   else if (fail_count == 0)   /* fail_count=0, fail_ignore_count>0 */
        snprintf(buf, sizeof(buf),
                 _(" %d of %d tests passed, %d failed test(s) ignored. "),
                 success_count,
                 success_count + fail_ignore_count,
                 fail_ignore_count);
-   else if (fail_ignore_count == 0) /* fail_count>0 && fail_ignore_count=0 */
+   else if (fail_ignore_count == 0)    /* fail_count>0 && fail_ignore_count=0 */
        snprintf(buf, sizeof(buf),
                 _(" %d of %d tests failed. "),
                 fail_count,
-                success_count+fail_count);
-   else /* fail_count>0 && fail_ignore_count>0 */
+                success_count + fail_count);
+   else
+       /* fail_count>0 && fail_ignore_count>0 */
        snprintf(buf, sizeof(buf),
                 _(" %d of %d tests failed, %d of these failures ignored. "),
-                fail_count+fail_ignore_count,
-                success_count + fail_count+fail_ignore_count,
+                fail_count + fail_ignore_count,
+                success_count + fail_count + fail_ignore_count,
                 fail_ignore_count);
 
    putchar('\n');
index c11eb5b9b24f5734734ac6cecec7e097361df533..6f9d4225b56aff19da4146d74a9d77b3ba5c6450 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.45 2006/09/16 20:14:34 tgl Exp $
+ *   $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.46 2006/10/04 00:30:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -787,7 +787,7 @@ 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",
@@ -1148,26 +1148,28 @@ pg_timezone_initialize(void)
  */
 #define MAX_TZDIR_DEPTH 10
 
-struct pg_tzenum {
-   int baselen;
-   int depth;
-   DIR *dirdesc[MAX_TZDIR_DEPTH];
-   char *dirname[MAX_TZDIR_DEPTH];
-   struct pg_tz tz;
+struct pg_tzenum
+{
+   int         baselen;
+   int         depth;
+   DIR        *dirdesc[MAX_TZDIR_DEPTH];
+   char       *dirname[MAX_TZDIR_DEPTH];
+   struct pg_tz tz;
 };
+
 /* typedef pg_tzenum is declared in pgtime.h */
 
 pg_tzenum *
-pg_tzenumerate_start(void) 
+pg_tzenumerate_start(void)
 {
-   pg_tzenum *ret = (pg_tzenum *) palloc0(sizeof(pg_tzenum));
-   char *startdir = pstrdup(pg_TZDIR());
+   pg_tzenum  *ret = (pg_tzenum *) palloc0(sizeof(pg_tzenum));
+   char       *startdir = pstrdup(pg_TZDIR());
 
    ret->baselen = strlen(startdir) + 1;
    ret->depth = 0;
    ret->dirname[0] = startdir;
    ret->dirdesc[0] = AllocateDir(startdir);
-   if (!ret->dirdesc[0]) 
+   if (!ret->dirdesc[0])
        ereport(ERROR,
                (errcode_for_file_access(),
                 errmsg("could not open directory \"%s\": %m", startdir)));
@@ -1192,7 +1194,7 @@ pg_tzenumerate_next(pg_tzenum *dir)
    while (dir->depth >= 0)
    {
        struct dirent *direntry;
-       char fullname[MAXPGPATH];
+       char        fullname[MAXPGPATH];
        struct stat statbuf;
 
        direntry = ReadDir(dir->dirdesc[dir->depth], dir->dirname[dir->depth]);
@@ -1219,13 +1221,13 @@ pg_tzenumerate_next(pg_tzenum *dir)
        if (S_ISDIR(statbuf.st_mode))
        {
            /* Step into the subdirectory */
-           if (dir->depth >= MAX_TZDIR_DEPTH-1)
+           if (dir->depth >= MAX_TZDIR_DEPTH - 1)
                ereport(ERROR,
                        (errmsg("timezone directory stack overflow")));
            dir->depth++;
            dir->dirname[dir->depth] = pstrdup(fullname);
            dir->dirdesc[dir->depth] = AllocateDir(fullname);
-           if (!dir->dirdesc[dir->depth]) 
+           if (!dir->dirdesc[dir->depth])
                ereport(ERROR,
                        (errcode_for_file_access(),
                         errmsg("could not open directory \"%s\": %m",
@@ -1236,8 +1238,8 @@ pg_tzenumerate_next(pg_tzenum *dir)
        }
 
        /*
-        * Load this timezone using tzload() not pg_tzset(),
-        * so we don't fill the cache
+        * Load this timezone using tzload() not pg_tzset(), so we don't fill
+        * the cache
         */
        if (tzload(fullname + dir->baselen, &dir->tz.state) != 0)
        {