Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 503e383

Browse files
committed
Remove useless assertions
We don't need Assert(IsA(foo, String)) right before running strVal(foo), since strVal() already does the assertion internally (via castNode()).
1 parent 7057bf2 commit 503e383

File tree

5 files changed

+0
-21
lines changed

5 files changed

+0
-21
lines changed

src/backend/commands/tablecmds.c

-2
Original file line numberDiff line numberDiff line change
@@ -8271,7 +8271,6 @@ ATExecSetStorage(Relation rel, const char *colName, Node *newValue, LOCKMODE loc
82718271
AttrNumber attnum;
82728272
ObjectAddress address;
82738273

8274-
Assert(IsA(newValue, String));
82758274
storagemode = strVal(newValue);
82768275

82778276
if (pg_strcasecmp(storagemode, "plain") == 0)
@@ -16171,7 +16170,6 @@ ATExecSetCompression(AlteredTableInfo *tab,
1617116170
char cmethod;
1617216171
ObjectAddress address;
1617316172

16174-
Assert(IsA(newValue, String));
1617516173
compression = strVal(newValue);
1617616174

1617716175
attrel = table_open(AttributeRelationId, RowExclusiveLock);

src/backend/commands/typecmds.c

-1
Original file line numberDiff line numberDiff line change
@@ -3577,7 +3577,6 @@ replace_domain_constraint_value(ParseState *pstate, ColumnRef *cref)
35773577
Node *field1 = (Node *) linitial(cref->fields);
35783578
char *colname;
35793579

3580-
Assert(IsA(field1, String));
35813580
colname = strVal(field1);
35823581
if (strcmp(colname, "value") == 0)
35833582
{

src/backend/executor/functions.c

-2
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,10 @@ sql_fn_post_column_ref(ParseState *pstate, ColumnRef *cref, Node *var)
318318
nnames--;
319319

320320
field1 = (Node *) linitial(cref->fields);
321-
Assert(IsA(field1, String));
322321
name1 = strVal(field1);
323322
if (nnames > 1)
324323
{
325324
subfield = (Node *) lsecond(cref->fields);
326-
Assert(IsA(subfield, String));
327325
name2 = strVal(subfield);
328326
}
329327

src/backend/parser/parse_expr.c

-10
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,6 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
631631
{
632632
Node *field1 = (Node *) linitial(cref->fields);
633633

634-
Assert(IsA(field1, String));
635634
colname = strVal(field1);
636635

637636
/* Try to identify as an unqualified column */
@@ -664,7 +663,6 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
664663
Node *field1 = (Node *) linitial(cref->fields);
665664
Node *field2 = (Node *) lsecond(cref->fields);
666665

667-
Assert(IsA(field1, String));
668666
relname = strVal(field1);
669667

670668
/* Locate the referenced nsitem */
@@ -685,7 +683,6 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
685683
break;
686684
}
687685

688-
Assert(IsA(field2, String));
689686
colname = strVal(field2);
690687

691688
/* Try to identify as a column of the nsitem */
@@ -712,9 +709,7 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
712709
Node *field2 = (Node *) lsecond(cref->fields);
713710
Node *field3 = (Node *) lthird(cref->fields);
714711

715-
Assert(IsA(field1, String));
716712
nspname = strVal(field1);
717-
Assert(IsA(field2, String));
718713
relname = strVal(field2);
719714

720715
/* Locate the referenced nsitem */
@@ -735,7 +730,6 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
735730
break;
736731
}
737732

738-
Assert(IsA(field3, String));
739733
colname = strVal(field3);
740734

741735
/* Try to identify as a column of the nsitem */
@@ -764,11 +758,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
764758
Node *field4 = (Node *) lfourth(cref->fields);
765759
char *catname;
766760

767-
Assert(IsA(field1, String));
768761
catname = strVal(field1);
769-
Assert(IsA(field2, String));
770762
nspname = strVal(field2);
771-
Assert(IsA(field3, String));
772763
relname = strVal(field3);
773764

774765
/*
@@ -798,7 +789,6 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
798789
break;
799790
}
800791

801-
Assert(IsA(field4, String));
802792
colname = strVal(field4);
803793

804794
/* Try to identify as a column of the nsitem */

src/pl/plpgsql/src/pl_comp.c

-6
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,6 @@ resolve_column_ref(ParseState *pstate, PLpgSQL_expr *expr,
12131213
{
12141214
Node *field1 = (Node *) linitial(cref->fields);
12151215

1216-
Assert(IsA(field1, String));
12171216
name1 = strVal(field1);
12181217
nnames_scalar = 1;
12191218
nnames_wholerow = 1;
@@ -1224,7 +1223,6 @@ resolve_column_ref(ParseState *pstate, PLpgSQL_expr *expr,
12241223
Node *field1 = (Node *) linitial(cref->fields);
12251224
Node *field2 = (Node *) lsecond(cref->fields);
12261225

1227-
Assert(IsA(field1, String));
12281226
name1 = strVal(field1);
12291227

12301228
/* Whole-row reference? */
@@ -1236,7 +1234,6 @@ resolve_column_ref(ParseState *pstate, PLpgSQL_expr *expr,
12361234
break;
12371235
}
12381236

1239-
Assert(IsA(field2, String));
12401237
name2 = strVal(field2);
12411238
colname = name2;
12421239
nnames_scalar = 2;
@@ -1250,9 +1247,7 @@ resolve_column_ref(ParseState *pstate, PLpgSQL_expr *expr,
12501247
Node *field2 = (Node *) lsecond(cref->fields);
12511248
Node *field3 = (Node *) lthird(cref->fields);
12521249

1253-
Assert(IsA(field1, String));
12541250
name1 = strVal(field1);
1255-
Assert(IsA(field2, String));
12561251
name2 = strVal(field2);
12571252

12581253
/* Whole-row reference? */
@@ -1264,7 +1259,6 @@ resolve_column_ref(ParseState *pstate, PLpgSQL_expr *expr,
12641259
break;
12651260
}
12661261

1267-
Assert(IsA(field3, String));
12681262
name3 = strVal(field3);
12691263
colname = name3;
12701264
nnames_field = 2;

0 commit comments

Comments
 (0)