pgindent run before PG 9.1 beta 1.
authorBruce Momjian <bruce@momjian.us>
Sun, 10 Apr 2011 15:42:00 +0000 (11:42 -0400)
committerBruce Momjian <bruce@momjian.us>
Sun, 10 Apr 2011 15:42:00 +0000 (11:42 -0400)
446 files changed:
contrib/adminpack/adminpack.c
contrib/auth_delay/auth_delay.c
contrib/btree_gist/btree_cash.c
contrib/btree_gist/btree_date.c
contrib/btree_gist/btree_float4.c
contrib/btree_gist/btree_float8.c
contrib/btree_gist/btree_int2.c
contrib/btree_gist/btree_int4.c
contrib/btree_gist/btree_int8.c
contrib/btree_gist/btree_interval.c
contrib/btree_gist/btree_oid.c
contrib/btree_gist/btree_time.c
contrib/btree_gist/btree_ts.c
contrib/btree_gist/btree_utils_num.c
contrib/btree_gist/btree_utils_num.h
contrib/btree_gist/btree_utils_var.c
contrib/dummy_seclabel/dummy_seclabel.c
contrib/file_fdw/file_fdw.c
contrib/fuzzystrmatch/levenshtein.c
contrib/hstore/hstore_gin.c
contrib/hstore/hstore_op.c
contrib/intarray/_int_bool.c
contrib/intarray/_int_gin.c
contrib/intarray/_int_tool.c
contrib/isn/ISBN.h
contrib/pg_archivecleanup/pg_archivecleanup.c
contrib/pg_stat_statements/pg_stat_statements.c
contrib/pg_test_fsync/pg_test_fsync.c
contrib/pg_trgm/trgm.h
contrib/pg_trgm/trgm_gin.c
contrib/pg_trgm/trgm_gist.c
contrib/pg_trgm/trgm_op.c
contrib/pg_upgrade/check.c
contrib/pg_upgrade/controldata.c
contrib/pg_upgrade/exec.c
contrib/pg_upgrade/file.c
contrib/pg_upgrade/function.c
contrib/pg_upgrade/info.c
contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/relfilenode.c
contrib/pg_upgrade/server.c
contrib/pg_upgrade/tablespace.c
contrib/pg_upgrade/util.c
contrib/pg_upgrade/version_old_8_3.c
contrib/pg_upgrade_support/pg_upgrade_support.c
contrib/pgbench/pgbench.c
contrib/seg/seg.c
contrib/sepgsql/dml.c
contrib/sepgsql/hooks.c
contrib/sepgsql/label.c
contrib/sepgsql/proc.c
contrib/sepgsql/relation.c
contrib/sepgsql/schema.c
contrib/sepgsql/selinux.c
contrib/sepgsql/sepgsql.h
contrib/spi/moddatetime.c
contrib/xml2/xpath.c
contrib/xml2/xslt_proc.c
src/backend/access/common/heaptuple.c
src/backend/access/common/indextuple.c
src/backend/access/gin/ginarrayproc.c
src/backend/access/gin/ginbulk.c
src/backend/access/gin/gindatapage.c
src/backend/access/gin/ginentrypage.c
src/backend/access/gin/ginfast.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/gistutil.c
src/backend/access/gist/gistxlog.c
src/backend/access/hash/hash.c
src/backend/access/heap/heapam.c
src/backend/access/heap/hio.c
src/backend/access/heap/rewriteheap.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/transam/twophase.c
src/backend/access/transam/varsup.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.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/objectaddress.c
src/backend/catalog/pg_collation.c
src/backend/catalog/pg_constraint.c
src/backend/catalog/pg_depend.c
src/backend/catalog/pg_enum.c
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_type.c
src/backend/catalog/storage.c
src/backend/catalog/toasting.c
src/backend/commands/alter.c
src/backend/commands/analyze.c
src/backend/commands/cluster.c
src/backend/commands/collationcmds.c
src/backend/commands/comment.c
src/backend/commands/conversioncmds.c
src/backend/commands/copy.c
src/backend/commands/dbcommands.c
src/backend/commands/explain.c
src/backend/commands/extension.c
src/backend/commands/foreigncmds.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/seclabel.c
src/backend/commands/sequence.c
src/backend/commands/tablecmds.c
src/backend/commands/tablespace.c
src/backend/commands/trigger.c
src/backend/commands/tsearchcmds.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/execQual.c
src/backend/executor/execUtils.c
src/backend/executor/functions.c
src/backend/executor/nodeAgg.c
src/backend/executor/nodeBitmapIndexscan.c
src/backend/executor/nodeForeignscan.c
src/backend/executor/nodeHash.c
src/backend/executor/nodeHashjoin.c
src/backend/executor/nodeIndexscan.c
src/backend/executor/nodeLimit.c
src/backend/executor/nodeLockRows.c
src/backend/executor/nodeMergeAppend.c
src/backend/executor/nodeMergejoin.c
src/backend/executor/nodeModifyTable.c
src/backend/executor/nodeNestloop.c
src/backend/executor/nodeRecursiveunion.c
src/backend/executor/nodeSetOp.c
src/backend/executor/nodeWindowAgg.c
src/backend/executor/spi.c
src/backend/libpq/auth.c
src/backend/libpq/hba.c
src/backend/libpq/pqcomm.c
src/backend/main/main.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/nodeFuncs.c
src/backend/nodes/params.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/equivclass.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/plan/analyzejoins.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/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/placeholder.c
src/backend/optimizer/util/predtest.c
src/backend/optimizer/util/var.c
src/backend/parser/analyze.c
src/backend/parser/parse_agg.c
src/backend/parser/parse_clause.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_collate.c
src/backend/parser/parse_cte.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_param.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/backend/parser/parse_utilcmd.c
src/backend/port/dynloader/freebsd.c
src/backend/port/dynloader/netbsd.c
src/backend/port/dynloader/openbsd.c
src/backend/port/pipe.c
src/backend/port/sysv_shmem.c
src/backend/port/unix_latch.c
src/backend/port/win32/crashdump.c
src/backend/port/win32/timer.c
src/backend/port/win32_latch.c
src/backend/postmaster/autovacuum.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/pgstat.c
src/backend/postmaster/postmaster.c
src/backend/postmaster/syslogger.c
src/backend/regex/regcomp.c
src/backend/replication/basebackup.c
src/backend/replication/syncrep.c
src/backend/replication/walreceiver.c
src/backend/replication/walreceiverfuncs.c
src/backend/replication/walsender.c
src/backend/rewrite/rewriteDefine.c
src/backend/rewrite/rewriteHandler.c
src/backend/rewrite/rewriteSupport.c
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/freelist.c
src/backend/storage/buffer/localbuf.c
src/backend/storage/file/fd.c
src/backend/storage/file/reinit.c
src/backend/storage/ipc/pmsignal.c
src/backend/storage/ipc/procarray.c
src/backend/storage/ipc/standby.c
src/backend/storage/large_object/inv_api.c
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/predicate.c
src/backend/storage/smgr/md.c
src/backend/storage/smgr/smgr.c
src/backend/tcop/postgres.c
src/backend/tcop/pquery.c
src/backend/tcop/utility.c
src/backend/tsearch/spell.c
src/backend/tsearch/ts_locale.c
src/backend/tsearch/ts_selfuncs.c
src/backend/tsearch/wparser_def.c
src/backend/utils/adt/acl.c
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/cash.c
src/backend/utils/adt/date.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/dbsize.c
src/backend/utils/adt/enum.c
src/backend/utils/adt/formatting.c
src/backend/utils/adt/genfile.c
src/backend/utils/adt/like.c
src/backend/utils/adt/nabstime.c
src/backend/utils/adt/network.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/numutils.c
src/backend/utils/adt/pg_locale.c
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/adt/ri_triggers.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/tsginidx.c
src/backend/utils/adt/tsvector_op.c
src/backend/utils/adt/varbit.c
src/backend/utils/adt/varlena.c
src/backend/utils/adt/xml.c
src/backend/utils/cache/inval.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/plancache.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/backend/utils/cache/ts_cache.c
src/backend/utils/cache/typcache.c
src/backend/utils/error/elog.c
src/backend/utils/fmgr/fmgr.c
src/backend/utils/fmgr/funcapi.c
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/backend/utils/mb/mbutils.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/rbtree.c
src/backend/utils/misc/tzparser.c
src/backend/utils/mmgr/aset.c
src/backend/utils/mmgr/portalmem.c
src/backend/utils/resowner/resowner.c
src/backend/utils/sort/tuplesort.c
src/backend/utils/time/snapmgr.c
src/bin/initdb/initdb.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_dump/compress_io.c
src/bin/pg_dump/compress_io.h
src/bin/pg_dump/dumputils.c
src/bin/pg_dump/dumputils.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_directory.c
src/bin/pg_dump/pg_backup_tar.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/pg_dumpall.c
src/bin/psql/command.c
src/bin/psql/describe.c
src/bin/psql/tab-complete.c
src/bin/scripts/droplang.c
src/include/access/gin.h
src/include/access/gin_private.h
src/include/access/gist.h
src/include/access/gist_private.h
src/include/access/hio.h
src/include/access/htup.h
src/include/access/itup.h
src/include/access/relscan.h
src/include/access/tupdesc.h
src/include/access/xact.h
src/include/access/xlog.h
src/include/access/xlogdefs.h
src/include/catalog/catalog.h
src/include/catalog/dependency.h
src/include/catalog/namespace.h
src/include/catalog/objectaccess.h
src/include/catalog/pg_am.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_authid.h
src/include/catalog/pg_class.h
src/include/catalog/pg_collation.h
src/include/catalog/pg_collation_fn.h
src/include/catalog/pg_constraint.h
src/include/catalog/pg_control.h
src/include/catalog/pg_enum.h
src/include/catalog/pg_extension.h
src/include/catalog/pg_index.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_seclabel.h
src/include/catalog/pg_type.h
src/include/catalog/storage.h
src/include/commands/alter.h
src/include/commands/collationcmds.h
src/include/commands/copy.h
src/include/commands/dbcommands.h
src/include/commands/defrem.h
src/include/commands/explain.h
src/include/commands/extension.h
src/include/commands/proclang.h
src/include/commands/seclabel.h
src/include/commands/trigger.h
src/include/commands/typecmds.h
src/include/commands/vacuum.h
src/include/executor/executor.h
src/include/executor/functions.h
src/include/executor/hashjoin.h
src/include/executor/nodeHash.h
src/include/fmgr.h
src/include/foreign/fdwapi.h
src/include/foreign/foreign.h
src/include/libpq/auth.h
src/include/libpq/libpq-be.h
src/include/libpq/libpq.h
src/include/nodes/execnodes.h
src/include/nodes/makefuncs.h
src/include/nodes/params.h
src/include/nodes/parsenodes.h
src/include/nodes/pg_list.h
src/include/nodes/plannodes.h
src/include/nodes/primnodes.h
src/include/nodes/relation.h
src/include/optimizer/cost.h
src/include/optimizer/pathnode.h
src/include/optimizer/paths.h
src/include/optimizer/placeholder.h
src/include/optimizer/subselect.h
src/include/parser/parse_collate.h
src/include/parser/parse_func.h
src/include/parser/parse_type.h
src/include/parser/parser.h
src/include/pgstat.h
src/include/port/win32.h
src/include/replication/replnodes.h
src/include/replication/syncrep.h
src/include/replication/walprotocol.h
src/include/replication/walreceiver.h
src/include/replication/walsender.h
src/include/rewrite/rewriteSupport.h
src/include/storage/backendid.h
src/include/storage/buf_internals.h
src/include/storage/latch.h
src/include/storage/pmsignal.h
src/include/storage/predicate_internals.h
src/include/storage/proc.h
src/include/storage/procarray.h
src/include/storage/relfilenode.h
src/include/tsearch/dicts/spell.h
src/include/utils/acl.h
src/include/utils/builtins.h
src/include/utils/bytea.h
src/include/utils/datetime.h
src/include/utils/elog.h
src/include/utils/guc.h
src/include/utils/lsyscache.h
src/include/utils/numeric.h
src/include/utils/portal.h
src/include/utils/rbtree.h
src/include/utils/rel.h
src/include/utils/tuplesort.h
src/include/utils/typcache.h
src/include/utils/varbit.h
src/include/utils/xml.h
src/interfaces/ecpg/compatlib/informix.c
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/memory.c
src/interfaces/ecpg/ecpglib/prepare.c
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/extern.h
src/interfaces/libpq/fe-auth.c
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-protocol2.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/pl/plperl/plperl.c
src/pl/plperl/plperl.h
src/pl/plperl/plperl_helpers.h
src/pl/plpgsql/src/pl_comp.c
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/plpgsql.h
src/pl/plpython/plpython.c
src/pl/tcl/pltcl.c
src/port/chklocale.c
src/port/crypt.c
src/port/dirmod.c
src/port/exec.c
src/port/getaddrinfo.c
src/port/inet_net_ntop.c
src/port/path.c
src/port/pgmkdirp.c
src/port/snprintf.c
src/port/unsetenv.c
src/test/isolation/isolation_main.c
src/test/isolation/isolationtester.c
src/test/isolation/isolationtester.h
src/test/regress/pg_regress.c

