Apologies if this has been ccovered elsewhere, or if dspam-dev
is the wrong place -- please point me at the right one.

Here are some patches to release 3.6.8 for running under postgresql 8.2.1 (and probably lots of other
8-releases as well).

There's a small fix to accommodate the new "escaped string" extension, a small fix to prevent a seg fault, a syntactic fix -- apparently postgresql 8 doesn't allow nested "/*"'s and finally a change to avoid doing "alter table" commands on tables that aren't actually created.

Hope this helps.

Oh yes:

The author or authors of this submission hereby release any and all
copyright interest in this code, documentation, or other materials
included to the DSPAM project and its primary governors. We intend this
relinquishment of copyright interest in perpetuity of all present and
future rights to said submission under copyright law.

Nat Howard
WiTopia (which kindly allowed me to submit the patches).

[EMAIL PROTECTED]






Index: pgsql_drv.c
===================================================================
RCS file: /disk/d/repository/dspam/src/pgsql_drv.c,v
retrieving revision 1.1.1.1
retrieving revision 1.4
diff -c -r1.1.1.1 -r1.4
*** pgsql_drv.c 29 Jan 2007 21:46:32 -0000      1.1.1.1
--- pgsql_drv.c 31 Jan 2007 15:15:44 -0000      1.4
***************
*** 1,4 ****
! /* $Id: pgsql_drv.c,v 1.1.1.1 2007/01/29 21:46:32 nrh Exp $ */

  /*
   DSPAM
--- 1,4 ----
! /* $Id: pgsql_drv.c,v 1.4 2007/01/31 15:15:44 nrh Exp $ */

  /*
   DSPAM
***************
*** 1006,1011 ****
--- 1006,1016 ----
    else
      s->pg_major_ver = _pgsql_drv_get_dbversion(s);
    s->pg_token_type = _pgsql_drv_token_type(s,NULL,0);
+   if(s->pg_major_ver >= 8)
+       s->escape_string_prefix = 'E';
+   else
+       s->escape_string_prefix = ' ';
+

    /* get spam totals on successful init */
    if (CTX->username != NULL)
***************
*** 1241,1248 ****
    mem = PQescapeBytea(SIG->data, SIG->length, &length);

    snprintf (scratch, sizeof (scratch),
! "INSERT INTO dspam_signature_data (uid, signature, length, created_on, data) VALUES (%d, '%s', %ld, CURRENT_DATE, '",
!             p->pw_uid, signature, SIG->length);
    buffer_cat (query, scratch);
    buffer_cat (query, (const char *) mem);
    buffer_cat (query, "')");
--- 1246,1253 ----
    mem = PQescapeBytea(SIG->data, SIG->length, &length);

    snprintf (scratch, sizeof (scratch),
! "INSERT INTO dspam_signature_data (uid, signature, length, created_on, data) VALUES (%d, '%s', %ld, CURRENT_DATE, %c'", ! p->pw_uid, signature, SIG->length, s- >escape_string_prefix);
    buffer_cat (query, scratch);
    buffer_cat (query, (const char *) mem);
    buffer_cat (query, "')");
***************
*** 2173,2179 ****
      if (p == NULL)
      {
        LOGDEBUG ("_ds_pref_load: unable to _pgsql_drv_getpwnam(%s)",
!               CTX->username);
        dspam_destroy(CTX);
        return NULL;
      } else {
--- 2178,2184 ----
      if (p == NULL)
      {
        LOGDEBUG ("_ds_pref_load: unable to _pgsql_drv_getpwnam(%s)",
!               username);
        dspam_destroy(CTX);
        return NULL;
      } else {
Index: pgsql_drv.h
===================================================================
RCS file: /disk/d/repository/dspam/src/pgsql_drv.h,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -c -r1.1.1.1 -r1.3
*** pgsql_drv.h 29 Jan 2007 21:46:32 -0000      1.1.1.1
--- pgsql_drv.h 30 Jan 2007 21:24:02 -0000      1.3
***************
*** 1,4 ****
! /* $Id: pgsql_drv.h,v 1.1.1.1 2007/01/29 21:46:32 nrh Exp $ */

  /*
   DSPAM
--- 1,4 ----
! /* $Id: pgsql_drv.h,v 1.3 2007/01/30 21:24:02 nrh Exp $ */

  /*
   DSPAM
***************
*** 54,59 ****
--- 54,60 ----
    struct passwd p_getpwuid;
    struct passwd p_getpwnam;
    int dbh_attached;
+ char escape_string_prefix; /* prefix backslashed-string with this char (avoid warnings in postgresql 8) */
  };

  /* Driver-specific functions */
Index: tools.pgsql_drv/pgsql_objects.sql
===================================================================
RCS file: /disk/d/repository/dspam/src/tools.pgsql_drv/ pgsql_objects.sql,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -c -r1.1.1.1 -r1.3
*** tools.pgsql_drv/pgsql_objects.sql 29 Jan 2007 21:46:32 -0000 1.1.1.1 --- tools.pgsql_drv/pgsql_objects.sql 30 Jan 2007 16:54:15 -0000 1.3
***************
*** 1,4 ****
! /* $Id: pgsql_objects.sql,v 1.1.1.1 2007/01/29 21:46:32 nrh Exp $ */

  CREATE TABLE dspam_token_data (
    uid smallint,
--- 1,4 ----
! /* $Id: pgsql_objects.sql,v 1.3 2007/01/30 16:54:15 nrh Exp $ */

  CREATE TABLE dspam_token_data (
    uid smallint,
***************
*** 56,69 ****
  end;';

  /* For much better performance
! /* see http://archives.postgresql.org/pgsql-performance/2004-11/ msg00416.php * and http://archives.postgresql.org/pgsql-performance/2004-11/ msg00417.php
   * for details
   */
  alter table "dspam_token_data" alter "token" set statistics 200;
  alter table dspam_signature_data alter signature set statistics 200;
- alter table dspam_neural_data alter node set statistics 200;
- alter table dspam_neural_decisions alter signature set statistics 200;
  alter table dspam_token_data alter innocent_hits set statistics 200;
  alter table dspam_token_data alter spam_hits set statistics 200;
CREATE INDEX id_token_data_sumhits ON dspam_token_data ((spam_hits + innocent_hits));
--- 56,67 ----
  end;';

  /* For much better performance
! * see http://archives.postgresql.org/pgsql-performance/2004-11/ msg00416.php * and http://archives.postgresql.org/pgsql-performance/2004-11/ msg00417.php
   * for details
   */
  alter table "dspam_token_data" alter "token" set statistics 200;
  alter table dspam_signature_data alter signature set statistics 200;
  alter table dspam_token_data alter innocent_hits set statistics 200;
  alter table dspam_token_data alter spam_hits set statistics 200;
CREATE INDEX id_token_data_sumhits ON dspam_token_data ((spam_hits + innocent_hits));

Reply via email to