From f83bf385c1dad4964e0d899174989a1668536182 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 26 Apr 2018 14:45:04 -0400 Subject: [PATCH] Preliminary work for pgindent run. Update typedefs.list from current buildfarm results. Adjust pgindent's typedef blacklist to block some more unfortunate typedef names that have snuck in since last time. Manually tweak a few places where I didn't like the initial results of pgindent'ing. --- contrib/pg_trgm/trgm_op.c | 12 +-- src/backend/libpq/be-secure-common.c | 4 +- src/include/storage/reinit.h | 4 +- src/port/pg_crc32c_armv8.c | 9 ++- src/tools/pgindent/pgindent | 6 +- src/tools/pgindent/typedefs.list | 105 +++++++++++++++++++++++++-- 6 files changed, 118 insertions(+), 22 deletions(-) diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.c index b572d087d8..67cca9703f 100644 --- a/contrib/pg_trgm/trgm_op.c +++ b/contrib/pg_trgm/trgm_op.c @@ -48,14 +48,14 @@ typedef struct /* Trigram bound type */ typedef uint8 TrgmBound; -#define TRGM_BOUND_LEFT (0x01) /* trigram is left bound of word */ -#define TRGM_BOUND_RIGHT (0x02) /* trigram is right bound of word */ +#define TRGM_BOUND_LEFT 0x01 /* trigram is left bound of word */ +#define TRGM_BOUND_RIGHT 0x02 /* trigram is right bound of word */ /* Word similarity flags */ -#define WORD_SIMILARITY_CHECK_ONLY (0x01) /* if set then only check existence - * of similar search pattern in text */ -#define WORD_SIMILARITY_STRICT (0x02) /* force bounds of extent to match - * word bounds */ +#define WORD_SIMILARITY_CHECK_ONLY 0x01 /* only check existence of similar + * search pattern in text */ +#define WORD_SIMILARITY_STRICT 0x02 /* force bounds of extent to match + * word bounds */ /* * Module load callback diff --git a/src/backend/libpq/be-secure-common.c b/src/backend/libpq/be-secure-common.c index 46f0b5f4a3..2389e5668f 100644 --- a/src/backend/libpq/be-secure-common.c +++ b/src/backend/libpq/be-secure-common.c @@ -114,8 +114,8 @@ run_ssl_passphrase_command(const char *prompt, bool is_server_start, char *buf, /* strip trailing newline */ len = strlen(buf); - if (buf[len - 1] == '\n') - buf[len-- -1] = '\0'; + if (len > 0 && buf[len - 1] == '\n') + buf[--len] = '\0'; error: pfree(command.data); diff --git a/src/include/storage/reinit.h b/src/include/storage/reinit.h index 9a1c5bdc4e..22639dab4c 100644 --- a/src/include/storage/reinit.h +++ b/src/include/storage/reinit.h @@ -19,8 +19,8 @@ extern void ResetUnloggedRelations(int op); -extern bool parse_filename_for_nontemp_relation( - const char *name, int *oidchars, ForkNumber *fork); +extern bool parse_filename_for_nontemp_relation(const char *name, + int *oidchars, ForkNumber *fork); #define UNLOGGED_RELATION_CLEANUP 0x0001 #define UNLOGGED_RELATION_INIT 0x0002 diff --git a/src/port/pg_crc32c_armv8.c b/src/port/pg_crc32c_armv8.c index b35b0f758c..820b2c24b4 100644 --- a/src/port/pg_crc32c_armv8.c +++ b/src/port/pg_crc32c_armv8.c @@ -29,17 +29,20 @@ pg_comp_crc32c_armv8(pg_crc32c crc, const void *data, size_t len) * significantly faster. Process leading bytes so that the loop below * starts with a pointer aligned to eight bytes. */ - if (!PointerIsAligned(p, uint16) && p + 1 <= pend) + if (!PointerIsAligned(p, uint16) && + p + 1 <= pend) { crc = __crc32cb(crc, *p); p += 1; } - if (!PointerIsAligned(p, uint32) && p + 2 <= pend) + if (!PointerIsAligned(p, uint32) && + p + 2 <= pend) { crc = __crc32ch(crc, *(uint16 *) p); p += 2; } - if (!PointerIsAligned(p, uint64) && p + 4 <= pend) + if (!PointerIsAligned(p, uint64) && + p + 4 <= pend) { crc = __crc32cw(crc, *(uint32 *) p); p += 4; diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 2bbbd7b850..fadc3185ca 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -59,8 +59,10 @@ $excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns" # easier to configure. Note that the typedefs need trailing newlines. my @whitelist = ("bool\n"); -my %blacklist = map { +"$_\n" => 1 } qw( FD_SET date interval timestamp ANY - abs allocfunc iterator other pointer printfunc reference string type ); +my %blacklist = map { +"$_\n" => 1 } qw( + ANY FD_SET U abs allocfunc boolean date digit ilist interval iterator other + pointer printfunc reference string timestamp type wrap +); # globals my @files; diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index abc10a8ffd..54850ee4d6 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -1,5 +1,6 @@ ABITVEC ACCESS_ALLOWED_ACE +ACL ACL_SIZE_INFORMATION AFFIX ASN1_INTEGER @@ -20,7 +21,6 @@ Acl AclItem AclMaskHow AclMode -AclObjectKind AclResult AcquireSampleRowsFunc ActiveSnapshotElt @@ -58,6 +58,7 @@ AllocChunk AllocPointer AllocSet AllocSetContext +AllocSetFreeList AllocateDesc AllocateDescKind AlterCollationStmt @@ -137,6 +138,7 @@ AttoptCacheEntry AttoptCacheKey AttrDefInfo AttrDefault +AttrMissing AttrNumber AttributeOpts AuthRequest @@ -197,8 +199,10 @@ BackgroundWorker BackgroundWorkerArray BackgroundWorkerHandle BackgroundWorkerSlot +Barrier BaseBackupCmd BeginDirectModify_function +BeginForeignInsert_function BeginForeignModify_function BeginForeignScan_function BeginSampleScan_function @@ -295,6 +299,8 @@ CV C_block CachedPlan CachedPlanSource +CallContext +CallStmt CancelRequestPacket CaseExpr CaseTestExpr @@ -319,6 +325,7 @@ CkptTsStatus ClientAuthentication_hook_type ClientData ClonePtrType +ClonedConstraint ClosePortalStmt ClosePtrType Clump @@ -546,6 +553,7 @@ EndBlobPtrType EndBlobsPtrType EndDataPtrType EndDirectModify_function +EndForeignInsert_function EndForeignModify_function EndForeignScan_function EndSampleScan_function @@ -572,6 +580,7 @@ ExceptionLabelMap ExceptionMap ExclusiveBackupState ExecAuxRowMark +ExecEvalSubroutine ExecForeignDelete_function ExecForeignInsert_function ExecForeignUpdate_function @@ -593,6 +602,8 @@ ExecutorStart_hook_type ExpandedArrayHeader ExpandedObjectHeader ExpandedObjectMethods +ExpandedRecordFieldInfo +ExpandedRecordHeader ExplainDirectModify_function ExplainForeignModify_function ExplainForeignScan_function @@ -830,11 +841,13 @@ GatherMergeState GatherPath GatherState Gene +GeneratePruningStepsContext GenerationBlock GenerationChunk GenerationContext GenerationPointer GenericCosts +GenericIndexOpts GenericXLogState GeqoPrivateData GetForeignJoinPaths_function @@ -879,7 +892,6 @@ GistNSN GistSplitUnion GistSplitVector GlobalTransaction -GrantObjectType GrantRoleStmt GrantStmt GrantTargetType @@ -939,6 +951,7 @@ HashBuildState HashCompareFunc HashCopyFunc HashIndexStat +HashInstrumentation HashJoin HashJoinState HashJoinTable @@ -973,6 +986,7 @@ HistControl HotStandbyState I32 ICU_Convert_Func +ID INFIX INT128 INTERFACE_INFO @@ -995,6 +1009,7 @@ Index IndexAMProperty IndexAmRoutine IndexArrayKeyInfo +IndexAttachInfo IndexAttrBitmapKind IndexBuildCallback IndexBuildResult @@ -1025,6 +1040,7 @@ InferenceElem InfoItem InhInfo InheritableSocket +InheritanceKind InitSampleScan_function InitializeDSMForeignScan_function InitializeWorkerForeignScan_function @@ -1057,12 +1073,16 @@ IterateForeignScan_function IterateJsonStringValuesState JEntry JHashState -JitContext -JitProviderCallbacks JOBOBJECTINFOCLASS JOBOBJECT_BASIC_LIMIT_INFORMATION JOBOBJECT_BASIC_UI_RESTRICTIONS JOBOBJECT_SECURITY_LIMIT_INFORMATION +JitContext +JitProviderCallbacks +JitProviderCompileExprCB +JitProviderInit +JitProviderReleaseContextCB +JitProviderResetAfterErrorCB Join JoinCostWorkspace JoinExpr @@ -1103,9 +1123,22 @@ LDAPMessage LDAPURLDesc LDAP_TIMEVAL LINE +LLVMAttributeRef +LLVMBasicBlockRef LLVMBuilderRef +LLVMIntPredicate LLVMJitContext LLVMJitHandle +LLVMMemoryBufferRef +LLVMModuleRef +LLVMOrcJITStackRef +LLVMOrcModuleHandle +LLVMOrcTargetAddress +LLVMPassManagerBuilderRef +LLVMPassManagerRef +LLVMSharedModuleRef +LLVMTargetMachineRef +LLVMTargetRef LLVMTypeRef LLVMValueRef LOCALLOCK @@ -1118,6 +1151,7 @@ LOCKMETHODID LOCKMODE LOCKTAG LONG +LONG_PTR LOOP LPBYTE LPCTSTR @@ -1131,6 +1165,7 @@ LPTSTR LPVOID LPWSTR LSEG +LUID LVRelStats LWLock LWLockHandle @@ -1178,6 +1213,7 @@ LockRowsState LockStmt LockTagType LockTupleMode +LockViewRecurse_context LockWaitPolicy LockingClause LogOpts @@ -1189,6 +1225,7 @@ LogicalDecodeFilterByOriginCB LogicalDecodeMessageCB LogicalDecodeShutdownCB LogicalDecodeStartupCB +LogicalDecodeTruncateCB LogicalDecodingContext LogicalErrorCallbackState LogicalOutputPluginInit @@ -1228,6 +1265,7 @@ MemoryContextCallbackFunction MemoryContextCounters MemoryContextData MemoryContextMethods +MemoryStatsPrintFunc MergeAppend MergeAppendPath MergeAppendState @@ -1244,6 +1282,7 @@ MinMaxOp MinimalTuple MinimalTupleData MinmaxOpaque +MissingPtr ModifyTable ModifyTablePath ModifyTableState @@ -1335,6 +1374,7 @@ OnCommitItem OnConflictAction OnConflictClause OnConflictExpr +OnConflictSetState OpBtreeInterpretation OpClassCacheEnt OpExpr @@ -1434,6 +1474,7 @@ PLpgSQL_label_type PLpgSQL_nsitem PLpgSQL_nsitem_type PLpgSQL_plugin +PLpgSQL_promise_type PLpgSQL_raise_option PLpgSQL_raise_option_type PLpgSQL_rec @@ -1444,8 +1485,10 @@ PLpgSQL_stmt PLpgSQL_stmt_assert PLpgSQL_stmt_assign PLpgSQL_stmt_block +PLpgSQL_stmt_call PLpgSQL_stmt_case PLpgSQL_stmt_close +PLpgSQL_stmt_commit PLpgSQL_stmt_dynexecute PLpgSQL_stmt_dynfors PLpgSQL_stmt_execsql @@ -1465,6 +1508,8 @@ PLpgSQL_stmt_raise PLpgSQL_stmt_return PLpgSQL_stmt_return_next PLpgSQL_stmt_return_query +PLpgSQL_stmt_rollback +PLpgSQL_stmt_set PLpgSQL_stmt_type PLpgSQL_stmt_while PLpgSQL_trigtype @@ -1501,6 +1546,7 @@ PLySubtransactionObject PLyTransformToOb PLyTupleToOb PLyUnicode_FromStringAndSize_t +PLy_elog_impl_t PMINIDUMP_CALLBACK_INFORMATION PMINIDUMP_EXCEPTION_INFORMATION PMINIDUMP_USER_STREAM_INFORMATION @@ -1534,7 +1580,9 @@ PSQL_ECHO_HIDDEN PSQL_ERROR_ROLLBACK PTEntryArray PTIterationArray +PTOKEN_PRIVILEGES PTOKEN_USER +PULONG PUTENVPROC PVOID PX_Alias @@ -1550,6 +1598,7 @@ PageHeaderData PageXLogRecPtr PagetableEntry Pairs +ParallelAppendState ParallelBitmapHeapState ParallelCompletionPtr ParallelContext @@ -1559,12 +1608,14 @@ ParallelHashJoinBatch ParallelHashJoinBatchAccessor ParallelHashJoinState ParallelHeapScanDesc +ParallelHeapScanDescData ParallelIndexScanDesc ParallelSlot ParallelState ParallelWorkerContext ParallelWorkerInfo Param +ParamCompileHook ParamExecData ParamExternData ParamFetchHook @@ -1584,6 +1635,8 @@ ParsedText ParsedWord ParserSetupHook ParserState +PartClauseInfo +PartClauseMatchStatus PartitionBoundInfo PartitionBoundInfoData PartitionBoundSpec @@ -1596,13 +1649,20 @@ PartitionElem PartitionHashBound PartitionKey PartitionListValue +PartitionPruneCombineOp +PartitionPruneContext +PartitionPruneInfo +PartitionPruneState +PartitionPruneStep +PartitionPruneStepCombine +PartitionPruneStepOp +PartitionPruningData PartitionRangeBound PartitionRangeDatum PartitionRangeDatumKind PartitionScheme PartitionSpec PartitionTupleRouting -PartitionedChildRelInfo PartitionwiseAggregateType PasswordType Path @@ -1749,6 +1809,7 @@ ProjectionPath ProtocolVersion PrsStorage PruneState +PruneStepResult PsqlScanCallbacks PsqlScanQuoteType PsqlScanResult @@ -1881,6 +1942,7 @@ RenameStmt ReopenPtrType ReorderBuffer ReorderBufferApplyChangeCB +ReorderBufferApplyTruncateCB ReorderBufferBeginCB ReorderBufferChange ReorderBufferCommitCB @@ -1968,6 +2030,7 @@ SID_AND_ATTRIBUTES SID_IDENTIFIER_AUTHORITY SID_NAME_USE SISeg +SIZE_T SMgrRelation SMgrRelationData SOCKADDR @@ -2022,6 +2085,7 @@ SeqScanState SeqTable SeqTableData SerCommitSeqNo +SerializedReindexState SerializedSnapshotData Session SessionBackupState @@ -2045,6 +2109,7 @@ SharedDependencyObjectType SharedDependencyType SharedExecutorInstrumentation SharedFileSet +SharedHashInfo SharedInvalCatalogMsg SharedInvalCatcacheMsg SharedInvalRelcacheMsg @@ -2058,6 +2123,8 @@ SharedRecordTypmodRegistry SharedSortInfo SharedTuplestore SharedTuplestoreAccessor +SharedTuplestoreChunk +SharedTuplestoreParticipant SharedTypmodTableEntry Sharedsort ShellTypeInfo @@ -2105,7 +2172,6 @@ SortBy SortByDir SortByNulls SortCoordinate -SortCoordinateData SortGroupClause SortItem SortPath @@ -2197,6 +2263,7 @@ TBlockState TIDBitmap TOKEN_DEFAULT_DACL TOKEN_INFORMATION_CLASS +TOKEN_PRIVILEGES TOKEN_USER TParser TParserCharTest @@ -2305,6 +2372,7 @@ TransformJsonStringValuesState TransitionCaptureState TrgmArc TrgmArcInfo +TrgmBound TrgmColor TrgmColorInfo TrgmNFA @@ -2363,6 +2431,7 @@ TypeCat TypeFuncClass TypeInfo TypeName +U U32 U8 UChar @@ -2413,6 +2482,7 @@ VariableShowStmt VariableSpace VariableStatData VariableSubstituteHook +VersionedQuery Vfd ViewCheckOption ViewOptions @@ -2537,6 +2607,8 @@ XmlTableBuilderData YYLTYPE YYSTYPE YY_BUFFER_STATE +ZipfCache +ZipfCell _SPI_connection _SPI_plan __AssignProcessToJobObject @@ -2548,6 +2620,7 @@ __RegisterWaitForSingleObject __SetInformationJobObject _resultmap _stringlist +abs acquireLocksOnSubLinks_context adjust_appendrel_attrs_context allocfunc @@ -2591,7 +2664,7 @@ bits16 bits32 bits8 bloom_filter -bool +boolean brin_column_state bytea cached_re_str @@ -2637,6 +2710,7 @@ deparse_expr_cxt deparse_namespace destructor dev_t +digit directory_fctx disassembledLeaf dlist_head @@ -2650,6 +2724,7 @@ dsa_area_pool dsa_area_span dsa_handle dsa_pointer +dsa_pointer_atomic dsa_segment_header dsa_segment_index dsa_segment_map @@ -2762,6 +2837,7 @@ hstoreUniquePairs_t hstoreUpgrade_t hyperLogLogState ifState +ilist import_error_callback_arg indexed_tlist inet @@ -2787,6 +2863,7 @@ intptr_t intvKEY itemIdSort itemIdSortData +iterator jmp_buf join_search_hook_type json_aelem_action @@ -2800,6 +2877,7 @@ lclTocEntry leafSegmentInfo line_t lineno_t +list_qsort_comparator locale_t locate_agg_of_level_context locate_var_of_level_context @@ -2852,6 +2930,7 @@ oidvector on_dsm_detach_callback on_exit_nicely_callback ossl_EVP_cipher_func +other output_type pagetable_hash pagetable_iterator @@ -2931,6 +3010,7 @@ pltcl_proc_desc pltcl_proc_key pltcl_proc_ptr pltcl_query_desc +pointer pos_trgm post_parse_analyze_hook_type pqbool @@ -2943,6 +3023,7 @@ printTextFormat printTextLineFormat printTextLineWrap printTextRule +printfunc priv_map process_file_callback_t process_sublinks_context @@ -2973,6 +3054,7 @@ rb_combiner rb_comparator rb_freefunc reduce_outer_joins_state +reference regex_arc_t regex_t regexp @@ -3065,6 +3147,7 @@ stmtCacheEntry storeInfo storeRes_func stream_stop_callback +string substitute_actual_parameters_context substitute_actual_srf_parameters_context substitute_multiple_relids_context @@ -3091,11 +3174,14 @@ trgm_mb_char trivalue tsKEY ts_db_fctx +ts_parserstate +ts_tokenizer ts_tokentype tsearch_readline_state tuplehash_hash tuplehash_iterator txid +type tzEntry u1byte u4byte @@ -3109,6 +3195,7 @@ uint16_t uint32 uint32_t uint64 +uint64_t uint8 uint8_t uintptr_t @@ -3140,6 +3227,7 @@ walrcv_disconnect_fn walrcv_endstreaming_fn walrcv_exec_fn walrcv_get_conninfo_fn +walrcv_get_senderinfo_fn walrcv_identify_system_fn walrcv_readtimelinehistoryfile_fn walrcv_receive_fn @@ -3152,6 +3240,7 @@ win32_pthread wint_t worker_state worktable +wrap xl_brin_createidx xl_brin_desummarize xl_brin_insert @@ -3198,6 +3287,7 @@ xl_heap_lock_updated xl_heap_multi_insert xl_heap_new_cid xl_heap_rewrite_mapping +xl_heap_truncate xl_heap_update xl_heap_visible xl_invalid_page @@ -3228,6 +3318,7 @@ xl_xact_invals xl_xact_origin xl_xact_parsed_abort xl_xact_parsed_commit +xl_xact_parsed_prepare xl_xact_relfilenodes xl_xact_subxacts xl_xact_twophase