diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c
index 8ffa56edc75fb696edc120abf091c495b1abf9b8..29de8c6fda4cfd1bd3766d65e8ddc54fd46987cb 100644
--- a/contrib/spi/timetravel.c
+++ b/contrib/spi/timetravel.c
@@ -309,6 +309,7 @@ timetravel(PG_FUNCTION_ARGS)
 		void	   *pplan;
 		Oid		   *ctypes;
 		char		sql[8192];
+		char		separ=' ';
 
 		/* allocate ctypes for preparation */
 		ctypes = (Oid *) palloc(natts * sizeof(Oid));
@@ -321,13 +322,12 @@ timetravel(PG_FUNCTION_ARGS)
 		{
 			ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
 			if (!(tupdesc->attrs[i - 1]->attisdropped)) /* skip dropped columns */
-				snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "$%d%s",
-						 i, (i < natts) ? ", " : ")");
-#if 0
-			snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "$%d /* %d */ %s",
-					 i, ctypes[i - 1], (i < natts) ? ", " : ")");
-#endif
+			{
+			    snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%c$%d", separ,i);
+			    separ = ',';
+			}
 		}
+		snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ")");
 
 		elog(DEBUG4, "timetravel (%s) update: sql: %s", relname, sql);