I had to modify your patch sligthly to fit more recent code
changes --- updated version attached and applied.

---------------------------------------------------------------------------

Böjthe Zoltán wrote:
> Bruce Momjian ?rta:
> 
> >Patch applied.  Thanks.
> >
> >---------------------------------------------------------------------------
> >  
> >
> Hi!
> 
> on my timetravel.c I find a bug: after the
> ALTER TABLE mytable drop column last_column_of_table;
> 
> the timetravel trigger say on UPDATE/DELETE:
> 
> ERROR:  parser: parse error at end of input
> 
> 
> Here is the patch for this bug
> 
> B?jthe Zolt?n

> --- timetravel.c.prev 2003-06-27 19:56:40.000000000 +0200
> +++ timetravel.c      2003-09-02 14:53:21.000000000 +0200
> @@ -306,7 +306,7 @@
>               void    *pplan;
>               Oid     *ctypes;
>               char    sql[8192];
> -             int     j;
> +             char    separ=' ';
>  
>               /* allocate ctypes for preparation */
>               ctypes = (Oid *) palloc(natts * sizeof(Oid));
> @@ -319,11 +319,12 @@
>               {
>                       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) ? ", " : ")" );
> -//                       snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
> "$%d /* %d */ %s",
> -//                                   i, ctypes[i-1], (i < natts) ? ", " : ")" );
> +                     {
> +                         snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), 
> "%c$%d", separ,i);
> +                         separ = ',';
> +                     }
>               }
> +             snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ")");
>  
>  //           elog(NOTICE, "timetravel (%s) update: sql: %s", relname, sql);
>  

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: contrib/spi/timetravel.c
===================================================================
RCS file: /cvsroot/pgsql-server/contrib/spi/timetravel.c,v
retrieving revision 1.18
diff -c -c -r1.18 timetravel.c
*** contrib/spi/timetravel.c    4 Aug 2003 00:43:11 -0000       1.18
--- contrib/spi/timetravel.c    11 Sep 2003 17:20:08 -0000
***************
*** 309,314 ****
--- 309,315 ----
                void       *pplan;
                Oid                *ctypes;
                char            sql[8192];
+               char            separ=' ';
  
                /* allocate ctypes for preparation */
                ctypes = (Oid *) palloc(natts * sizeof(Oid));
***************
*** 321,333 ****
                {
                        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
                }
  
                elog(DEBUG4, "timetravel (%s) update: sql: %s", relname, sql);
  
--- 322,333 ----
                {
                        ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
                        if (!(tupdesc->attrs[i - 1]->attisdropped)) /* skip dropped 
columns */
!                       {
!                           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);
  
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to