Skip to content

Commit b1099ec

Browse files
committed
Remove AssertArg and AssertState
These don't offer anything over plain Assert, and their usage had already been declared obsolescent. Author: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/20221009210148.GA900071@nathanxps13
1 parent d37aa3d commit b1099ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+162
-174
lines changed

contrib/fuzzystrmatch/fuzzystrmatch.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ _soundex(const char *instr, char *outstr)
724724
{
725725
int count;
726726

727-
AssertArg(instr);
728-
AssertArg(outstr);
727+
Assert(instr);
728+
Assert(outstr);
729729

730730
outstr[SOUNDEX_LEN] = '\0';
731731

src/backend/access/common/tupdesc.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CreateTemplateTupleDesc(int natts)
4949
/*
5050
* sanity checks
5151
*/
52-
AssertArg(natts >= 0);
52+
Assert(natts >= 0);
5353

5454
/*
5555
* Allocate enough memory for the tuple descriptor, including the
@@ -273,12 +273,12 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
273273
/*
274274
* sanity checks
275275
*/
276-
AssertArg(PointerIsValid(src));
277-
AssertArg(PointerIsValid(dst));
278-
AssertArg(srcAttno >= 1);
279-
AssertArg(srcAttno <= src->natts);
280-
AssertArg(dstAttno >= 1);
281-
AssertArg(dstAttno <= dst->natts);
276+
Assert(PointerIsValid(src));
277+
Assert(PointerIsValid(dst));
278+
Assert(srcAttno >= 1);
279+
Assert(srcAttno <= src->natts);
280+
Assert(dstAttno >= 1);
281+
Assert(dstAttno <= dst->natts);
282282

283283
memcpy(dstAtt, srcAtt, ATTRIBUTE_FIXED_PART_SIZE);
284284

@@ -594,9 +594,9 @@ TupleDescInitEntry(TupleDesc desc,
594594
/*
595595
* sanity checks
596596
*/
597-
AssertArg(PointerIsValid(desc));
598-
AssertArg(attributeNumber >= 1);
599-
AssertArg(attributeNumber <= desc->natts);
597+
Assert(PointerIsValid(desc));
598+
Assert(attributeNumber >= 1);
599+
Assert(attributeNumber <= desc->natts);
600600

601601
/*
602602
* initialize the attribute fields
@@ -664,9 +664,9 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
664664
Form_pg_attribute att;
665665

666666
/* sanity checks */
667-
AssertArg(PointerIsValid(desc));
668-
AssertArg(attributeNumber >= 1);
669-
AssertArg(attributeNumber <= desc->natts);
667+
Assert(PointerIsValid(desc));
668+
Assert(attributeNumber >= 1);
669+
Assert(attributeNumber <= desc->natts);
670670

671671
/* initialize the attribute fields */
672672
att = TupleDescAttr(desc, attributeNumber - 1);
@@ -767,9 +767,9 @@ TupleDescInitEntryCollation(TupleDesc desc,
767767
/*
768768
* sanity checks
769769
*/
770-
AssertArg(PointerIsValid(desc));
771-
AssertArg(attributeNumber >= 1);
772-
AssertArg(attributeNumber <= desc->natts);
770+
Assert(PointerIsValid(desc));
771+
Assert(attributeNumber >= 1);
772+
Assert(attributeNumber <= desc->natts);
773773

774774
TupleDescAttr(desc, attributeNumber - 1)->attcollation = collationid;
775775
}

src/backend/access/heap/heapam.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2281,7 +2281,7 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
22812281
bool need_cids = RelationIsAccessibleInLogicalDecoding(relation);
22822282

22832283
/* currently not needed (thus unsupported) for heap_multi_insert() */
2284-
AssertArg(!(options & HEAP_INSERT_NO_LOGICAL));
2284+
Assert(!(options & HEAP_INSERT_NO_LOGICAL));
22852285

22862286
needwal = RelationNeedsWAL(relation);
22872287
saveFreeSpace = RelationGetTargetPageFreeSpace(relation,

src/backend/access/nbtree/nbtsort.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ _bt_load(BTWriteState *wstate, BTSpool *btspool, BTSpool *btspool2)
12261226
/* Abbreviation is not supported here */
12271227
sortKey->abbreviate = false;
12281228

1229-
AssertState(sortKey->ssup_attno != 0);
1229+
Assert(sortKey->ssup_attno != 0);
12301230

12311231
strategy = (scanKey->sk_flags & SK_BT_DESC) != 0 ?
12321232
BTGreaterStrategyNumber : BTLessStrategyNumber;

src/backend/access/transam/multixact.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ MultiXactIdCreate(TransactionId xid1, MultiXactStatus status1,
389389
MultiXactId newMulti;
390390
MultiXactMember members[2];
391391

392-
AssertArg(TransactionIdIsValid(xid1));
393-
AssertArg(TransactionIdIsValid(xid2));
392+
Assert(TransactionIdIsValid(xid1));
393+
Assert(TransactionIdIsValid(xid2));
394394

395395
Assert(!TransactionIdEquals(xid1, xid2) || (status1 != status2));
396396

@@ -445,8 +445,8 @@ MultiXactIdExpand(MultiXactId multi, TransactionId xid, MultiXactStatus status)
445445
int i;
446446
int j;
447447

448-
AssertArg(MultiXactIdIsValid(multi));
449-
AssertArg(TransactionIdIsValid(xid));
448+
Assert(MultiXactIdIsValid(multi));
449+
Assert(TransactionIdIsValid(xid));
450450

451451
/* MultiXactIdSetOldestMember() must have been called already. */
452452
Assert(MultiXactIdIsValid(OldestMemberMXactId[MyBackendId]));

src/backend/access/transam/xact.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3250,7 +3250,7 @@ CommitTransactionCommand(void)
32503250
s->savepointLevel = savepointLevel;
32513251

32523252
/* This is the same as TBLOCK_SUBBEGIN case */
3253-
AssertState(s->blockState == TBLOCK_SUBBEGIN);
3253+
Assert(s->blockState == TBLOCK_SUBBEGIN);
32543254
StartSubTransaction();
32553255
s->blockState = TBLOCK_SUBINPROGRESS;
32563256
}
@@ -3278,7 +3278,7 @@ CommitTransactionCommand(void)
32783278
s->savepointLevel = savepointLevel;
32793279

32803280
/* This is the same as TBLOCK_SUBBEGIN case */
3281-
AssertState(s->blockState == TBLOCK_SUBBEGIN);
3281+
Assert(s->blockState == TBLOCK_SUBBEGIN);
32823282
StartSubTransaction();
32833283
s->blockState = TBLOCK_SUBINPROGRESS;
32843284
}
@@ -4667,7 +4667,7 @@ RollbackAndReleaseCurrentSubTransaction(void)
46674667
CleanupSubTransaction();
46684668

46694669
s = CurrentTransactionState; /* changed by pop */
4670-
AssertState(s->blockState == TBLOCK_SUBINPROGRESS ||
4670+
Assert(s->blockState == TBLOCK_SUBINPROGRESS ||
46714671
s->blockState == TBLOCK_INPROGRESS ||
46724672
s->blockState == TBLOCK_IMPLICIT_INPROGRESS ||
46734673
s->blockState == TBLOCK_STARTED);

src/backend/bootstrap/bootstrap.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ InsertOneValue(char *value, int i)
648648
Oid typinput;
649649
Oid typoutput;
650650

651-
AssertArg(i >= 0 && i < MAXATTR);
651+
Assert(i >= 0 && i < MAXATTR);
652652

653653
elog(DEBUG4, "inserting column %d value \"%s\"", i, value);
654654

src/backend/catalog/namespace.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4093,7 +4093,7 @@ InitTempTableNamespace(void)
40934093
MyProc->tempNamespaceId = namespaceId;
40944094

40954095
/* It should not be done already. */
4096-
AssertState(myTempNamespaceSubID == InvalidSubTransactionId);
4096+
Assert(myTempNamespaceSubID == InvalidSubTransactionId);
40974097
myTempNamespaceSubID = GetCurrentSubTransactionId();
40984098

40994099
baseSearchPathValid = false; /* need to rebuild list */

src/backend/catalog/pg_collation.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ CollationCreate(const char *collname, Oid collnamespace,
6464
ObjectAddress myself,
6565
referenced;
6666

67-
AssertArg(collname);
68-
AssertArg(collnamespace);
69-
AssertArg(collowner);
70-
AssertArg((collcollate && collctype) || colliculocale);
67+
Assert(collname);
68+
Assert(collnamespace);
69+
Assert(collowner);
70+
Assert((collcollate && collctype) || colliculocale);
7171

7272
/*
7373
* Make sure there is no existing collation of same name & encoding.

src/backend/commands/dbcommands.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
26062606
bool result = false;
26072607
Relation relation;
26082608

2609-
AssertArg(name);
2609+
Assert(name);
26102610

26112611
/* Caller may wish to grab a better lock on pg_database beforehand... */
26122612
relation = table_open(DatabaseRelationId, AccessShareLock);

src/backend/commands/indexcmds.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2896,7 +2896,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
28962896
* This matches the options enforced by the grammar, where the object name
28972897
* is optional for DATABASE and SYSTEM.
28982898
*/
2899-
AssertArg(objectName || objectKind != REINDEX_OBJECT_SCHEMA);
2899+
Assert(objectName || objectKind != REINDEX_OBJECT_SCHEMA);
29002900

29012901
if (objectKind == REINDEX_OBJECT_SYSTEM &&
29022902
(params->options & REINDEXOPT_CONCURRENTLY) != 0)

src/backend/commands/portalcmds.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ PortalCleanup(Portal portal)
267267
/*
268268
* sanity checks
269269
*/
270-
AssertArg(PortalIsValid(portal));
271-
AssertArg(portal->cleanup == PortalCleanup);
270+
Assert(PortalIsValid(portal));
271+
Assert(portal->cleanup == PortalCleanup);
272272

273273
/*
274274
* Shut down executor, if still running. We skip this during error abort,

src/backend/commands/tablecmds.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3134,7 +3134,7 @@ StoreCatalogInheritance(Oid relationId, List *supers,
31343134
/*
31353135
* sanity checks
31363136
*/
3137-
AssertArg(OidIsValid(relationId));
3137+
Assert(OidIsValid(relationId));
31383138

31393139
if (supers == NIL)
31403140
return;
@@ -3651,7 +3651,7 @@ rename_constraint_internal(Oid myrelid,
36513651
Form_pg_constraint con;
36523652
ObjectAddress address;
36533653

3654-
AssertArg(!myrelid || !mytypid);
3654+
Assert(!myrelid || !mytypid);
36553655

36563656
if (mytypid)
36573657
{
@@ -9731,7 +9731,7 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel,
97319731
Oid insertTriggerOid,
97329732
updateTriggerOid;
97339733

9734-
AssertArg(OidIsValid(parentConstr));
9734+
Assert(OidIsValid(parentConstr));
97359735

97369736
if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
97379737
ereport(ERROR,

src/backend/jit/jit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ file_exists(const char *name)
195195
{
196196
struct stat st;
197197

198-
AssertArg(name != NULL);
198+
Assert(name != NULL);
199199

200200
if (stat(name, &st) == 0)
201201
return !S_ISDIR(st.st_mode);

src/backend/parser/parse_utilcmd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
14631463
int i;
14641464
Oid ofTypeId;
14651465

1466-
AssertArg(ofTypename);
1466+
Assert(ofTypename);
14671467

14681468
tuple = typenameType(NULL, ofTypename, NULL);
14691469
check_of_type(tuple);

src/backend/postmaster/autovacuum.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3001,8 +3001,8 @@ relation_needs_vacanalyze(Oid relid,
30013001
TransactionId xidForceLimit;
30023002
MultiXactId multiForceLimit;
30033003

3004-
AssertArg(classForm != NULL);
3005-
AssertArg(OidIsValid(relid));
3004+
Assert(classForm != NULL);
3005+
Assert(OidIsValid(relid));
30063006

30073007
/*
30083008
* Determine vacuum/analyze equation parameters. We have two possible

src/backend/replication/logical/reorderbuffer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3084,7 +3084,7 @@ ReorderBufferSetBaseSnapshot(ReorderBuffer *rb, TransactionId xid,
30843084
ReorderBufferTXN *txn;
30853085
bool is_new;
30863086

3087-
AssertArg(snap != NULL);
3087+
Assert(snap != NULL);
30883088

30893089
/*
30903090
* Fetch the transaction to operate on. If we know it's a subtransaction,

src/backend/replication/slot.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ ReplicationSlotAcquire(const char *name, bool nowait)
452452
ReplicationSlot *s;
453453
int active_pid;
454454

455-
AssertArg(name != NULL);
455+
Assert(name != NULL);
456456

457457
retry:
458458
Assert(MyReplicationSlot == NULL);

src/backend/storage/lmgr/lwlock.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ LWLockAttemptLock(LWLock *lock, LWLockMode mode)
816816
{
817817
uint32 old_state;
818818

819-
AssertArg(mode == LW_EXCLUSIVE || mode == LW_SHARED);
819+
Assert(mode == LW_EXCLUSIVE || mode == LW_SHARED);
820820

821821
/*
822822
* Read once outside the loop, later iterations will get the newer value
@@ -1204,7 +1204,7 @@ LWLockAcquire(LWLock *lock, LWLockMode mode)
12041204
lwstats = get_lwlock_stats_entry(lock);
12051205
#endif
12061206

1207-
AssertArg(mode == LW_SHARED || mode == LW_EXCLUSIVE);
1207+
Assert(mode == LW_SHARED || mode == LW_EXCLUSIVE);
12081208

12091209
PRINT_LWDEBUG("LWLockAcquire", lock, mode);
12101210

@@ -1368,7 +1368,7 @@ LWLockConditionalAcquire(LWLock *lock, LWLockMode mode)
13681368
{
13691369
bool mustwait;
13701370

1371-
AssertArg(mode == LW_SHARED || mode == LW_EXCLUSIVE);
1371+
Assert(mode == LW_SHARED || mode == LW_EXCLUSIVE);
13721372

13731373
PRINT_LWDEBUG("LWLockConditionalAcquire", lock, mode);
13741374

src/backend/tcop/postgres.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4050,8 +4050,8 @@ PostgresMain(const char *dbname, const char *username)
40504050
bool idle_in_transaction_timeout_enabled = false;
40514051
bool idle_session_timeout_enabled = false;
40524052

4053-
AssertArg(dbname != NULL);
4054-
AssertArg(username != NULL);
4053+
Assert(dbname != NULL);
4054+
Assert(username != NULL);
40554055

40564056
SetProcessingMode(InitProcessing);
40574057

src/backend/tcop/pquery.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ PortalStart(Portal portal, ParamListInfo params,
440440
QueryDesc *queryDesc;
441441
int myeflags;
442442

443-
AssertArg(PortalIsValid(portal));
444-
AssertState(portal->status == PORTAL_DEFINED);
443+
Assert(PortalIsValid(portal));
444+
Assert(portal->status == PORTAL_DEFINED);
445445

446446
/*
447447
* Set up global portal context pointers.
@@ -694,7 +694,7 @@ PortalRun(Portal portal, long count, bool isTopLevel, bool run_once,
694694
MemoryContext savePortalContext;
695695
MemoryContext saveMemoryContext;
696696

697-
AssertArg(PortalIsValid(portal));
697+
Assert(PortalIsValid(portal));
698698

699699
TRACE_POSTGRESQL_QUERY_EXECUTE_START();
700700

@@ -1399,7 +1399,7 @@ PortalRunFetch(Portal portal,
13991399
MemoryContext savePortalContext;
14001400
MemoryContext oldContext;
14011401

1402-
AssertArg(PortalIsValid(portal));
1402+
Assert(PortalIsValid(portal));
14031403

14041404
/*
14051405
* Check for improper portal use, and mark portal active.

src/backend/utils/activity/pgstat.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, Oid objoid)
785785

786786
/* should be called from backends */
787787
Assert(IsUnderPostmaster || !IsPostmasterEnvironment);
788-
AssertArg(!kind_info->fixed_amount);
788+
Assert(!kind_info->fixed_amount);
789789

790790
pgstat_prep_snapshot();
791791

@@ -901,8 +901,8 @@ pgstat_have_entry(PgStat_Kind kind, Oid dboid, Oid objoid)
901901
void
902902
pgstat_snapshot_fixed(PgStat_Kind kind)
903903
{
904-
AssertArg(pgstat_is_kind_valid(kind));
905-
AssertArg(pgstat_get_kind_info(kind)->fixed_amount);
904+
Assert(pgstat_is_kind_valid(kind));
905+
Assert(pgstat_get_kind_info(kind)->fixed_amount);
906906

907907
if (pgstat_fetch_consistency == PGSTAT_FETCH_CONSISTENCY_SNAPSHOT)
908908
pgstat_build_snapshot();
@@ -1219,7 +1219,7 @@ pgstat_is_kind_valid(int ikind)
12191219
const PgStat_KindInfo *
12201220
pgstat_get_kind_info(PgStat_Kind kind)
12211221
{
1222-
AssertArg(pgstat_is_kind_valid(kind));
1222+
Assert(pgstat_is_kind_valid(kind));
12231223

12241224
return &pgstat_kind_infos[kind];
12251225
}

src/backend/utils/activity/pgstat_replslot.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pgstat_reset_replslot(const char *name)
4444
{
4545
ReplicationSlot *slot;
4646

47-
AssertArg(name != NULL);
47+
Assert(name != NULL);
4848

4949
/* Check if the slot exits with the given name. */
5050
slot = SearchNamedReplicationSlot(name, true);
@@ -213,7 +213,7 @@ get_replslot_index(const char *name)
213213
{
214214
ReplicationSlot *slot;
215215

216-
AssertArg(name != NULL);
216+
Assert(name != NULL);
217217

218218
slot = SearchNamedReplicationSlot(name, true);
219219

0 commit comments

Comments
 (0)