Minor simplification: inline helper function
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 20 Apr 2015 10:01:09 +0000 (13:01 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 20 Apr 2015 10:34:14 +0000 (13:34 +0300)
src/backend/commands/sequence.c

index 1089e40d1d1a12d715939d44a5ed3816e85f88d6..bb05bb32732f1f1cbb04a6a7541c9e28c079b462 100644 (file)
@@ -104,7 +104,6 @@ static void process_owned_by(Relation seqrel, List *owned_by);
 static void log_sequence_tuple(Relation seqrel, HeapTuple tuple,
                                                           Buffer buf, Page page);
 static void seqrel_update_relam(Oid seqoid, Oid seqamid);
-static Oid get_new_seqam_oid(Oid oldAM, char *accessMethod);
 
 
 /*
@@ -244,7 +243,10 @@ DefineSequence(CreateSeqStmt *seq)
        stmt->if_not_exists = seq->if_not_exists;
 
        /* Let AM fill the values[] and nulls[] for the tuple as well. */
-       seqamid = get_new_seqam_oid(InvalidOid, seq->accessMethod);
+       if (seq->accessMethod)
+               seqamid = get_seqam_oid(seq->accessMethod, false);
+       else
+               seqamid = LOCAL_SEQAM_OID;
        seqam_init(seqamid, InvalidOid, seq->options, seq->amoptions,
                           value, null);
 
@@ -480,11 +482,13 @@ AlterSequence(AlterSeqStmt *stmt)
        heap_deform_tuple(tuple, tupDesc, values, nulls);
 
        oldamid = seqrel->rd_rel->relam;
-       seqamid = get_new_seqam_oid(seqrel->rd_rel->relam, stmt->accessMethod);
+       if (stmt->accessMethod)
+               seqamid = get_seqam_oid(stmt->accessMethod, false);
+       else
+               seqamid = oldamid;
 
        /*
-        * If we are changing sequence AM, we need to alter
-        * the sequence relation.
+        * If we are changing sequence AM, we need to alter the sequence relation.
         */
        if (seqamid != oldamid)
        {
@@ -1733,18 +1737,6 @@ ResetSequenceCaches(void)
        last_used_seq = NULL;
 }
 
-static Oid
-get_new_seqam_oid(Oid oldAM, char *accessMethod)
-{
-
-       if (oldAM && accessMethod == NULL)
-               return oldAM;
-       else if (accessMethod == NULL)
-               return LOCAL_SEQAM_OID;
-       else
-               return get_seqam_oid(accessMethod, false);
-}
-
 /*
  * Increment sequence while correctly handling overflows and min/max.
  */