index c149dd6c6352587706067fbc5145f32d856e6f3e..99fa02e81365f0ba04d1a642b6862bc415b1da91 100644 (file)
@@ -78,18 +78,19 @@ convert_and_check_filename(text *arg, bool logAllowed)
        /* Disallow '/a/b/data/..' */
        if (path_contains_parent_reference(filename))
            ereport(ERROR,
-               (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-               (errmsg("reference to parent directory (\"..\") not allowed"))));
+                   (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+           (errmsg("reference to parent directory (\"..\") not allowed"))));
+
        /*
-        *  Allow absolute paths if within DataDir or Log_directory, even
-        *  though Log_directory might be outside DataDir.
+        * Allow absolute paths if within DataDir or Log_directory, even
+        * though Log_directory might be outside DataDir.
         */
        if (!path_is_prefix_of_path(DataDir, filename) &&
            (!logAllowed || !is_absolute_path(Log_directory) ||
             !path_is_prefix_of_path(Log_directory, filename)))
            ereport(ERROR,
-               (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
-                (errmsg("absolute path not allowed"))));
+                   (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+                    (errmsg("absolute path not allowed"))));
    }
    else if (!path_is_relative_and_below_cwd(filename))
        ereport(ERROR,
index ca388c4498414d86cb0fbd889ef1f851e9f93ddf..4e0d5959d19ca9852b60386d995b25af41a3ef8d 100644 (file)
 
 PG_MODULE_MAGIC;
 
-void _PG_init(void);
+void       _PG_init(void);
 
 /* GUC Variables */
 static int auth_delay_milliseconds;
 
 /* Original Hook */
-static ClientAuthentication_hook_type  original_client_auth_hook = NULL;
+static ClientAuthentication_hook_type original_client_auth_hook = NULL;
 
 /*
  * Check authentication
@@ -55,7 +55,7 @@ _PG_init(void)
 {
    /* Define custom GUC variables */
    DefineCustomIntVariable("auth_delay.milliseconds",
-                           "Milliseconds to delay before reporting authentication failure",
+            "Milliseconds to delay before reporting authentication failure",
                            NULL,
                            &auth_delay_milliseconds,
                            0,
index 7938a70f17a120c1e181df0804b558b6608bef22..2664a2687057d4b001839043480c204952dcb43e 100644 (file)
@@ -169,7 +169,7 @@ gbt_cash_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index ccd7e2ad3f383a3fef458454b3bbe5a05fb1cca7..8a675e2f1d884a5e0625c3f00f3ea4715622ba54 100644 (file)
@@ -90,9 +90,9 @@ static float8
 gdb_date_dist(const void *a, const void *b)
 {
    /* we assume the difference can't overflow */
-   Datum diff = DirectFunctionCall2(date_mi,
+   Datum       diff = DirectFunctionCall2(date_mi,
                                     DateADTGetDatum(*((const DateADT *) a)),
-                                    DateADTGetDatum(*((const DateADT *) b)));
+                                   DateADTGetDatum(*((const DateADT *) b)));
 
    return (float8) Abs(DatumGetInt32(diff));
 }
@@ -113,14 +113,14 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(date_dist);
-Datum       date_dist(PG_FUNCTION_ARGS);
+Datum      date_dist(PG_FUNCTION_ARGS);
 Datum
 date_dist(PG_FUNCTION_ARGS)
 {
    /* we assume the difference can't overflow */
-   Datum diff = DirectFunctionCall2(date_mi,
-                                    PG_GETARG_DATUM(0),
-                                    PG_GETARG_DATUM(1));
+   Datum       diff = DirectFunctionCall2(date_mi,
+                                          PG_GETARG_DATUM(0),
+                                          PG_GETARG_DATUM(1));
 
    PG_RETURN_INT32(Abs(DatumGetInt32(diff)));
 }
@@ -181,7 +181,7 @@ gbt_date_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index 932a941f889e4b9d3e91fd4f58ad7654221c7187..266256b23cf973cdaebec5b5160164baca5b66a0 100644 (file)
@@ -94,18 +94,18 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(float4_dist);
-Datum       float4_dist(PG_FUNCTION_ARGS);
+Datum      float4_dist(PG_FUNCTION_ARGS);
 Datum
 float4_dist(PG_FUNCTION_ARGS)
 {
-    float4     a = PG_GETARG_FLOAT4(0);
+   float4      a = PG_GETARG_FLOAT4(0);
    float4      b = PG_GETARG_FLOAT4(1);
    float4      r;
 
    r = a - b;
    CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
 
-   PG_RETURN_FLOAT4( Abs(r) );
+   PG_RETURN_FLOAT4(Abs(r));
 }
 
 
@@ -162,7 +162,7 @@ gbt_float4_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index 0c39980ba1e0ee456c05a0d7644364b5b11bd8b2..efbee0f3e4b66531310bb6f98a8eec991f2954b3 100644 (file)
@@ -76,8 +76,8 @@ gbt_float8key_cmp(const void *a, const void *b)
 static float8
 gbt_float8_dist(const void *a, const void *b)
 {
-   float8      arg1 = *(const float8 *)a;
-   float8      arg2 = *(const float8 *)b;
+   float8      arg1 = *(const float8 *) a;
+   float8      arg2 = *(const float8 *) b;
    float8      r;
 
    r = arg1 - arg2;
@@ -102,7 +102,7 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(float8_dist);
-Datum       float8_dist(PG_FUNCTION_ARGS);
+Datum      float8_dist(PG_FUNCTION_ARGS);
 Datum
 float8_dist(PG_FUNCTION_ARGS)
 {
@@ -113,7 +113,7 @@ float8_dist(PG_FUNCTION_ARGS)
    r = a - b;
    CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
 
-   PG_RETURN_FLOAT8( Abs(r) );
+   PG_RETURN_FLOAT8(Abs(r));
 }
 
 /**************************************************
@@ -169,7 +169,7 @@ gbt_float8_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index c06d170a5e1af5c272fff56d0d775bdc47ed5ffc..7841145b53f6e49da3d8f9e13918bd1358023f8f 100644 (file)
@@ -94,12 +94,12 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(int2_dist);
-Datum       int2_dist(PG_FUNCTION_ARGS);
+Datum      int2_dist(PG_FUNCTION_ARGS);
 Datum
 int2_dist(PG_FUNCTION_ARGS)
 {
-   int2        a = PG_GETARG_INT16(0);
-   int2        b = PG_GETARG_INT16(1);
+   int2        a = PG_GETARG_INT16(0);
+   int2        b = PG_GETARG_INT16(1);
    int2        r;
    int2        ra;
 
@@ -169,7 +169,7 @@ gbt_int2_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index ef7af524e76bdfab212fd332b8bd3b0778237ba6..0e4b4f85b0eb448ce004e2863b7b9cdc79c8b40d 100644 (file)
@@ -95,14 +95,14 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(int4_dist);
-Datum       int4_dist(PG_FUNCTION_ARGS);
+Datum      int4_dist(PG_FUNCTION_ARGS);
 Datum
 int4_dist(PG_FUNCTION_ARGS)
 {
-   int4        a = PG_GETARG_INT32(0);
-   int4        b = PG_GETARG_INT32(1);
-   int4        r;
-   int4        ra;
+   int4        a = PG_GETARG_INT32(0);
+   int4        b = PG_GETARG_INT32(1);
+   int4        r;
+   int4        ra;
 
    r = a - b;
    ra = Abs(r);
@@ -111,7 +111,7 @@ int4_dist(PG_FUNCTION_ARGS)
    if (ra < 0 || (!SAMESIGN(a, b) && !SAMESIGN(r, a)))
        ereport(ERROR,
                (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-                        errmsg("integer out of range")));
+                errmsg("integer out of range")));
 
    PG_RETURN_INT32(ra);
 }
@@ -170,7 +170,7 @@ gbt_int4_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index 1f14d82891d8c47cd59487d2fd8a1d41a4054e96..d54113d3936660a1b5ab5b5b8a5d700b71e09551 100644 (file)
@@ -95,14 +95,14 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(int8_dist);
-Datum       int8_dist(PG_FUNCTION_ARGS);
+Datum      int8_dist(PG_FUNCTION_ARGS);
 Datum
 int8_dist(PG_FUNCTION_ARGS)
 {
-   int64       a = PG_GETARG_INT64(0);
-   int64       b = PG_GETARG_INT64(1);
-   int64       r;
-   int64       ra;
+   int64       a = PG_GETARG_INT64(0);
+   int64       b = PG_GETARG_INT64(1);
+   int64       r;
+   int64       ra;
 
    r = a - b;
    ra = Abs(r);
@@ -111,7 +111,7 @@ int8_dist(PG_FUNCTION_ARGS)
    if (ra < 0 || (!SAMESIGN(a, b) && !SAMESIGN(r, a)))
        ereport(ERROR,
                (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
-                        errmsg("bigint out of range")));
+                errmsg("bigint out of range")));
 
    PG_RETURN_INT64(ra);
 }
@@ -170,7 +170,7 @@ gbt_int8_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index 5195284afa1be65f3a66acf779d7a1a6c99236f6..137a5fcd7f4e2e9487782b28d9a8b6ec46ecc506 100644 (file)
@@ -88,7 +88,7 @@ intr2num(const Interval *i)
 static float8
 gbt_intv_dist(const void *a, const void *b)
 {
-   return (float8)Abs(intr2num((Interval*)a) - intr2num((Interval*)b));
+   return (float8) Abs(intr2num((Interval *) a) - intr2num((Interval *) b));
 }
 
 /*
@@ -127,7 +127,7 @@ abs_interval(Interval *a)
 }
 
 PG_FUNCTION_INFO_V1(interval_dist);
-Datum       interval_dist(PG_FUNCTION_ARGS);
+Datum      interval_dist(PG_FUNCTION_ARGS);
 Datum
 interval_dist(PG_FUNCTION_ARGS)
 {
@@ -240,7 +240,7 @@ gbt_intv_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) query, GIST_LEAF(entry), &tinfo)
+            gbt_num_distance(&key, (void *) query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index c81dd31799eb9a2f61b86ab29d2f05adc8a2db31..3b0929b42bb0147a6dbcbb240d676df5a21fb83b 100644 (file)
@@ -101,13 +101,13 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(oid_dist);
-Datum       oid_dist(PG_FUNCTION_ARGS);
+Datum      oid_dist(PG_FUNCTION_ARGS);
 Datum
 oid_dist(PG_FUNCTION_ARGS)
 {
-    Oid            a = PG_GETARG_OID(0);
-   Oid         b = PG_GETARG_OID(1);
-   Oid         res;
+   Oid         a = PG_GETARG_OID(0);
+   Oid         b = PG_GETARG_OID(1);
+   Oid         res;
 
    if (a < b)
        res = b - a;
@@ -170,7 +170,7 @@ gbt_oid_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index 44f6923409f4b6a6fb1682751deae1507f76c5be..e9cfe33f45594fbe5db9077dfe97ef4472f7b025 100644 (file)
@@ -119,7 +119,7 @@ gbt_time_dist(const void *a, const void *b)
 {
    const TimeADT *aa = (const TimeADT *) a;
    const TimeADT *bb = (const TimeADT *) b;
-   Interval      *i;
+   Interval   *i;
 
    i = DatumGetIntervalP(DirectFunctionCall2(time_mi_time,
                                              TimeADTGetDatumFast(*aa),
@@ -143,7 +143,7 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(time_dist);
-Datum       time_dist(PG_FUNCTION_ARGS);
+Datum      time_dist(PG_FUNCTION_ARGS);
 Datum
 time_dist(PG_FUNCTION_ARGS)
 {
@@ -239,7 +239,7 @@ gbt_time_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
index 9a0ec07a1e742bf4003ee5b0a5f1b7ce2ef40d72..9d3a5919a0ee078eb0be8c4097c4a01471ab396e 100644 (file)
@@ -120,7 +120,7 @@ gbt_ts_dist(const void *a, const void *b)
 {
    const Timestamp *aa = (const Timestamp *) a;
    const Timestamp *bb = (const Timestamp *) b;
-   Interval      *i;
+   Interval   *i;
 
    if (TIMESTAMP_NOT_FINITE(*aa) || TIMESTAMP_NOT_FINITE(*bb))
        return get_float8_infinity();
@@ -147,17 +147,17 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(ts_dist);
-Datum       ts_dist(PG_FUNCTION_ARGS);
+Datum      ts_dist(PG_FUNCTION_ARGS);
 Datum
 ts_dist(PG_FUNCTION_ARGS)
 {
    Timestamp   a = PG_GETARG_TIMESTAMP(0);
    Timestamp   b = PG_GETARG_TIMESTAMP(1);
-    Interval      *r;
+   Interval   *r;
 
    if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
    {
-       Interval *p = palloc(sizeof(Interval));
+       Interval   *p = palloc(sizeof(Interval));
 
        p->day = INT_MAX;
        p->month = INT_MAX;
@@ -169,25 +169,24 @@ ts_dist(PG_FUNCTION_ARGS)
        PG_RETURN_INTERVAL_P(p);
    }
    else
-
-   r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
-                                             PG_GETARG_DATUM(0),
-                                             PG_GETARG_DATUM(1)));
-   PG_RETURN_INTERVAL_P( abs_interval(r) );
+       r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
+                                                 PG_GETARG_DATUM(0),
+                                                 PG_GETARG_DATUM(1)));
+   PG_RETURN_INTERVAL_P(abs_interval(r));
 }
 
 PG_FUNCTION_INFO_V1(tstz_dist);
-Datum       tstz_dist(PG_FUNCTION_ARGS);
+Datum      tstz_dist(PG_FUNCTION_ARGS);
 Datum
 tstz_dist(PG_FUNCTION_ARGS)
 {
-   TimestampTz a = PG_GETARG_TIMESTAMPTZ(0);
-   TimestampTz b = PG_GETARG_TIMESTAMPTZ(1);
-    Interval      *r;
+   TimestampTz a = PG_GETARG_TIMESTAMPTZ(0);
+   TimestampTz b = PG_GETARG_TIMESTAMPTZ(1);
+   Interval   *r;
 
    if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
    {
-       Interval *p = palloc(sizeof(Interval));
+       Interval   *p = palloc(sizeof(Interval));
 
        p->day = INT_MAX;
        p->month = INT_MAX;
@@ -202,7 +201,7 @@ tstz_dist(PG_FUNCTION_ARGS)
    r = DatumGetIntervalP(DirectFunctionCall2(timestamp_mi,
                                              PG_GETARG_DATUM(0),
                                              PG_GETARG_DATUM(1)));
-   PG_RETURN_INTERVAL_P( abs_interval(r) );
+   PG_RETURN_INTERVAL_P(abs_interval(r));
 }
 
 
@@ -309,7 +308,7 @@ gbt_ts_distance(PG_FUNCTION_ARGS)
    key.upper = (GBT_NUMKEY *) &kkk->upper;
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+           gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
        );
 }
 
@@ -354,7 +353,7 @@ gbt_tstz_distance(PG_FUNCTION_ARGS)
    qqq = tstz_to_ts_gmt(query);
 
    PG_RETURN_FLOAT8(
-                  gbt_num_distance(&key, (void *) &qqq, GIST_LEAF(entry), &tinfo)
+             gbt_num_distance(&key, (void *) &qqq, GIST_LEAF(entry), &tinfo)
        );
 }
 
index 17440a191b271a57afe3e445a3f522a3ead39a69..64c95854df89d15376ecc6dd7994fe6a971276e0 100644 (file)
@@ -223,8 +223,8 @@ gbt_num_consistent(const GBT_NUMKEY_R *key,
            retval = (*tinfo->f_le) (query, key->upper);
            break;
        case BtreeGistNotEqualStrategyNumber:
-           retval = (! ((*tinfo->f_eq) (query, key->lower) &&
-               (*tinfo->f_eq) (query, key->upper)))  ? true : false;
+           retval = (!((*tinfo->f_eq) (query, key->lower) &&
+                       (*tinfo->f_eq) (query, key->upper))) ? true : false;
            break;
        default:
            retval = false;
@@ -249,9 +249,9 @@ gbt_num_distance(const GBT_NUMKEY_R *key,
    if (tinfo->f_dist == NULL)
        elog(ERROR, "KNN search is not supported for btree_gist type %d",
             (int) tinfo->t);
-   if ( tinfo->f_le(query, key->lower) )
+   if (tinfo->f_le(query, key->lower))
        retval = tinfo->f_dist(query, key->lower);
-   else if ( tinfo->f_ge(query, key->upper) )
+   else if (tinfo->f_ge(query, key->upper))
        retval = tinfo->f_dist(query, key->upper);
    else
        retval = 0.0;
index 243d3b5cb99087a3c166c922c72031c5bc3cac39..8935ed66306a1079fd29daabc10b435f12462c77 100644 (file)
@@ -46,7 +46,7 @@ typedef struct
    bool        (*f_le) (const void *, const void *);   /* less or equal */
    bool        (*f_lt) (const void *, const void *);   /* less than */
    int         (*f_cmp) (const void *, const void *);  /* key compare function */
-   float8      (*f_dist) (const void *, const void *); /* key distance function */
+   float8      (*f_dist) (const void *, const void *); /* key distance function */
 } gbtree_ninfo;
 
 
@@ -94,7 +94,7 @@ typedef struct
 
 #define GET_FLOAT_DISTANCE(t, arg1, arg2)  Abs( ((float8) *((const t *) (arg1))) - ((float8) *((const t *) (arg2))) )
 
-#define SAMESIGN(a,b)   (((a) < 0) == ((b) < 0))
+#define SAMESIGN(a,b)  (((a) < 0) == ((b) < 0))
 
 /*
  * check to see if a float4/8 val has underflowed or overflowed
@@ -121,7 +121,7 @@ extern bool gbt_num_consistent(const GBT_NUMKEY_R *key, const void *query,
                   const gbtree_ninfo *tinfo);
 
 extern float8 gbt_num_distance(const GBT_NUMKEY_R *key, const void *query,
-                  bool is_leaf, const gbtree_ninfo *tinfo);
+                bool is_leaf, const gbtree_ninfo *tinfo);
 
 extern GIST_SPLITVEC *gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
                  const gbtree_ninfo *tinfo);
index 8f3173e499789c02f7d756ff6db42220b5a6cd06..d74013af8828d987a3c0bc4ba5a9b12f74597b21 100644 (file)
@@ -598,7 +598,7 @@ gbt_var_consistent(
                    || gbt_var_node_pf_match(key, query, tinfo);
            break;
        case BtreeGistNotEqualStrategyNumber:
-           retval = ! ((*tinfo->f_eq) (query, key->lower) && (*tinfo->f_eq) (query, key->upper));
+           retval = !((*tinfo->f_eq) (query, key->lower) && (*tinfo->f_eq) (query, key->upper));
            break;
        default:
            retval = FALSE;
index 974806f1b6ca9e3d22b9db47dbfb5e26cbfa5217..5deb43fa9b819299f21635544920ea7ca6f39580 100644 (file)
@@ -18,7 +18,7 @@
 PG_MODULE_MAGIC;
 
 /* Entrypoint of the module */
-void _PG_init(void);
+void       _PG_init(void);
 
 static void
 dummy_object_relabel(const ObjectAddress *object, const char *seclabel)
index 6a84a00e8d39558b07d7767d496fa5f6c334d24d..466c015107db28b46601b759ad4542d6589a597c 100644 (file)
@@ -45,17 +45,17 @@ struct FileFdwOption
  */
 static struct FileFdwOption valid_options[] = {
    /* File options */
-   { "filename",       ForeignTableRelationId },
+   {"filename", ForeignTableRelationId},
 
    /* Format options */
    /* oids option is not supported */
-   { "format",         ForeignTableRelationId },
-   { "header",         ForeignTableRelationId },
-   { "delimiter",      ForeignTableRelationId },
-   { "quote",          ForeignTableRelationId },
-   { "escape",         ForeignTableRelationId },
-   { "null",           ForeignTableRelationId },
-   { "encoding",       ForeignTableRelationId },
+   {"format", ForeignTableRelationId},
+   {"header", ForeignTableRelationId},
+   {"delimiter", ForeignTableRelationId},
+   {"quote", ForeignTableRelationId},
+   {"escape", ForeignTableRelationId},
+   {"null", ForeignTableRelationId},
+   {"encoding", ForeignTableRelationId},
 
    /*
     * force_quote is not supported by file_fdw because it's for COPY TO.
@@ -68,7 +68,7 @@ static struct FileFdwOption valid_options[] = {
     */
 
    /* Sentinel */
-   { NULL,         InvalidOid }
+   {NULL, InvalidOid}
 };
 
 /*
@@ -76,9 +76,9 @@ static struct FileFdwOption valid_options[] = {
  */
 typedef struct FileFdwExecutionState
 {
-   char           *filename;   /* file to read */
-   List           *options;    /* merged COPY options, excluding filename */
-   CopyState       cstate;     /* state of reading file */
+   char       *filename;       /* file to read */
+   List       *options;        /* merged COPY options, excluding filename */
+   CopyState   cstate;         /* state of reading file */
 } FileFdwExecutionState;
 
 /*
@@ -94,8 +94,8 @@ PG_FUNCTION_INFO_V1(file_fdw_validator);
  * FDW callback routines
  */
 static FdwPlan *filePlanForeignScan(Oid foreigntableid,
-                                   PlannerInfo *root,
-                                   RelOptInfo *baserel);
+                   PlannerInfo *root,
+                   RelOptInfo *baserel);
 static void fileExplainForeignScan(ForeignScanState *node, ExplainState *es);
 static void fileBeginForeignScan(ForeignScanState *node, int eflags);
 static TupleTableSlot *fileIterateForeignScan(ForeignScanState *node);
@@ -109,8 +109,8 @@ static bool is_valid_option(const char *option, Oid context);
 static void fileGetOptions(Oid foreigntableid,
               char **filename, List **other_options);
 static void estimate_costs(PlannerInfo *root, RelOptInfo *baserel,
-                          const char *filename,
-                          Cost *startup_cost, Cost *total_cost);
+              const char *filename,
+              Cost *startup_cost, Cost *total_cost);
 
 
 /*
@@ -149,16 +149,16 @@ file_fdw_validator(PG_FUNCTION_ARGS)
 
    /*
     * Only superusers are allowed to set options of a file_fdw foreign table.
-    * This is because the filename is one of those options, and we don't
-    * want non-superusers to be able to determine which file gets read.
+    * This is because the filename is one of those options, and we don't want
+    * non-superusers to be able to determine which file gets read.
     *
     * Putting this sort of permissions check in a validator is a bit of a
     * crock, but there doesn't seem to be any other place that can enforce
     * the check more cleanly.
     *
-    * Note that the valid_options[] array disallows setting filename at
-    * any options level other than foreign table --- otherwise there'd
-    * still be a security hole.
+    * Note that the valid_options[] array disallows setting filename at any
+    * options level other than foreign table --- otherwise there'd still be a
+    * security hole.
     */
    if (catalog == ForeignTableRelationId && !superuser())
        ereport(ERROR,
@@ -171,7 +171,7 @@ file_fdw_validator(PG_FUNCTION_ARGS)
     */
    foreach(cell, options_list)
    {
-       DefElem    *def = (DefElem *) lfirst(cell);
+       DefElem    *def = (DefElem *) lfirst(cell);
 
        if (!is_valid_option(def->defname, catalog))
        {
@@ -276,7 +276,7 @@ fileGetOptions(Oid foreigntableid,
    prev = NULL;
    foreach(lc, options)
    {
-       DefElem    *def = (DefElem *) lfirst(lc);
+       DefElem    *def = (DefElem *) lfirst(lc);
 
        if (strcmp(def->defname, "filename") == 0)
        {
@@ -302,7 +302,7 @@ filePlanForeignScan(Oid foreigntableid,
                    PlannerInfo *root,
                    RelOptInfo *baserel)
 {
-   FdwPlan    *fdwplan;
+   FdwPlan    *fdwplan;
    char       *filename;
    List       *options;
 
@@ -313,7 +313,7 @@ filePlanForeignScan(Oid foreigntableid,
    fdwplan = makeNode(FdwPlan);
    estimate_costs(root, baserel, filename,
                   &fdwplan->startup_cost, &fdwplan->total_cost);
-   fdwplan->fdw_private = NIL;             /* not used */
+   fdwplan->fdw_private = NIL; /* not used */
 
    return fdwplan;
 }
@@ -337,7 +337,7 @@ fileExplainForeignScan(ForeignScanState *node, ExplainState *es)
    /* Suppress file size if we're not showing cost details */
    if (es->costs)
    {
-       struct stat     stat_buf;
+       struct stat stat_buf;
 
        if (stat(filename, &stat_buf) == 0)
            ExplainPropertyLong("Foreign File Size", (long) stat_buf.st_size,
@@ -368,8 +368,8 @@ fileBeginForeignScan(ForeignScanState *node, int eflags)
                   &filename, &options);
 
    /*
-    * Create CopyState from FDW options.  We always acquire all columns,
-    * so as to match the expected ScanTupleSlot signature.
+    * Create CopyState from FDW options.  We always acquire all columns, so
+    * as to match the expected ScanTupleSlot signature.
     */
    cstate = BeginCopyFrom(node->ss.ss_currentRelation,
                           filename,
@@ -398,7 +398,7 @@ fileIterateForeignScan(ForeignScanState *node)
 {
    FileFdwExecutionState *festate = (FileFdwExecutionState *) node->fdw_state;
    TupleTableSlot *slot = node->ss.ss_ScanTupleSlot;
-   bool            found;
+   bool        found;
    ErrorContextCallback errcontext;
 
    /* Set up callback to identify error line number. */
@@ -410,8 +410,8 @@ fileIterateForeignScan(ForeignScanState *node)
    /*
     * The protocol for loading a virtual tuple into a slot is first
     * ExecClearTuple, then fill the values/isnull arrays, then
-    * ExecStoreVirtualTuple.  If we don't find another row in the file,
-    * we just skip the last step, leaving the slot empty as required.
+    * ExecStoreVirtualTuple.  If we don't find another row in the file, we
+    * just skip the last step, leaving the slot empty as required.
     *
     * We can pass ExprContext = NULL because we read all columns from the
     * file, so no need to evaluate default expressions.
@@ -471,17 +471,17 @@ estimate_costs(PlannerInfo *root, RelOptInfo *baserel,
               const char *filename,
               Cost *startup_cost, Cost *total_cost)
 {
-   struct stat     stat_buf;
-   BlockNumber     pages;
-   int             tuple_width;
-   double          ntuples;
-   double          nrows;
-   Cost            run_cost = 0;
-   Cost            cpu_per_tuple;
+   struct stat stat_buf;
+   BlockNumber pages;
+   int         tuple_width;
+   double      ntuples;
+   double      nrows;
+   Cost        run_cost = 0;
+   Cost        cpu_per_tuple;
 
    /*
-    * Get size of the file.  It might not be there at plan time, though,
-    * in which case we have to use a default estimate.
+    * Get size of the file.  It might not be there at plan time, though, in
+    * which case we have to use a default estimate.
     */
    if (stat(filename, &stat_buf) < 0)
        stat_buf.st_size = 10 * BLCKSZ;
@@ -489,7 +489,7 @@ estimate_costs(PlannerInfo *root, RelOptInfo *baserel,
    /*
     * Convert size to pages for use in I/O cost estimate below.
     */
-   pages = (stat_buf.st_size + (BLCKSZ-1)) / BLCKSZ;
+   pages = (stat_buf.st_size + (BLCKSZ - 1)) / BLCKSZ;
    if (pages < 1)
        pages = 1;
 
@@ -505,10 +505,9 @@ estimate_costs(PlannerInfo *root, RelOptInfo *baserel,
    ntuples = clamp_row_est((double) stat_buf.st_size / (double) tuple_width);
 
    /*
-    * Now estimate the number of rows returned by the scan after applying
-    * the baserestrictinfo quals.  This is pretty bogus too, since the
-    * planner will have no stats about the relation, but it's better than
-    * nothing.
+    * Now estimate the number of rows returned by the scan after applying the
+    * baserestrictinfo quals.  This is pretty bogus too, since the planner
+    * will have no stats about the relation, but it's better than nothing.
     */
    nrows = ntuples *
        clauselist_selectivity(root,
@@ -523,7 +522,7 @@ estimate_costs(PlannerInfo *root, RelOptInfo *baserel,
    baserel->rows = nrows;
 
    /*
-    * Now estimate costs.  We estimate costs almost the same way as
+    * Now estimate costs.  We estimate costs almost the same way as
     * cost_seqscan(), thus assuming that I/O costs are equivalent to a
     * regular table file of the same size.  However, we take per-tuple CPU
     * costs as 10x of a seqscan, to account for the cost of parsing records.
index 3d85d4175fb1e08be0e0b10172a78521df7f1fcf..a84c46a4a408fc7d17ba44137d871e9a45b20e05 100644 (file)
@@ -23,7 +23,7 @@
  */
 #ifdef LEVENSHTEIN_LESS_EQUAL
 static int levenshtein_less_equal_internal(text *s, text *t,
-                    int ins_c, int del_c, int sub_c, int max_d);
+                               int ins_c, int del_c, int sub_c, int max_d);
 #else
 static int levenshtein_internal(text *s, text *t,
                     int ins_c, int del_c, int sub_c);
@@ -50,7 +50,7 @@ static int levenshtein_internal(text *s, text *t,
  * array.
  *
  * If max_d >= 0, we only need to provide an accurate answer when that answer
- * is less than or equal to the bound.  From any cell in the matrix, there is
+ * is less than or equal to the bound. From any cell in the matrix, there is
  * theoretical "minimum residual distance" from that cell to the last column
  * of the final row.  This minimum residual distance is zero when the
  * untransformed portions of the strings are of equal length (because we might
@@ -87,11 +87,13 @@ levenshtein_internal(text *s, text *t,
 
    /*
     * For levenshtein_less_equal_internal, we have real variables called
-    * start_column and stop_column; otherwise it's just short-hand for 0
-    * and m.
+    * start_column and stop_column; otherwise it's just short-hand for 0 and
+    * m.
     */
 #ifdef LEVENSHTEIN_LESS_EQUAL
-   int        start_column, stop_column;
+   int         start_column,
+               stop_column;
+
 #undef START_COLUMN
 #undef STOP_COLUMN
 #define START_COLUMN start_column
@@ -139,16 +141,16 @@ levenshtein_internal(text *s, text *t,
    stop_column = m + 1;
 
    /*
-    * If max_d >= 0, determine whether the bound is impossibly tight.  If so,
+    * If max_d >= 0, determine whether the bound is impossibly tight.  If so,
     * return max_d + 1 immediately.  Otherwise, determine whether it's tight
     * enough to limit the computation we must perform.  If so, figure out
     * initial stop column.
     */
    if (max_d >= 0)
    {
-       int     min_theo_d;     /* Theoretical minimum distance. */
-       int     max_theo_d;     /* Theoretical maximum distance. */
-       int     net_inserts = n - m;
+       int         min_theo_d; /* Theoretical minimum distance. */
+       int         max_theo_d; /* Theoretical maximum distance. */
+       int         net_inserts = n - m;
 
        min_theo_d = net_inserts < 0 ?
            -net_inserts * del_c : net_inserts * ins_c;
@@ -162,20 +164,20 @@ levenshtein_internal(text *s, text *t,
        else if (ins_c + del_c > 0)
        {
            /*
-            * Figure out how much of the first row of the notional matrix
-            * we need to fill in.  If the string is growing, the theoretical
+            * Figure out how much of the first row of the notional matrix we
+            * need to fill in.  If the string is growing, the theoretical
             * minimum distance already incorporates the cost of deleting the
-            * number of characters necessary to make the two strings equal
-            * in length.  Each additional deletion forces another insertion,
-            * so the best-case total cost increases by ins_c + del_c.
-            * If the string is shrinking, the minimum theoretical cost
-            * assumes no excess deletions; that is, we're starting no futher
-            * right than column n - m.  If we do start further right, the
-            * best-case total cost increases by ins_c + del_c for each move
-            * right.
+            * number of characters necessary to make the two strings equal in
+            * length.  Each additional deletion forces another insertion, so
+            * the best-case total cost increases by ins_c + del_c. If the
+            * string is shrinking, the minimum theoretical cost assumes no
+            * excess deletions; that is, we're starting no futher right than
+            * column n - m.  If we do start further right, the best-case
+            * total cost increases by ins_c + del_c for each move right.
             */
-           int slack_d = max_d - min_theo_d;
-           int best_column = net_inserts < 0 ? -net_inserts : 0;
+           int         slack_d = max_d - min_theo_d;
+           int         best_column = net_inserts < 0 ? -net_inserts : 0;
+
            stop_column = best_column + (slack_d / (ins_c + del_c)) + 1;
            if (stop_column > m)
                stop_column = m + 1;
@@ -185,15 +187,15 @@ levenshtein_internal(text *s, text *t,
 
    /*
     * In order to avoid calling pg_mblen() repeatedly on each character in s,
-    * we cache all the lengths before starting the main loop -- but if all the
-    * characters in both strings are single byte, then we skip this and use
-    * a fast-path in the main loop.  If only one string contains multi-byte
-    * characters, we still build the array, so that the fast-path needn't
-    * deal with the case where the array hasn't been initialized.
+    * we cache all the lengths before starting the main loop -- but if all
+    * the characters in both strings are single byte, then we skip this and
+    * use a fast-path in the main loop.  If only one string contains
+    * multi-byte characters, we still build the array, so that the fast-path
+    * needn't deal with the case where the array hasn't been initialized.
     */
    if (m != s_bytes || n != t_bytes)
    {
-       int     i;
+       int         i;
        const char *cp = s_data;
 
        s_char_len = (int *) palloc((m + 1) * sizeof(int));
@@ -214,8 +216,8 @@ levenshtein_internal(text *s, text *t,
    curr = prev + m;
 
    /*
-    * To transform the first i characters of s into the first 0 characters
-    * of t, we must perform i deletions.
+    * To transform the first i characters of s into the first 0 characters of
+    * t, we must perform i deletions.
     */
    for (i = START_COLUMN; i < STOP_COLUMN; i++)
        prev[i] = i * del_c;
@@ -228,6 +230,7 @@ levenshtein_internal(text *s, text *t,
        int         y_char_len = n != t_bytes + 1 ? pg_mblen(y) : 1;
 
 #ifdef LEVENSHTEIN_LESS_EQUAL
+
        /*
         * In the best case, values percolate down the diagonal unchanged, so
         * we must increment stop_column unless it's already on the right end
@@ -241,10 +244,10 @@ levenshtein_internal(text *s, text *t,
        }
 
        /*
-        * The main loop fills in curr, but curr[0] needs a special case:
-        * to transform the first 0 characters of s into the first j
-        * characters of t, we must perform j insertions.  However, if
-        * start_column > 0, this special case does not apply.
+        * The main loop fills in curr, but curr[0] needs a special case: to
+        * transform the first 0 characters of s into the first j characters
+        * of t, we must perform j insertions.  However, if start_column > 0,
+        * this special case does not apply.
         */
        if (start_column == 0)
        {
@@ -285,7 +288,7 @@ levenshtein_internal(text *s, text *t,
                 */
                ins = prev[i] + ins_c;
                del = curr[i - 1] + del_c;
-               if (x[x_char_len-1] == y[y_char_len-1]
+               if (x[x_char_len - 1] == y[y_char_len - 1]
                    && x_char_len == y_char_len &&
                    (x_char_len == 1 || rest_of_char_same(x, y, x_char_len)))
                    sub = prev[i - 1];
@@ -331,6 +334,7 @@ levenshtein_internal(text *s, text *t,
        y += y_char_len;
 
 #ifdef LEVENSHTEIN_LESS_EQUAL
+
        /*
         * This chunk of code represents a significant performance hit if used
         * in the case where there is no max_d bound.  This is probably not
@@ -348,15 +352,16 @@ levenshtein_internal(text *s, text *t,
             * string, so we want to find the value for zp where where (n - 1)
             * - j = (m - 1) - zp.
             */
-           int zp = j - (n - m);
+           int         zp = j - (n - m);
 
            /* Check whether the stop column can slide left. */
            while (stop_column > 0)
            {
-               int ii = stop_column - 1;
-               int net_inserts = ii - zp;
+               int         ii = stop_column - 1;
+               int         net_inserts = ii - zp;
+
                if (prev[ii] + (net_inserts > 0 ? net_inserts * ins_c :
-                   -net_inserts * del_c) <= max_d)
+                               -net_inserts * del_c) <= max_d)
                    break;
                stop_column--;
            }
@@ -364,14 +369,16 @@ levenshtein_internal(text *s, text *t,
            /* Check whether the start column can slide right. */
            while (start_column < stop_column)
            {
-               int net_inserts = start_column - zp;
+               int         net_inserts = start_column - zp;
+
                if (prev[start_column] +
                    (net_inserts > 0 ? net_inserts * ins_c :
-                   -net_inserts * del_c) <= max_d)
+                    -net_inserts * del_c) <= max_d)
                    break;
+
                /*
-                * We'll never again update these values, so we must make
-                * sure there's nothing here that could confuse any future
+                * We'll never again update these values, so we must make sure
+                * there's nothing here that could confuse any future
                 * iteration of the outer loop.
                 */
                prev[start_column] = max_d + 1;
index d55674c79f902f5a4091899a48e3121adf12dd84..2007801cf0c97300cc201af5a19cdfd9f3c14a04 100644 (file)
@@ -13,7 +13,7 @@
 /*
  * When using a GIN index for hstore, we choose to index both keys and values.
  * The storage format is "text" values, with K, V, or N prepended to the string
- * to indicate key, value, or null values.  (As of 9.1 it might be better to
+ * to indicate key, value, or null values. (As of 9.1 it might be better to
  * store null values as nulls, but we'll keep it this way for on-disk
  * compatibility.)
  */
@@ -168,7 +168,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS)
    {
        /*
         * Index doesn't have information about correspondence of keys and
-        * values, so we need recheck.  However, if not all the keys are
+        * values, so we need recheck.  However, if not all the keys are
         * present, we can fail at once.
         */
        *recheck = true;
index cb6200ab1dcfbb9807e39c190e9c662215418424..5b278c14ffe249f3e3208f992073b337e9fff622 100644 (file)
@@ -437,7 +437,7 @@ hstore_delete_hstore(PG_FUNCTION_ARGS)
            if (snullval != HS_VALISNULL(es2, j)
                || (!snullval
                    && (svallen != HS_VALLEN(es2, j)
-                       || memcmp(HS_VAL(es, ps, i), HS_VAL(es2, ps2, j), svallen) != 0)))
+           || memcmp(HS_VAL(es, ps, i), HS_VAL(es2, ps2, j), svallen) != 0)))
            {
                HS_COPYITEM(ed, bufd, pd,
                            HS_KEY(es, ps, i), HS_KEYLEN(es, i),
@@ -1000,7 +1000,7 @@ hstore_contains(PG_FUNCTION_ARGS)
            if (nullval != HS_VALISNULL(ve, idx)
                || (!nullval
                    && (vallen != HS_VALLEN(ve, idx)
-           || memcmp(HS_VAL(te, tstr, i), HS_VAL(ve, vstr, idx), vallen))))
+            || memcmp(HS_VAL(te, tstr, i), HS_VAL(ve, vstr, idx), vallen))))
                res = false;
        }
        else
index 072e8cc89773b052be3f0a805067db7ab3b0c8bc..4e63f6d66c145072984360be989723cd682b9924 100644 (file)
@@ -98,7 +98,7 @@ gettoken(WORKSTATE *state, int4 *val)
                }
                else
                {
-                   long    lval;
+                   long        lval;
 
                    nnn[innn] = '\0';
                    errno = 0;
@@ -355,8 +355,8 @@ gin_bool_consistent(QUERYTYPE *query, bool *check)
        return FALSE;
 
    /*
-    * Set up data for checkcondition_gin.  This must agree with the
-    * query extraction code in ginint4_queryextract.
+    * Set up data for checkcondition_gin.  This must agree with the query
+    * extraction code in ginint4_queryextract.
     */
    gcv.first = items;
    gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size);
index 3ef5c4635a150b94a90651a375e1e523ee9f78cd..9abe54e55f9f4501c2999237e62b06dcaf86ca66 100644 (file)
@@ -34,8 +34,8 @@ ginint4_queryextract(PG_FUNCTION_ARGS)
 
        /*
         * If the query doesn't have any required primitive values (for
-        * instance, it's something like '! 42'), we have to do a full
-        * index scan.
+        * instance, it's something like '! 42'), we have to do a full index
+        * scan.
         */
        if (query_has_required_values(query))
            *searchMode = GIN_SEARCH_MODE_DEFAULT;
@@ -95,7 +95,7 @@ ginint4_queryextract(PG_FUNCTION_ARGS)
            case RTOldContainsStrategyNumber:
                if (*nentries > 0)
                    *searchMode = GIN_SEARCH_MODE_DEFAULT;
-               else                /* everything contains the empty set */
+               else    /* everything contains the empty set */
                    *searchMode = GIN_SEARCH_MODE_ALL;
                break;
            default:
@@ -116,6 +116,7 @@ ginint4_consistent(PG_FUNCTION_ARGS)
    bool       *check = (bool *) PG_GETARG_POINTER(0);
    StrategyNumber strategy = PG_GETARG_UINT16(1);
    int32       nkeys = PG_GETARG_INT32(3);
+
    /* Pointer     *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
    bool       *recheck = (bool *) PG_GETARG_POINTER(5);
    bool        res = FALSE;
index ddf07f042b24140a51f2311099c4accfae26e1f4..bfc55501dbcdd6f9ba361808b69a712207cb0031 100644 (file)
@@ -183,7 +183,7 @@ rt__int_size(ArrayType *a, float *size)
    *size = (float) ARRNELEMS(a);
 }
 
-/* Sort the given data (len >= 2).  Return true if any duplicates found */
+/* Sort the given data (len >= 2). Return true if any duplicates found */
 bool
 isort(int4 *a, int len)
 {
@@ -195,7 +195,7 @@ isort(int4 *a, int len)
    bool        r = FALSE;
 
    /*
-    * We use a simple insertion sort.  While this is O(N^2) in the worst
+    * We use a simple insertion sort.  While this is O(N^2) in the worst
     * case, it's quite fast if the input is already sorted or nearly so.
     * Also, for not-too-large inputs it's faster than more complex methods
     * anyhow.
index c0301ced1e0ceea3e8265903603485ed2f1ec151..dbda6fb7241400063b86ca2deb1bd28872a3361c 100644 (file)
@@ -988,4 +988,3 @@ const char *ISBN_range_new[][2] = {
    {"10-976000", "10-999999"},
    {NULL, NULL},
 };
-
index 79892077c8c012225cf82fc716d3208a41b3564a..d96eef2c5a618910bbf80ed43f3a41cac1dd82f4 100644 (file)
@@ -25,9 +25,9 @@
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #endif
-#else  /* WIN32 */
+#else                          /* WIN32 */
 extern int getopt(int argc, char *const argv[], const char *optstring);
-#endif /* ! WIN32 */
+#endif   /* ! WIN32 */
 
 extern char *optarg;
 extern int optind;
index 87cf8c55cf491831bbf5a9db79ca1eb3e9b81cc9..0236b87498fa27a4c445046469f89b7615e75632 100644 (file)
@@ -137,7 +137,7 @@ typedef enum
    PGSS_TRACK_NONE,            /* track no statements */
    PGSS_TRACK_TOP,             /* only top level statements */
    PGSS_TRACK_ALL              /* all statements, including nested ones */
-} PGSSTrackLevel;
+}  PGSSTrackLevel;
 
 static const struct config_enum_entry track_options[] =
 {
index 49a7b3c2c006d3e2e405cd3dd6d64e3b7febfe8f..305b3d0723ddf23014d56b87c0e4aa2ab3afd6a0 100644 (file)
 
 static const char *progname;
 
-static int     ops_per_test = 2000;
-static char        full_buf[XLOG_SEG_SIZE], *buf, *filename = FSYNC_FILENAME;
-static struct timeval start_t, stop_t;
-
-
-static void    handle_args(int argc, char *argv[]);
-static void    prepare_buf(void);
-static void    test_open(void);
-static void    test_non_sync(void);
-static void    test_sync(int writes_per_op);
-static void    test_open_syncs(void);
-static void    test_open_sync(const char *msg, int writes_size);
-static void    test_file_descriptor_sync(void);
+static int ops_per_test = 2000;
+static char full_buf[XLOG_SEG_SIZE],
+          *buf,
+          *filename = FSYNC_FILENAME;
+static struct timeval start_t,
+           stop_t;
+
+
+static void handle_args(int argc, char *argv[]);
+static void prepare_buf(void);
+static void test_open(void);
+static void test_non_sync(void);
+static void test_sync(int writes_per_op);
+static void test_open_syncs(void);
+static void test_open_sync(const char *msg, int writes_size);
+static void test_file_descriptor_sync(void);
+
 #ifdef HAVE_FSYNC_WRITETHROUGH
 static int pg_fsync_writethrough(int fd);
 #endif
-static void    print_elapse(struct timeval start_t, struct timeval stop_t);
-static void    die(const char *str);
+static void print_elapse(struct timeval start_t, struct timeval stop_t);
+static void die(const char *str);
 
 
 int
@@ -103,7 +107,7 @@ handle_args(int argc, char *argv[])
    }
 
    while ((option = getopt_long(argc, argv, "f:o:",
-           long_options, &optindex)) != -1)
+                                long_options, &optindex)) != -1)
    {
        switch (option)
        {
@@ -176,7 +180,9 @@ test_open(void)
 static void
 test_sync(int writes_per_op)
 {
-   int         tmpfile, ops, writes;
+   int         tmpfile,
+               ops,
+               writes;
    bool        fs_warning = false;
 
    if (writes_per_op == 1)
@@ -353,7 +359,9 @@ test_open_syncs(void)
 static void
 test_open_sync(const char *msg, int writes_size)
 {
-   int     tmpfile, ops, writes;
+   int         tmpfile,
+               ops,
+               writes;
 
    printf(LABEL_FORMAT, msg);
    fflush(stdout);
@@ -377,7 +385,6 @@ test_open_sync(const char *msg, int writes_size)
        close(tmpfile);
        print_elapse(start_t, stop_t);
    }
-
 #else
    printf(NA_FORMAT, "n/a\n");
 #endif
@@ -386,22 +393,22 @@ test_open_sync(const char *msg, int writes_size)
 static void
 test_file_descriptor_sync(void)
 {
-   int         tmpfile, ops;
+   int         tmpfile,
+               ops;
 
    /*
-    * Test whether fsync can sync data written on a different
-    * descriptor for the same file.  This checks the efficiency
-    * of multi-process fsyncs against the same file.
-    * Possibly this should be done with writethrough on platforms
-    * which support it.
+    * Test whether fsync can sync data written on a different descriptor for
+    * the same file.  This checks the efficiency of multi-process fsyncs
+    * against the same file. Possibly this should be done with writethrough
+    * on platforms which support it.
     */
    printf("\nTest if fsync on non-write file descriptor is honored:\n");
    printf("(If the times are similar, fsync() can sync data written\n");
    printf("on a different descriptor.)\n");
 
    /*
-    * first write, fsync and close, which is the
-    * normal behavior without multiple descriptors
+    * first write, fsync and close, which is the normal behavior without
+    * multiple descriptors
     */
    printf(LABEL_FORMAT, "write, fsync, close");
    fflush(stdout);
@@ -416,9 +423,10 @@ test_file_descriptor_sync(void)
        if (fsync(tmpfile) != 0)
            die("fsync failed");
        close(tmpfile);
+
        /*
-        * open and close the file again to be consistent
-        * with the following test
+        * open and close the file again to be consistent with the following
+        * test
         */
        if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
            die("could not open output file");
@@ -428,9 +436,8 @@ test_file_descriptor_sync(void)
    print_elapse(start_t, stop_t);
 
    /*
-    * Now open, write, close, open again and fsync
-    * This simulates processes fsyncing each other's
-    * writes.
+    * Now open, write, close, open again and fsync This simulates processes
+    * fsyncing each other's writes.
     */
    printf(LABEL_FORMAT, "write, close, fsync");
    fflush(stdout);
@@ -458,7 +465,8 @@ test_file_descriptor_sync(void)
 static void
 test_non_sync(void)
 {
-   int         tmpfile, ops;
+   int         tmpfile,
+               ops;
 
    /*
     * Test a simple write without fsync
@@ -494,7 +502,6 @@ pg_fsync_writethrough(int fd)
    return -1;
 #endif
 }
-
 #endif
 
 /*
index f3644fcce76271f1713791184ad9a072145fb1d2..61de5d89d161bf7e4d9a5965d0211b1447c0c2c3 100644 (file)
@@ -51,8 +51,9 @@ uint32        trgm2int(trgm *ptr);
 #endif
 #define ISPRINTABLETRGM(t) ( ISPRINTABLECHAR( ((char*)(t)) ) && ISPRINTABLECHAR( ((char*)(t))+1 ) && ISPRINTABLECHAR( ((char*)(t))+2 ) )
 
-#define ISESCAPECHAR(x) (*(x) == '\\') /* Wildcard escape character */
-#define ISWILDCARDCHAR(x) (*(x) == '_' || *(x) == '%')  /* Wildcard meta-character */
+#define ISESCAPECHAR(x) (*(x) == '\\') /* Wildcard escape character */
+#define ISWILDCARDCHAR(x) (*(x) == '_' || *(x) == '%') /* Wildcard
+                                                        * meta-character */
 
 typedef struct
 {
@@ -105,4 +106,4 @@ TRGM       *generate_wildcard_trgm(const char *str, int slen);
 float4     cnt_sml(TRGM *trg1, TRGM *trg2);
 bool       trgm_contained_by(TRGM *trg1, TRGM *trg2);
 
-#endif /* __TRGM_H__ */
+#endif   /* __TRGM_H__ */
index aaca1f97377f23f939b62d270910de033505365f..43ac0b0c6575a78124da79cf4c353a40cc2a0aec 100644 (file)
@@ -67,7 +67,7 @@ gin_extract_value_trgm(PG_FUNCTION_ARGS)
        ptr = GETARR(trg);
        for (i = 0; i < trglen; i++)
        {
-           int32   item = trgm2int(ptr);
+           int32       item = trgm2int(ptr);
 
            entries[i] = Int32GetDatum(item);
            ptr++;
@@ -83,10 +83,11 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
    text       *val = (text *) PG_GETARG_TEXT_P(0);
    int32      *nentries = (int32 *) PG_GETARG_POINTER(1);
    StrategyNumber strategy = PG_GETARG_UINT16(2);
-   /* bool   **pmatch = (bool **) PG_GETARG_POINTER(3); */
-   /* Pointer    *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
-   /* bool   **nullFlags = (bool **) PG_GETARG_POINTER(5); */
-   int32      *searchMode = (int32 *) PG_GETARG_POINTER(6);
+
+   /* bool   **pmatch = (bool **) PG_GETARG_POINTER(3); */
+   /* Pointer    *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+   /* bool   **nullFlags = (bool **) PG_GETARG_POINTER(5); */
+   int32      *searchMode = (int32 *) PG_GETARG_POINTER(6);
    Datum      *entries = NULL;
    TRGM       *trg;
    int32       trglen;
@@ -104,6 +105,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
 #endif
            /* FALL THRU */
        case LikeStrategyNumber:
+
            /*
             * For wildcard search we extract all the trigrams that every
             * potentially-matching string must include.
@@ -112,7 +114,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
            break;
        default:
            elog(ERROR, "unrecognized strategy number: %d", strategy);
-           trg = NULL;     /* keep compiler quiet */
+           trg = NULL;         /* keep compiler quiet */
            break;
    }
 
@@ -125,7 +127,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
        ptr = GETARR(trg);
        for (i = 0; i < trglen; i++)
        {
-           int32   item = trgm2int(ptr);
+           int32       item = trgm2int(ptr);
 
            entries[i] = Int32GetDatum(item);
            ptr++;
@@ -146,9 +148,11 @@ gin_trgm_consistent(PG_FUNCTION_ARGS)
 {
    bool       *check = (bool *) PG_GETARG_POINTER(0);
    StrategyNumber strategy = PG_GETARG_UINT16(1);
+
    /* text    *query = PG_GETARG_TEXT_P(2); */
    int32       nkeys = PG_GETARG_INT32(3);
-   /* Pointer    *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+
+   /* Pointer    *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
    bool       *recheck = (bool *) PG_GETARG_POINTER(5);
    bool        res;
    int32       i,
index d83265c11c38fcb1c37e17babe4d37f5dfd8da8e..b328a09f41fee50beb96a28835e15ef835222cd6 100644 (file)
@@ -190,17 +190,18 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
    GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
    text       *query = PG_GETARG_TEXT_P(1);
    StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
+
    /* Oid      subtype = PG_GETARG_OID(3); */
    bool       *recheck = (bool *) PG_GETARG_POINTER(4);
    TRGM       *key = (TRGM *) DatumGetPointer(entry->key);
    TRGM       *qtrg;
    bool        res;
    char       *cache = (char *) fcinfo->flinfo->fn_extra,
-              *cacheContents = cache + MAXALIGN(sizeof(StrategyNumber));
+              *cacheContents = cache + MAXALIGN(sizeof(StrategyNumber));
 
    /*
     * Store both the strategy number and extracted trigrams in cache, because
-    * trigram extraction is relatively CPU-expensive.  We must include
+    * trigram extraction is relatively CPU-expensive.  We must include
     * strategy number because trigram extraction depends on strategy.
     */
    if (cache == NULL || strategy != *((StrategyNumber *) cache) ||
@@ -222,7 +223,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
                break;
            default:
                elog(ERROR, "unrecognized strategy number: %d", strategy);
-               qtrg = NULL;        /* keep compiler quiet */
+               qtrg = NULL;    /* keep compiler quiet */
                break;
        }
 
@@ -251,20 +252,20 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
            *recheck = false;
 
            if (GIST_LEAF(entry))
-           {                           /* all leafs contains orig trgm */
-               float4      tmpsml = cnt_sml(key, qtrg);
+           {                   /* all leafs contains orig trgm */
+               float4      tmpsml = cnt_sml(key, qtrg);
 
                /* strange bug at freebsd 5.2.1 and gcc 3.3.3 */
                res = (*(int *) &tmpsml == *(int *) &trgm_limit || tmpsml > trgm_limit) ? true : false;
            }
            else if (ISALLTRUE(key))
-           {                           /* non-leaf contains signature */
+           {                   /* non-leaf contains signature */
                res = true;
            }
            else
-           {                           /* non-leaf contains signature */
-               int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
-               int4 len = ARRNELEM(qtrg);
+           {                   /* non-leaf contains signature */
+               int4        count = cnt_sml_sign_common(qtrg, GETSIGN(key));
+               int4        len = ARRNELEM(qtrg);
 
                if (len == 0)
                    res = false;
@@ -286,20 +287,20 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
             * nodes.
             */
            if (GIST_LEAF(entry))
-           {                           /* all leafs contains orig trgm */
+           {                   /* all leafs contains orig trgm */
                res = trgm_contained_by(qtrg, key);
            }
            else if (ISALLTRUE(key))
-           {                           /* non-leaf contains signature */
+           {                   /* non-leaf contains signature */
                res = true;
            }
            else
-           {                           /* non-leaf contains signature */
-               int32   k,
-                       tmp = 0,
-                       len = ARRNELEM(qtrg);
-               trgm *ptr = GETARR(qtrg);
-               BITVECP sign = GETSIGN(key);
+           {                   /* non-leaf contains signature */
+               int32       k,
+                           tmp = 0,
+                           len = ARRNELEM(qtrg);
+               trgm       *ptr = GETARR(qtrg);
+               BITVECP     sign = GETSIGN(key);
 
                res = true;
                for (k = 0; k < len; k++)
@@ -328,6 +329,7 @@ gtrgm_distance(PG_FUNCTION_ARGS)
    GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
    text       *query = PG_GETARG_TEXT_P(1);
    StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
+
    /* Oid      subtype = PG_GETARG_OID(3); */
    TRGM       *key = (TRGM *) DatumGetPointer(entry->key);
    TRGM       *qtrg;
@@ -355,17 +357,17 @@ gtrgm_distance(PG_FUNCTION_ARGS)
    {
        case DistanceStrategyNumber:
            if (GIST_LEAF(entry))
-           {                           /* all leafs contains orig trgm */
+           {                   /* all leafs contains orig trgm */
                res = 1.0 - cnt_sml(key, qtrg);
            }
            else if (ISALLTRUE(key))
-           {                           /* all leafs contains orig trgm */
+           {                   /* all leafs contains orig trgm */
                res = 0.0;
            }
            else
-           {                           /* non-leaf contains signature */
-               int4 count = cnt_sml_sign_common(qtrg, GETSIGN(key));
-               int4 len = ARRNELEM(qtrg);
+           {                   /* non-leaf contains signature */
+               int4        count = cnt_sml_sign_common(qtrg, GETSIGN(key));
+               int4        len = ARRNELEM(qtrg);
 
                res = (len == 0) ? -1.0 : 1.0 - ((float8) count) / ((float8) len);
            }
index 52f9172f6d52d3e307341b1a5446082315ce8e27..dfb2df50488223a576120c1d11bebc5a8d2c2ac1 100644 (file)
@@ -273,9 +273,9 @@ get_wildcard_part(const char *str, int lenstr,
    const char *beginword = str;
    const char *endword;
    char       *s = buf;
-   bool        in_wildcard_meta = false;
-   bool        in_escape = false;
-   int         clen;
+   bool        in_wildcard_meta = false;
+   bool        in_escape = false;
+   int         clen;
 
    /*
     * Find the first word character remembering whether last character was
@@ -410,14 +410,14 @@ generate_wildcard_trgm(const char *str, int slen)
 {
    TRGM       *trg;
    char       *buf,
-              *buf2;
+              *buf2;
    trgm       *tptr;
    int         len,
                charlen,
                bytelen;
    const char *eword;
 
-   trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) * 3);
+   trg = (TRGM *) palloc(TRGMHDRSIZE + sizeof(trgm) * (slen / 2 + 1) *3);
    trg->flag = ARRKEY;
    SET_VARSIZE(trg, TRGMHDRSIZE);
 
@@ -638,6 +638,7 @@ similarity_dist(PG_FUNCTION_ARGS)
    float4      res = DatumGetFloat4(DirectFunctionCall2(similarity,
                                                         PG_GETARG_DATUM(0),
                                                         PG_GETARG_DATUM(1)));
+
    PG_RETURN_FLOAT4(1.0 - res);
 }
 
index 05aac8fde9cd5a05c8e351f25b9ab79e0e31eb42..747244072d434f8a5317dc5f37587d7684bb9963 100644 (file)
@@ -212,7 +212,10 @@ check_cluster_versions(void)
    old_cluster.major_version = get_major_server_version(&old_cluster);
    new_cluster.major_version = get_major_server_version(&new_cluster);
 
-   /* We allow upgrades from/to the same major version for alpha/beta upgrades */
+   /*
+    * We allow upgrades from/to the same major version for alpha/beta
+    * upgrades
+    */
 
    if (GET_MAJOR_VERSION(old_cluster.major_version) < 803)
        pg_log(PG_FATAL, "This utility can only upgrade from PostgreSQL version 8.3 and later.\n");
@@ -516,7 +519,7 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
    }
 
    if (script)
-           fclose(script);
+       fclose(script);
 
    if (found)
    {
index 78c75e8a8438bae5e632c4e40802e0712ab7bd57..3ac2180d49bf76296c4521eb4d87f206314818c9 100644 (file)
@@ -505,8 +505,7 @@ check_control_data(ControlData *oldctrl,
               "\nOld and new pg_controldata date/time storage types do not match.\n");
 
        /*
-        * This is a common 8.3 -> 8.4 upgrade problem, so we are more
-        * verbose
+        * This is a common 8.3 -> 8.4 upgrade problem, so we are more verbose
         */
        pg_log(PG_FATAL,
               "You will need to rebuild the new server with configure\n"
index 7095ba62a8013a4d2f21ef4edfb615b784d53642..59a76bc8aec075b72b0848c361ef4e2c2fe7fe50 100644 (file)
@@ -15,7 +15,7 @@
 
 static void check_data_dir(const char *pg_data);
 static void check_bin_dir(ClusterInfo *cluster);
-static void    validate_exec(const char *dir, const char *cmdName);
+static void validate_exec(const char *dir, const char *cmdName);
 
 
 /*
index 0024b6ee00597bbba47a0b7f754c542aa54f7a76..f8f7233593d5ae4dfaf30c955b6c7fc660ac602f 100644 (file)
@@ -377,4 +377,5 @@ win32_pghardlink(const char *src, const char *dst)
    else
        return 0;
 }
+
 #endif
index c01ff046bbd6a780f0f88ffec68285774745d69d..322014cd235cb404f586f72d63a845ba7c1405d7 100644 (file)
 void
 install_support_functions_in_new_db(const char *db_name)
 {
-   PGconn *conn = connectToServer(&new_cluster, db_name);
-   
+   PGconn     *conn = connectToServer(&new_cluster, db_name);
+
    /* suppress NOTICE of dropped objects */
    PQclear(executeQueryOrDie(conn,
                              "SET client_min_messages = warning;"));
    PQclear(executeQueryOrDie(conn,
-                      "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;"));
+                          "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;"));
    PQclear(executeQueryOrDie(conn,
                              "RESET client_min_messages;"));
 
@@ -42,31 +42,31 @@ install_support_functions_in_new_db(const char *db_name)
                              "LANGUAGE C STRICT;"));
    PQclear(executeQueryOrDie(conn,
                              "CREATE OR REPLACE FUNCTION "
-                             "binary_upgrade.set_next_array_pg_type_oid(OID) "
+                           "binary_upgrade.set_next_array_pg_type_oid(OID) "
                              "RETURNS VOID "
                              "AS '$libdir/pg_upgrade_support' "
                              "LANGUAGE C STRICT;"));
    PQclear(executeQueryOrDie(conn,
                              "CREATE OR REPLACE FUNCTION "
-                             "binary_upgrade.set_next_toast_pg_type_oid(OID) "
+                           "binary_upgrade.set_next_toast_pg_type_oid(OID) "
                              "RETURNS VOID "
                              "AS '$libdir/pg_upgrade_support' "
                              "LANGUAGE C STRICT;"));
    PQclear(executeQueryOrDie(conn,
                              "CREATE OR REPLACE FUNCTION "
-                             "binary_upgrade.set_next_heap_pg_class_oid(OID) "
+                           "binary_upgrade.set_next_heap_pg_class_oid(OID) "
                              "RETURNS VOID "
                              "AS '$libdir/pg_upgrade_support' "
                              "LANGUAGE C STRICT;"));
    PQclear(executeQueryOrDie(conn,
                              "CREATE OR REPLACE FUNCTION "
-                             "binary_upgrade.set_next_index_pg_class_oid(OID) "
+                          "binary_upgrade.set_next_index_pg_class_oid(OID) "
                              "RETURNS VOID "
                              "AS '$libdir/pg_upgrade_support' "
                              "LANGUAGE C STRICT;"));
    PQclear(executeQueryOrDie(conn,
                              "CREATE OR REPLACE FUNCTION "
-                             "binary_upgrade.set_next_toast_pg_class_oid(OID) "
+                          "binary_upgrade.set_next_toast_pg_class_oid(OID) "
                              "RETURNS VOID "
                              "AS '$libdir/pg_upgrade_support' "
                              "LANGUAGE C STRICT;"));
index ceb1601cc6d8922bdd0fc33177500e480506bd9d..f0cd8e5ede29a02db5c4f45ce414897f91772e7f 100644 (file)
@@ -13,9 +13,9 @@
 
 
 static void create_rel_filename_map(const char *old_data, const char *new_data,
-             const DbInfo *old_db, const DbInfo *new_db,
-             const RelInfo *old_rel, const RelInfo *new_rel,
-             FileNameMap *map);
+                       const DbInfo *old_db, const DbInfo *new_db,
+                       const RelInfo *old_rel, const RelInfo *new_rel,
+                       FileNameMap *map);
 static void get_db_infos(ClusterInfo *cluster);
 static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
 static void free_rel_infos(RelInfoArr *rel_arr);
@@ -40,7 +40,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
 
    if (old_db->rel_arr.nrels != new_db->rel_arr.nrels)
        pg_log(PG_FATAL, "old and new databases \"%s\" have a different number of relations\n",
-                   old_db->db_name);
+              old_db->db_name);
 
    maps = (FileNameMap *) pg_malloc(sizeof(FileNameMap) *
                                     old_db->rel_arr.nrels);
@@ -52,24 +52,24 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
 
        if (old_rel->reloid != new_rel->reloid)
            pg_log(PG_FATAL, "Mismatch of relation id: database \"%s\", old relid %d, new relid %d\n",
-           old_db->db_name, old_rel->reloid, new_rel->reloid);
+                  old_db->db_name, old_rel->reloid, new_rel->reloid);
 
        /*
-        *  In pre-8.4, TOAST table names change during CLUSTER;  in >= 8.4
-        *  TOAST relation names always use heap table oids, hence we
-        *  cannot check relation names when upgrading from pre-8.4.
+        * In pre-8.4, TOAST table names change during CLUSTER;  in >= 8.4
+        * TOAST relation names always use heap table oids, hence we cannot
+        * check relation names when upgrading from pre-8.4.
         */
        if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
            ((GET_MAJOR_VERSION(old_cluster.major_version) >= 804 ||
              strcmp(old_rel->nspname, "pg_toast") != 0) &&
             strcmp(old_rel->relname, new_rel->relname) != 0))
            pg_log(PG_FATAL, "Mismatch of relation names: database \"%s\", "
-               "old rel %s.%s, new rel %s.%s\n",
-               old_db->db_name, old_rel->nspname, old_rel->relname,
-               new_rel->nspname, new_rel->relname);
+                  "old rel %s.%s, new rel %s.%s\n",
+                  old_db->db_name, old_rel->nspname, old_rel->relname,
+                  new_rel->nspname, new_rel->relname);
 
        create_rel_filename_map(old_pgdata, new_pgdata, old_db, new_db,
-               old_rel, new_rel, maps + num_maps);
+                               old_rel, new_rel, maps + num_maps);
        num_maps++;
    }
 
@@ -85,9 +85,9 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
  */
 static void
 create_rel_filename_map(const char *old_data, const char *new_data,
-             const DbInfo *old_db, const DbInfo *new_db,
-             const RelInfo *old_rel, const RelInfo *new_rel,
-             FileNameMap *map)
+                       const DbInfo *old_db, const DbInfo *new_db,
+                       const RelInfo *old_rel, const RelInfo *new_rel,
+                       FileNameMap *map)
 {
    if (strlen(old_rel->tablespace) == 0)
    {
@@ -110,8 +110,8 @@ create_rel_filename_map(const char *old_data, const char *new_data,
    }
 
    /*
-    *  old_relfilenode might differ from pg_class.oid (and hence
-    *  new_relfilenode) because of CLUSTER, REINDEX, or VACUUM FULL.
+    * old_relfilenode might differ from pg_class.oid (and hence
+    * new_relfilenode) because of CLUSTER, REINDEX, or VACUUM FULL.
     */
    map->old_relfilenode = old_rel->relfilenode;
 
@@ -185,7 +185,9 @@ get_db_infos(ClusterInfo *cluster)
    int         ntups;
    int         tupnum;
    DbInfo     *dbinfos;
-   int         i_datname, i_oid, i_spclocation;
+   int         i_datname,
+               i_oid,
+               i_spclocation;
 
    res = executeQueryOrDie(conn,
                            "SELECT d.oid, d.datname, t.spclocation "
@@ -241,15 +243,19 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
    int         num_rels = 0;
    char       *nspname = NULL;
    char       *relname = NULL;
-   int         i_spclocation, i_nspname, i_relname, i_oid, i_relfilenode;
+   int         i_spclocation,
+               i_nspname,
+               i_relname,
+               i_oid,
+               i_relfilenode;
    char        query[QUERY_ALLOC];
 
    /*
     * pg_largeobject contains user data that does not appear in pg_dumpall
     * --schema-only output, so we have to copy that system table heap and
-    * index.  We could grab the pg_largeobject oids from template1, but
-    * it is easy to treat it as a normal table.
-    * Order by oid so we can join old/new structures efficiently.
+    * index.  We could grab the pg_largeobject oids from template1, but it is
+    * easy to treat it as a normal table. Order by oid so we can join old/new
+    * structures efficiently.
     */
 
    snprintf(query, sizeof(query),
@@ -263,7 +269,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
             "  ((n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
             "    c.oid >= %u) "
             "  OR (n.nspname = 'pg_catalog' AND "
-            "    relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
+   "    relname IN ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
    /* we preserve pg_class.oid so we sort by it to match old/new */
             "ORDER BY 1;",
    /* see the comment at the top of old_8_3_create_sequence_script() */
@@ -273,7 +279,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
             FirstNormalObjectId,
    /* does pg_largeobject_metadata need to be migrated? */
             (GET_MAJOR_VERSION(old_cluster.major_version) <= 804) ?
-            "" : ", 'pg_largeobject_metadata', 'pg_largeobject_metadata_oid_index'");
+   "" : ", 'pg_largeobject_metadata', 'pg_largeobject_metadata_oid_index'");
 
    res = executeQueryOrDie(conn, query);
 
index 061544cac889fcb1bd77878a9b810f811c146838..e435aaef08c88a581344bedb6aae67093e3f1450 100644 (file)
@@ -18,7 +18,7 @@
  * FYI, while pg_class.oid and pg_class.relfilenode are intially the same
  * in a cluster, but they can diverge due to CLUSTER, REINDEX, or VACUUM
  * FULL.  The new cluster will have matching pg_class.oid and
- * pg_class.relfilenode values and be based on the old oid value.  This can
+ * pg_class.relfilenode values and be based on the old oid value.  This can
  * cause the old and new pg_class.relfilenode values to differ.  In summary,
  * old and new pg_class.oid and new pg_class.relfilenode will have the
  * same value, and old pg_class.relfilenode might differ.
@@ -34,7 +34,7 @@
  */
 
 
+
 #include "pg_upgrade.h"
 
 #ifdef HAVE_LANGINFO_H
@@ -53,7 +53,8 @@ static void cleanup(void);
 /* This is the database used by pg_dumpall to restore global tables */
 #define GLOBAL_DUMP_DB "postgres"
 
-ClusterInfo old_cluster, new_cluster;
+ClusterInfo old_cluster,
+           new_cluster;
 OSInfo     os_info;
 
 int
@@ -192,7 +193,7 @@ prepare_new_cluster(void)
    exec_prog(true,
              SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
              "--all --analyze >> %s 2>&1" SYSTEMQUOTE,
-          new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
+     new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
    check_ok();
 
    /*
@@ -205,7 +206,7 @@ prepare_new_cluster(void)
    exec_prog(true,
              SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
              "--all --freeze >> %s 2>&1" SYSTEMQUOTE,
-          new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
+     new_cluster.bindir, new_cluster.port, os_info.user, log_opts.filename);
    check_ok();
 
    get_pg_database_relfilenode(&new_cluster);
@@ -229,16 +230,16 @@ prepare_new_databases(void)
    prep_status("Creating databases in the new cluster");
 
    /*
-    *  Install support functions in the global-restore database
-    *  to preserve pg_authid.oid.
+    * Install support functions in the global-restore database to preserve
+    * pg_authid.oid.
     */
    install_support_functions_in_new_db(GLOBAL_DUMP_DB);
 
    /*
     * We have to create the databases first so we can install support
-    * functions in all the other databases.  Ideally we could create
-    * the support functions in template1 but pg_dumpall creates database
-    * using the template0 template.
+    * functions in all the other databases.  Ideally we could create the
+    * support functions in template1 but pg_dumpall creates database using
+    * the template0 template.
     */
    exec_prog(true,
              SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on "
index 8f72ea80d7ad9eb448a602de1f33b70a362b23f4..5ca570eb157c7e7287464025d7d526a59c568b89 100644 (file)
@@ -85,6 +85,7 @@ typedef struct
 {
    char        old_dir[MAXPGPATH];
    char        new_dir[MAXPGPATH];
+
    /*
     * old/new relfilenodes might differ for pg_largeobject(_metadata) indexes
     * due to VACUUM FULL or REINDEX.  Other relfilenodes are preserved.
@@ -92,7 +93,7 @@ typedef struct
    Oid         old_relfilenode;
    Oid         new_relfilenode;
    /* the rest are used only for logging and error reporting */
-   char        nspname[NAMEDATALEN];       /* namespaces */
+   char        nspname[NAMEDATALEN];   /* namespaces */
    char        relname[NAMEDATALEN];
 } FileNameMap;
 
@@ -180,7 +181,7 @@ typedef struct
    char       *bindir;         /* pathname for cluster's executable directory */
    unsigned short port;        /* port number where postmaster is waiting */
    uint32      major_version;  /* PG_VERSION of cluster */
-   char       major_version_str[64];       /* string PG_VERSION of cluster */
+   char        major_version_str[64];  /* string PG_VERSION of cluster */
    Oid         pg_database_oid;    /* OID of pg_database relation */
    char       *libpath;        /* pathname for cluster's pkglibdir */
    char       *tablespace_suffix;      /* directory specification */
@@ -232,9 +233,10 @@ typedef struct
 /*
  * Global variables
  */
-extern LogOpts log_opts;
+extern LogOpts log_opts;
 extern UserOpts user_opts;
-extern ClusterInfo old_cluster, new_cluster;
+extern ClusterInfo old_cluster,
+           new_cluster;
 extern OSInfo os_info;
 extern char scandir_file_pattern[];
 
@@ -246,8 +248,8 @@ void check_old_cluster(bool live_check,
                  char **sequence_script_file_name);
 void       check_new_cluster(void);
 void       report_clusters_compatible(void);
-void issue_warnings(char *sequence_script_file_name);
-void output_completion_banner(char *deletion_script_file_name);
+void       issue_warnings(char *sequence_script_file_name);
+void       output_completion_banner(char *deletion_script_file_name);
 void       check_cluster_versions(void);
 void       check_cluster_compatibility(bool live_check);
 void       create_script_for_old_cluster_deletion(char **deletion_script_file_name);
@@ -309,11 +311,11 @@ typedef void *pageCnvCtx;
 
 int            dir_matching_filenames(const struct dirent * scan_ent);
 int pg_scandir(const char *dirname, struct dirent *** namelist,
-              int (*selector) (const struct dirent *));
+          int (*selector) (const struct dirent *));
 const char *copyAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
                  const char *dst, bool force);
 const char *linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
-                             const char *dst);
+                 const char *dst);
 
 void       check_hard_link(void);
 
@@ -329,10 +331,10 @@ void      check_loadable_libraries(void);
 FileNameMap *gen_db_file_maps(DbInfo *old_db,
                 DbInfo *new_db, int *nmaps, const char *old_pgdata,
                 const char *new_pgdata);
-void       get_db_and_rel_infos(ClusterInfo *cluster);
+void       get_db_and_rel_infos(ClusterInfo *cluster);
 void       free_db_and_rel_infos(DbInfoArr *db_arr);
-void       print_maps(FileNameMap *maps, int n,
-               const char *db_name);
+void print_maps(FileNameMap *maps, int n,
+          const char *db_name);
 
 /* option.c */
 
@@ -352,12 +354,12 @@ void      init_tablespaces(void);
 
 /* server.c */
 
-PGconn *connectToServer(ClusterInfo *cluster, const char *db_name);
-PGresult *executeQueryOrDie(PGconn *conn, const char *fmt,...);
+PGconn    *connectToServer(ClusterInfo *cluster, const char *db_name);
+PGresult   *executeQueryOrDie(PGconn *conn, const char *fmt,...);
 
 void       start_postmaster(ClusterInfo *cluster, bool quiet);
 void       stop_postmaster(bool fast, bool quiet);
-uint32 get_major_server_version(ClusterInfo *cluster);
+uint32     get_major_server_version(ClusterInfo *cluster);
 void       check_for_libpq_envvars(void);
 
 
@@ -380,14 +382,14 @@ unsigned int str2uint(const char *str);
 /* version.c */
 
 void new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster,
-                                             bool check_mode);
+                                        bool check_mode);
 
 /* version_old_8_3.c */
 
 void       old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster);
 void       old_8_3_check_for_tsquery_usage(ClusterInfo *cluster);
-void old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode);
-void old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode);
+void       old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode);
+void       old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode);
 void old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
-                                                  bool check_mode);
+                                             bool check_mode);
 char      *old_8_3_create_sequence_script(ClusterInfo *cluster);
index d111b13de905ffe8b5022874e5bf37cc87a74605..9a0a3ac18d9557cf696e452d4e61cab1b9c08485 100644 (file)
@@ -30,7 +30,7 @@ char      scandir_file_pattern[MAXPGPATH];
  */
 const char *
 transfer_all_new_dbs(DbInfoArr *old_db_arr,
-                    DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
+                  DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
 {
    int         dbnum;
    const char *msg = NULL;
@@ -39,7 +39,7 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
 
    if (old_db_arr->ndbs != new_db_arr->ndbs)
        pg_log(PG_FATAL, "old and new clusters have a different number of databases\n");
-   
+
    for (dbnum = 0; dbnum < old_db_arr->ndbs; dbnum++)
    {
        DbInfo     *old_db = &old_db_arr->dbs[dbnum];
@@ -50,8 +50,8 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
 
        if (strcmp(old_db->db_name, new_db->db_name) != 0)
            pg_log(PG_FATAL, "old and new databases have different names: old \"%s\", new \"%s\"\n",
-               old_db->db_name, new_db->db_name);
-       
+                  old_db->db_name, new_db->db_name);
+
        n_maps = 0;
        mappings = gen_db_file_maps(old_db, new_db, &n_maps, old_pgdata,
                                    new_pgdata);
@@ -169,7 +169,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
            for (fileno = 0; fileno < numFiles; fileno++)
            {
                if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
-                   strlen(scandir_file_pattern)) == 0)
+                           strlen(scandir_file_pattern)) == 0)
                {
                    snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
                             namelist[fileno]->d_name);
@@ -178,7 +178,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
 
                    unlink(new_file);
                    transfer_relfile(pageConverter, old_file, new_file,
-                             maps[mapnum].nspname, maps[mapnum].relname);
+                                maps[mapnum].nspname, maps[mapnum].relname);
                }
            }
        }
@@ -196,7 +196,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
        for (fileno = 0; fileno < numFiles; fileno++)
        {
            if (strncmp(namelist[fileno]->d_name, scandir_file_pattern,
-               strlen(scandir_file_pattern)) == 0)
+                       strlen(scandir_file_pattern)) == 0)
            {
                snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_dir,
                         namelist[fileno]->d_name);
@@ -205,7 +205,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
 
                unlink(new_file);
                transfer_relfile(pageConverter, old_file, new_file,
-                             maps[mapnum].nspname, maps[mapnum].relname);
+                                maps[mapnum].nspname, maps[mapnum].relname);
            }
        }
    }
@@ -227,7 +227,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
  */
 static void
 transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
-        const char *new_file, const char *nspname, const char *relname)
+             const char *new_file, const char *nspname, const char *relname)
 {
    const char *msg;
 
@@ -249,7 +249,7 @@ transfer_relfile(pageCnvCtx *pageConverter, const char *old_file,
 
        if ((msg = linkAndUpdateFile(pageConverter, old_file, new_file)) != NULL)
            pg_log(PG_FATAL,
-              "error while creating link from %s.%s (%s to %s): %s\n",
+                  "error while creating link from %s.%s (%s to %s): %s\n",
                   nspname, relname, old_file, new_file, msg);
    }
    return;
index a7d57872346104fca8e8e324f0bc188fed04cfb0..2a0f50eb2a22b4907e8d462db169530e1f251ea0 100644 (file)
@@ -194,12 +194,12 @@ start_postmaster(ClusterInfo *cluster, bool quiet)
     * because it is being used by another process." so we have to send all
     * other output to 'nul'.
     *
-    * Using autovacuum=off disables cleanup vacuum and analyze, but
-    * freeze vacuums can still happen, so we set
-    * autovacuum_freeze_max_age to its maximum.  We assume all datfrozenxid
-    * and relfrozen values are less than a gap of 2000000000 from the current
-    * xid counter, so autovacuum will not touch them.
-    */ 
+    * Using autovacuum=off disables cleanup vacuum and analyze, but freeze
+    * vacuums can still happen, so we set autovacuum_freeze_max_age to its
+    * maximum.  We assume all datfrozenxid and relfrozen values are less than
+    * a gap of 2000000000 from the current xid counter, so autovacuum will
+    * not touch them.
+    */
    snprintf(cmd, sizeof(cmd),
             SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
             "-o \"-p %d -c autovacuum=off "
@@ -251,7 +251,7 @@ stop_postmaster(bool fast, bool quiet)
             "\"%s\" 2>&1" SYSTEMQUOTE,
             bindir,
 #ifndef WIN32
-            log_opts.filename, datadir, fast ? "-m fast" : "", log_opts.filename);
+      log_opts.filename, datadir, fast ? "-m fast" : "", log_opts.filename);
 #else
             DEVNULL, datadir, fast ? "-m fast" : "", DEVNULL);
 #endif
index a575487621906cdfd9b85959f83affd73904e485..6cdae51cf1904b419058d57373cc50fdda855d06 100644 (file)
@@ -78,8 +78,8 @@ set_tablespace_directory_suffix(ClusterInfo *cluster)
    {
        /* This cluster has a version-specific subdirectory */
        cluster->tablespace_suffix = pg_malloc(4 +
-                                 strlen(cluster->major_version_str) +
-                                                     10 /* OIDCHARS */ + 1);
+                                        strlen(cluster->major_version_str) +
+                                              10 /* OIDCHARS */ + 1);
 
        /* The leading slash is needed to start a new directory. */
        sprintf(cluster->tablespace_suffix, "/PG_%s_%d", cluster->major_version_str,
index 804aa0d1e5fa2900cdb59cffea565315294fe503..9a6691ce75f94f0cd353f4e331ac12ab2661febf 100644 (file)
@@ -12,7 +12,7 @@
 #include <signal.h>
 
 
-LogOpts            log_opts;
+LogOpts        log_opts;
 
 /*
  * report_status()
index 3ec4b59a05e17a24b19ecbbe786af7b12681529a..0a60eec926b54764c76dbc68be64cb7d2908c25c 100644 (file)
@@ -288,7 +288,7 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
 
                /* Rebuild all tsvector collumns with one ALTER TABLE command */
                if (strcmp(PQgetvalue(res, rowno, i_nspname), nspname) != 0 ||
-                strcmp(PQgetvalue(res, rowno, i_relname), relname) != 0)
+                   strcmp(PQgetvalue(res, rowno, i_relname), relname) != 0)
                {
                    if (strlen(nspname) != 0 || strlen(relname) != 0)
                        fprintf(script, ";\n\n");
index 02d1512719ec2a7f11e938145b144df39be03f0f..2c23cbab9df07b85583ff450632faaf44cd9f8df 100644 (file)
@@ -178,9 +178,9 @@ create_empty_extension(PG_FUNCTION_ARGS)
                          &textDatums, NULL, &ndatums);
        for (i = 0; i < ndatums; i++)
        {
-           text   *txtname = DatumGetTextPP(textDatums[i]);
-           char   *extName = text_to_cstring(txtname);
-           Oid     extOid = get_extension_oid(extName, false);
+           text       *txtname = DatumGetTextPP(textDatums[i]);
+           char       *extName = text_to_cstring(txtname);
+           Oid         extOid = get_extension_oid(extName, false);
 
            requiredExtensions = lappend_oid(requiredExtensions, extOid);
        }
@@ -188,7 +188,7 @@ create_empty_extension(PG_FUNCTION_ARGS)
 
    InsertExtensionTuple(text_to_cstring(extName),
                         GetUserId(),
-                        get_namespace_oid(text_to_cstring(schemaName), false),
+                      get_namespace_oid(text_to_cstring(schemaName), false),
                         relocatable,
                         text_to_cstring(extVersion),
                         extConfig,
index 7c2ca6e84d361f07908c86c5f33ee7fc9c9bccce..0a3e5fd9283ac92cfe761ea567b0bbdfea1eb56e 100644 (file)
@@ -69,7 +69,7 @@
 typedef struct win32_pthread *pthread_t;
 typedef int pthread_attr_t;
 
-static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
+static int pthread_create(pthread_t *thread, pthread_attr_t * attr, void *(*start_routine) (void *), void *arg);
 static int pthread_join(pthread_t th, void **thread_return);
 #elif defined(ENABLE_THREAD_SAFETY)
 /* Use platform-dependent pthread capability */
@@ -87,7 +87,7 @@ static int    pthread_join(pthread_t th, void **thread_return);
 typedef struct fork_pthread *pthread_t;
 typedef int pthread_attr_t;
 
-static int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
+static int pthread_create(pthread_t *thread, pthread_attr_t * attr, void *(*start_routine) (void *), void *arg);
 static int pthread_join(pthread_t th, void **thread_return);
 #endif
 
@@ -817,7 +817,7 @@ top:
 
            INSTR_TIME_SET_CURRENT(now);
            INSTR_TIME_ACCUM_DIFF(thread->exec_elapsed[cnum],
-                                 now, st->stmt_begin);
+                                 now, st->stmt_begin);
            thread->exec_count[cnum]++;
        }
 
@@ -850,8 +850,8 @@ top:
        if (commands[st->state]->type == SQL_COMMAND)
        {
            /*
-            * Read and discard the query result; note this is not included
-            * in the statement latency numbers.
+            * Read and discard the query result; note this is not included in
+            * the statement latency numbers.
             */
            res = PQgetResult(st->con);
            switch (PQresultStatus(res))
@@ -1716,16 +1716,16 @@ printResults(int ttype, int normal_xacts, int nclients,
 
        for (i = 0; i < num_files; i++)
        {
-           Command   **commands;
+           Command   **commands;
 
            if (num_files > 1)
-               printf("statement latencies in milliseconds, file %d:\n", i+1);
+               printf("statement latencies in milliseconds, file %d:\n", i + 1);
            else
                printf("statement latencies in milliseconds:\n");
 
            for (commands = sql_files[i]; *commands != NULL; commands++)
            {
-               Command    *command = *commands;
+               Command    *command = *commands;
                int         cnum = command->command_num;
                double      total_time;
                instr_time  total_exec_elapsed;
@@ -1737,7 +1737,7 @@ printResults(int ttype, int normal_xacts, int nclients,
                total_exec_count = 0;
                for (t = 0; t < nthreads; t++)
                {
-                   TState *thread = &threads[t];
+                   TState     *thread = &threads[t];
 
                    INSTR_TIME_ADD(total_exec_elapsed,
                                   thread->exec_elapsed[cnum]);
@@ -2014,9 +2014,9 @@ main(int argc, char **argv)
     * is_latencies only works with multiple threads in thread-based
     * implementations, not fork-based ones, because it supposes that the
     * parent can see changes made to the per-thread execution stats by child
-    * threads.  It seems useful enough to accept despite this limitation,
-    * but perhaps we should FIXME someday (by passing the stats data back
-    * up through the parent-to-child pipes).
+    * threads.  It seems useful enough to accept despite this limitation, but
+    * perhaps we should FIXME someday (by passing the stats data back up
+    * through the parent-to-child pipes).
     */
 #ifndef ENABLE_THREAD_SAFETY
    if (is_latencies && nthreads > 1)
@@ -2161,7 +2161,7 @@ main(int argc, char **argv)
    threads = (TState *) xmalloc(sizeof(TState) * nthreads);
    for (i = 0; i < nthreads; i++)
    {
-       TState *thread = &threads[i];
+       TState     *thread = &threads[i];
 
        thread->tid = i;
        thread->state = &state[nclients / nthreads * i];
@@ -2170,7 +2170,7 @@ main(int argc, char **argv)
        if (is_latencies)
        {
            /* Reserve memory for the thread to store per-command latencies */
-           int     t;
+           int         t;
 
            thread->exec_elapsed = (instr_time *)
                xmalloc(sizeof(instr_time) * num_commands);
@@ -2200,7 +2200,7 @@ main(int argc, char **argv)
    /* start threads */
    for (i = 0; i < nthreads; i++)
    {
-       TState *thread = &threads[i];
+       TState     *thread = &threads[i];
 
        INSTR_TIME_SET_CURRENT(thread->start_time);
 
@@ -2472,7 +2472,7 @@ typedef struct fork_pthread
 
 static int
 pthread_create(pthread_t *thread,
-              pthread_attr_t *attr,
+              pthread_attr_t * attr,
               void *(*start_routine) (void *),
               void *arg)
 {
@@ -2586,7 +2586,7 @@ typedef struct win32_pthread
    void       *(*routine) (void *);
    void       *arg;
    void       *result;
-}  win32_pthread;
+} win32_pthread;
 
 static unsigned __stdcall
 win32_pthread_run(void *arg)
@@ -2600,7 +2600,7 @@ win32_pthread_run(void *arg)
 
 static int
 pthread_create(pthread_t *thread,
-              pthread_attr_t *attr,
+              pthread_attr_t * attr,
               void *(*start_routine) (void *),
               void *arg)
 {
index afada2a0aad0f04f75c74c8309ecfd3f9c97b41c..fd284e0c071350918dcaf2283d4967ae1d30d76a 100644 (file)
@@ -356,7 +356,7 @@ gseg_picksplit(GistEntryVector *entryvec,
    {
        seg = (SEG *) DatumGetPointer(entryvec->vector[i].key);
        /* center calculation is done this way to avoid possible overflow */
-       sort_items[i - 1].center = seg->lower*0.5f + seg->upper*0.5f;
+       sort_items[i - 1].center = seg->lower * 0.5f + seg->upper * 0.5f;
        sort_items[i - 1].index = i;
        sort_items[i - 1].data = seg;
    }
index 358a2643ca469891954644fd886974f666c4667c..22666b708e96912b2701cb895c21db1de07d1c86 100644 (file)
@@ -59,7 +59,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns)
    result = bms_copy(columns);
    result = bms_del_member(result, index);
 
-   for (attno=1; attno <= natts; attno++)
+   for (attno = 1; attno <= natts; attno++)
    {
        tuple = SearchSysCache2(ATTNUM,
                                ObjectIdGetDatum(relOid),
@@ -108,6 +108,7 @@ fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns)
    while ((index = bms_first_member(tmpset)) > 0)
    {
        attno = index + FirstLowInvalidHeapAttributeNumber;
+
        /*
         * whole-row-reference shall be fixed-up later
         */
@@ -158,14 +159,13 @@ check_relation_privileges(Oid relOid,
    bool        result = true;
 
    /*
-    * Hardwired Policies:
-    * SE-PostgreSQL enforces
-    * - clients cannot modify system catalogs using DMLs
-    * - clients cannot reference/modify toast relations using DMLs
+    * Hardwired Policies: SE-PostgreSQL enforces - clients cannot modify
+    * system catalogs using DMLs - clients cannot reference/modify toast
+    * relations using DMLs
     */
    if (sepgsql_getenforce() > 0)
    {
-       Oid     relnamespace = get_rel_namespace(relOid);
+       Oid         relnamespace = get_rel_namespace(relOid);
 
        if (IsSystemNamespace(relnamespace) &&
            (required & (SEPG_DB_TABLE__UPDATE |
@@ -242,7 +242,7 @@ check_relation_privileges(Oid relOid,
    {
        AttrNumber  attnum;
        uint32      column_perms = 0;
-       ObjectAddress   object;
+       ObjectAddress object;
 
        if (bms_is_member(index, selected))
            column_perms |= SEPG_DB_COLUMN__SELECT;
@@ -290,12 +290,12 @@ sepgsql_dml_privileges(List *rangeTabls, bool abort)
 {
    ListCell   *lr;
 
-   foreach (lr, rangeTabls)
+   foreach(lr, rangeTabls)
    {
-       RangeTblEntry  *rte = lfirst(lr);
-       uint32          required = 0;
-       List           *tableIds;
-       ListCell       *li;
+       RangeTblEntry *rte = lfirst(lr);
+       uint32      required = 0;
+       List       *tableIds;
+       ListCell   *li;
 
        /*
         * Only regular relations shall be checked
@@ -328,25 +328,24 @@ sepgsql_dml_privileges(List *rangeTabls, bool abort)
 
        /*
         * If this RangeTblEntry is also supposed to reference inherited
-        * tables, we need to check security label of the child tables.
-        * So, we expand rte->relid into list of OIDs of inheritance
-        * hierarchy, then checker routine will be invoked for each
-        * relations.
+        * tables, we need to check security label of the child tables. So, we
+        * expand rte->relid into list of OIDs of inheritance hierarchy, then
+        * checker routine will be invoked for each relations.
         */
        if (!rte->inh)
            tableIds = list_make1_oid(rte->relid);
        else
            tableIds = find_all_inheritors(rte->relid, NoLock, NULL);
 
-       foreach (li, tableIds)
+       foreach(li, tableIds)
        {
            Oid         tableOid = lfirst_oid(li);
            Bitmapset  *selectedCols;
            Bitmapset  *modifiedCols;
 
            /*
-            * child table has different attribute numbers, so we need
-            * to fix up them.
+            * child table has different attribute numbers, so we need to fix
+            * up them.
             */
            selectedCols = fixup_inherited_columns(rte->relid, tableOid,
                                                   rte->selectedCols);
index 5dc8a3ecaa8b704a158409d6be46d8cd755253c5..7797ccb199f088ed101b0c77b41d0b9f98a63d2d 100644 (file)
@@ -29,17 +29,17 @@ PG_MODULE_MAGIC;
 /*
  * Declarations
  */
-void _PG_init(void);
+void       _PG_init(void);
 
 /*
  * Saved hook entries (if stacked)
  */
-static object_access_hook_type         next_object_access_hook = NULL;
-static ClientAuthentication_hook_type  next_client_auth_hook = NULL;
-static ExecutorCheckPerms_hook_type        next_exec_check_perms_hook = NULL;
-static needs_fmgr_hook_type                next_needs_fmgr_hook = NULL;
-static fmgr_hook_type                  next_fmgr_hook = NULL;
-static ProcessUtility_hook_type            next_ProcessUtility_hook = NULL;
+static object_access_hook_type next_object_access_hook = NULL;
+static ClientAuthentication_hook_type next_client_auth_hook = NULL;
+static ExecutorCheckPerms_hook_type next_exec_check_perms_hook = NULL;
+static needs_fmgr_hook_type next_needs_fmgr_hook = NULL;
+static fmgr_hook_type next_fmgr_hook = NULL;
+static ProcessUtility_hook_type next_ProcessUtility_hook = NULL;
 
 /*
  * GUC: sepgsql.permissive = (on|off)
@@ -73,14 +73,14 @@ sepgsql_get_debug_audit(void)
 static void
 sepgsql_client_auth(Port *port, int status)
 {
-   char   *context;
+   char       *context;
 
    if (next_client_auth_hook)
-       (*next_client_auth_hook)(port, status);
+       (*next_client_auth_hook) (port, status);
 
    /*
-    * In the case when authentication failed, the supplied socket
-    * shall be closed soon, so we don't need to do anything here.
+    * In the case when authentication failed, the supplied socket shall be
+    * closed soon, so we don't need to do anything here.
     */
    if (status != STATUS_OK)
        return;
@@ -96,8 +96,8 @@ sepgsql_client_auth(Port *port, int status)
    sepgsql_set_client_label(context);
 
    /*
-    * Switch the current performing mode from INTERNAL to either
-    * DEFAULT or PERMISSIVE.
+    * Switch the current performing mode from INTERNAL to either DEFAULT or
+    * PERMISSIVE.
     */
    if (sepgsql_permissive)
        sepgsql_set_mode(SEPGSQL_MODE_PERMISSIVE);
@@ -113,12 +113,12 @@ sepgsql_client_auth(Port *port, int status)
  */
 static void
 sepgsql_object_access(ObjectAccessType access,
-                      Oid classId,
-                      Oid objectId,
-                      int subId)
+                     Oid classId,
+                     Oid objectId,
+                     int subId)
 {
    if (next_object_access_hook)
-       (*next_object_access_hook)(access, classId, objectId, subId);
+       (*next_object_access_hook) (access, classId, objectId, subId);
 
    switch (access)
    {
@@ -147,7 +147,7 @@ sepgsql_object_access(ObjectAccessType access,
            break;
 
        default:
-           elog(ERROR, "unexpected object access type: %d", (int)access);
+           elog(ERROR, "unexpected object access type: %d", (int) access);
            break;
    }
 }
@@ -161,11 +161,11 @@ static bool
 sepgsql_exec_check_perms(List *rangeTabls, bool abort)
 {
    /*
-    * If security provider is stacking and one of them replied 'false'
-    * at least, we don't need to check any more.
+    * If security provider is stacking and one of them replied 'false' at
+    * least, we don't need to check any more.
     */
    if (next_exec_check_perms_hook &&
-       !(*next_exec_check_perms_hook)(rangeTabls, abort))
+       !(*next_exec_check_perms_hook) (rangeTabls, abort))
        return false;
 
    if (!sepgsql_dml_privileges(rangeTabls, abort))
@@ -184,20 +184,19 @@ sepgsql_exec_check_perms(List *rangeTabls, bool abort)
 static bool
 sepgsql_needs_fmgr_hook(Oid functionId)
 {
-   char   *old_label;
-   char   *new_label;
-   char   *function_label;
+   char       *old_label;
+   char       *new_label;
+   char       *function_label;
 
    if (next_needs_fmgr_hook &&
-       (*next_needs_fmgr_hook)(functionId))
+       (*next_needs_fmgr_hook) (functionId))
        return true;
 
    /*
-    * SELinux needs the function to be called via security_definer
-    * wrapper, if this invocation will take a domain-transition.
-    * We call these functions as trusted-procedure, if the security
-    * policy has a rule that switches security label of the client
-    * on execution.
+    * SELinux needs the function to be called via security_definer wrapper,
+    * if this invocation will take a domain-transition. We call these
+    * functions as trusted-procedure, if the security policy has a rule that
+    * switches security label of the client on execution.
     */
    old_label = sepgsql_get_client_label();
    new_label = sepgsql_proc_get_domtrans(functionId);
@@ -210,9 +209,9 @@ sepgsql_needs_fmgr_hook(Oid functionId)
 
    /*
     * Even if not a trusted-procedure, this function should not be inlined
-    * unless the client has db_procedure:{execute} permission.
-    * Please note that it shall be actually failed later because of same
-    * reason with ACL_EXECUTE.
+    * unless the client has db_procedure:{execute} permission. Please note
+    * that it shall be actually failed later because of same reason with
+    * ACL_EXECUTE.
     */
    function_label = sepgsql_get_label(ProcedureRelationId, functionId, 0);
    if (sepgsql_check_perms(sepgsql_get_client_label(),
@@ -238,20 +237,21 @@ static void
 sepgsql_fmgr_hook(FmgrHookEventType event,
                  FmgrInfo *flinfo, Datum *private)
 {
-   struct {
-       char   *old_label;
-       char   *new_label;
-       Datum   next_private;
-   } *stack;
+   struct
+   {
+       char       *old_label;
+       char       *new_label;
+       Datum       next_private;
+   }          *stack;
 
    switch (event)
    {
        case FHET_START:
-           stack = (void *)DatumGetPointer(*private);
+           stack = (void *) DatumGetPointer(*private);
            if (!stack)
            {
-               MemoryContext   oldcxt;
-               const char     *cur_label = sepgsql_get_client_label();
+               MemoryContext oldcxt;
+               const char *cur_label = sepgsql_get_client_label();
 
                oldcxt = MemoryContextSwitchTo(flinfo->fn_mcxt);
                stack = palloc(sizeof(*stack));
@@ -265,8 +265,8 @@ sepgsql_fmgr_hook(FmgrHookEventType event,
                {
                    /*
                     * process:transition permission between old and new
-                    * label, when user tries to switch security label of
-                    * the client on execution of trusted procedure.
+                    * label, when user tries to switch security label of the
+                    * client on execution of trusted procedure.
                     */
                    sepgsql_check_perms(cur_label, stack->new_label,
                                        SEPG_CLASS_PROCESS,
@@ -280,22 +280,22 @@ sepgsql_fmgr_hook(FmgrHookEventType event,
            stack->old_label = sepgsql_set_client_label(stack->new_label);
 
            if (next_fmgr_hook)
-               (*next_fmgr_hook)(event, flinfo, &stack->next_private);
+               (*next_fmgr_hook) (event, flinfo, &stack->next_private);
            break;
 
        case FHET_END:
        case FHET_ABORT:
-           stack = (void *)DatumGetPointer(*private);
+           stack = (void *) DatumGetPointer(*private);
 
            if (next_fmgr_hook)
-               (*next_fmgr_hook)(event, flinfo, &stack->next_private);
+               (*next_fmgr_hook) (event, flinfo, &stack->next_private);
 
            sepgsql_set_client_label(stack->old_label);
            stack->old_label = NULL;
            break;
 
        default:
-           elog(ERROR, "unexpected event type: %d", (int)event);
+           elog(ERROR, "unexpected event type: %d", (int) event);
            break;
    }
 }
@@ -315,8 +315,8 @@ sepgsql_utility_command(Node *parsetree,
                        char *completionTag)
 {
    if (next_ProcessUtility_hook)
-       (*next_ProcessUtility_hook)(parsetree, queryString, params,
-                                   isTopLevel, dest, completionTag);
+       (*next_ProcessUtility_hook) (parsetree, queryString, params,
+                                    isTopLevel, dest, completionTag);
 
    /*
     * Check command tag to avoid nefarious operations
@@ -324,6 +324,7 @@ sepgsql_utility_command(Node *parsetree,
    switch (nodeTag(parsetree))
    {
        case T_LoadStmt:
+
            /*
             * We reject LOAD command across the board on enforcing mode,
             * because a binary module can arbitrarily override hooks.
@@ -336,11 +337,12 @@ sepgsql_utility_command(Node *parsetree,
            }
            break;
        default:
+
            /*
-            * Right now we don't check any other utility commands,
-            * because it needs more detailed information to make
-            * access control decision here, but we don't want to
-            * have two parse and analyze routines individually.
+            * Right now we don't check any other utility commands, because it
+            * needs more detailed information to make access control decision
+            * here, but we don't want to have two parse and analyze routines
+            * individually.
             */
            break;
    }
@@ -358,7 +360,7 @@ sepgsql_utility_command(Node *parsetree,
 void
 _PG_init(void)
 {
-   char   *context;
+   char       *context;
 
    /*
     * We allow to load the SE-PostgreSQL module on single-user-mode or
@@ -367,12 +369,12 @@ _PG_init(void)
    if (IsUnderPostmaster)
        ereport(ERROR,
                (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-                errmsg("sepgsql must be loaded via shared_preload_libraries")));
+            errmsg("sepgsql must be loaded via shared_preload_libraries")));
 
    /*
-    * Check availability of SELinux on the platform.
-    * If disabled, we cannot activate any SE-PostgreSQL features,
-    * and we have to skip rest of initialization.
+    * Check availability of SELinux on the platform. If disabled, we cannot
+    * activate any SE-PostgreSQL features, and we have to skip rest of
+    * initialization.
     */
    if (is_selinux_enabled() < 1)
    {
@@ -383,8 +385,8 @@ _PG_init(void)
    /*
     * sepgsql.permissive = (on|off)
     *
-    * This variable controls performing mode of SE-PostgreSQL
-    * on user's session.
+    * This variable controls performing mode of SE-PostgreSQL on user's
+    * session.
     */
    DefineCustomBoolVariable("sepgsql.permissive",
                             "Turn on/off permissive mode in SE-PostgreSQL",
@@ -400,10 +402,9 @@ _PG_init(void)
    /*
     * sepgsql.debug_audit = (on|off)
     *
-    * This variable allows users to turn on/off audit logs on access
-    * control decisions, independent from auditallow/auditdeny setting
-    * in the security policy.
-    * We intend to use this option for debugging purpose.
+    * This variable allows users to turn on/off audit logs on access control
+    * decisions, independent from auditallow/auditdeny setting in the
+    * security policy. We intend to use this option for debugging purpose.
     */
    DefineCustomBoolVariable("sepgsql.debug_audit",
                             "Turn on/off debug audit messages",
@@ -419,13 +420,12 @@ _PG_init(void)
    /*
     * Set up dummy client label.
     *
-    * XXX - note that PostgreSQL launches background worker process
-    * like autovacuum without authentication steps. So, we initialize
-    * sepgsql_mode with SEPGSQL_MODE_INTERNAL, and client_label with
-    * the security context of server process.
-    * Later, it also launches background of user session. In this case,
-    * the process is always hooked on post-authentication, and we can
-    * initialize the sepgsql_mode and client_label correctly.
+    * XXX - note that PostgreSQL launches background worker process like
+    * autovacuum without authentication steps. So, we initialize sepgsql_mode
+    * with SEPGSQL_MODE_INTERNAL, and client_label with the security context
+    * of server process. Later, it also launches background of user session.
+    * In this case, the process is always hooked on post-authentication, and
+    * we can initialize the sepgsql_mode and client_label correctly.
     */
    if (getcon_raw(&context) < 0)
        ereport(ERROR,
index 828512a961aa7f00f94a0f32760b350f4d72e8fb..669ee35ac3e4a6d3515364e662568d865af1dbb2 100644 (file)
@@ -38,7 +38,7 @@
  *
  * security label of the client process
  */
-static char       *client_label = NULL;
+static char *client_label = NULL;
 
 char *
 sepgsql_get_client_label(void)
@@ -49,7 +49,7 @@ sepgsql_get_client_label(void)
 char *
 sepgsql_set_client_label(char *new_label)
 {
-   char   *old_label = client_label;
+   char       *old_label = client_label;
 
    client_label = new_label;
 
@@ -66,22 +66,22 @@ sepgsql_set_client_label(char *new_label)
 char *
 sepgsql_get_label(Oid classId, Oid objectId, int32 subId)
 {
-   ObjectAddress   object;
-   char           *label;
+   ObjectAddress object;
+   char       *label;
 
-   object.classId      = classId;
-   object.objectId     = objectId;
-   object.objectSubId  = subId;
+   object.classId = classId;
+   object.objectId = objectId;
+   object.objectSubId = subId;
 
    label = GetSecurityLabel(&object, SEPGSQL_LABEL_TAG);
-   if (!label || security_check_context_raw((security_context_t)label))
+   if (!label || security_check_context_raw((security_context_t) label))
    {
-       security_context_t  unlabeled;
+       security_context_t unlabeled;
 
        if (security_get_initial_context_raw("unlabeled", &unlabeled) < 0)
            ereport(ERROR,
                    (errcode(ERRCODE_INTERNAL_ERROR),
-                    errmsg("SELinux: failed to get initial security label: %m")));
+              errmsg("SELinux: failed to get initial security label: %m")));
        PG_TRY();
        {
            label = pstrdup(unlabeled);
@@ -107,21 +107,22 @@ void
 sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel)
 {
    /*
-    * validate format of the supplied security label,
-    * if it is security context of selinux.
+    * validate format of the supplied security label, if it is security
+    * context of selinux.
     */
    if (seclabel &&
        security_check_context_raw((security_context_t) seclabel) < 0)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_NAME),
-                errmsg("SELinux: invalid security label: \"%s\"", seclabel)));
+              errmsg("SELinux: invalid security label: \"%s\"", seclabel)));
+
    /*
     * Do actual permission checks for each object classes
     */
    switch (object->classId)
    {
        case NamespaceRelationId:
-           sepgsql_schema_relabel(object->objectId, seclabel);
+           sepgsql_schema_relabel(object->objectId, seclabel);
            break;
        case RelationRelationId:
            if (object->objectSubId == 0)
@@ -151,7 +152,7 @@ PG_FUNCTION_INFO_V1(sepgsql_getcon);
 Datum
 sepgsql_getcon(PG_FUNCTION_ARGS)
 {
-   char   *client_label;
+   char       *client_label;
 
    if (!sepgsql_is_enabled())
        PG_RETURN_NULL();
@@ -171,9 +172,9 @@ PG_FUNCTION_INFO_V1(sepgsql_mcstrans_in);
 Datum
 sepgsql_mcstrans_in(PG_FUNCTION_ARGS)
 {
-   text   *label = PG_GETARG_TEXT_P(0);
-   char   *raw_label;
-   char   *result;
+   text       *label = PG_GETARG_TEXT_P(0);
+   char       *raw_label;
+   char       *result;
 
    if (!sepgsql_is_enabled())
        ereport(ERROR,
@@ -211,9 +212,9 @@ PG_FUNCTION_INFO_V1(sepgsql_mcstrans_out);
 Datum
 sepgsql_mcstrans_out(PG_FUNCTION_ARGS)
 {
-   text   *label = PG_GETARG_TEXT_P(0);
-   char   *qual_label;
-   char   *result;
+   text       *label = PG_GETARG_TEXT_P(0);
+   char       *qual_label;
+   char       *result;
 
    if (!sepgsql_is_enabled())
        ereport(ERROR,
@@ -250,8 +251,8 @@ static char *
 quote_object_name(const char *src1, const char *src2,
                  const char *src3, const char *src4)
 {
-   StringInfoData  result;
-   const char     *temp;
+   StringInfoData result;
+   const char *temp;
 
    initStringInfo(&result);
 
@@ -260,28 +261,28 @@ quote_object_name(const char *src1, const char *src2,
        temp = quote_identifier(src1);
        appendStringInfo(&result, "%s", temp);
        if (src1 != temp)
-           pfree((void *)temp);
+           pfree((void *) temp);
    }
    if (src2)
    {
        temp = quote_identifier(src2);
        appendStringInfo(&result, ".%s", temp);
        if (src2 != temp)
-           pfree((void *)temp);
+           pfree((void *) temp);
    }
    if (src3)
    {
        temp = quote_identifier(src3);
        appendStringInfo(&result, ".%s", temp);
        if (src3 != temp)
-           pfree((void *)temp);
+           pfree((void *) temp);
    }
    if (src4)
    {
        temp = quote_identifier(src4);