All pastes #514930 Raw Edit

psql+sa typecast

public text v1 · immutable
#514930 ·published 2007-05-28 00:03 UTC
rendered paste body
function signature: 

kenneth@gilgamesh:~/Maildir/.spam-missed/cur$ grep -A6 put_token /usr/share/doc/spamassassin/sql/bayes_pg.sql

  CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER,
                                    intokenary BYTEA[],
                                    inspam_count INTEGER,
                                    inham_count INTEGER,
                                    inatime INTEGER)

original perl code to call the function: 

  998-  my $tokenarray = join(",", map { '"' . _quote_bytea($_) . '"' } sort keys %{$tokens});
  999-
  1000:  my $sth = $self->{_dbh}->prepare("select put_tokens($self->{_userid}, '{$tokenarray}',
  1001-                                                     $spam_count, $ham_count, $atime)");

results in: 

  2007-05-27 13:34:29 EDT ERROR:  function put_tokens(integer, "unknown", integer, integer, integer) does not exist
  2007-05-27 13:34:29 EDT HINT:  No function matches the given name and argument types. You may need to add explicit type casts.

modified perl code: 

 998   my $tokenarray = join(",", map { '"' . _quote_bytea($_) . '"' } sort keys %{$tokens});
 999
1000   my $sth = $self->{_dbh}->prepare("select put_tokens($self->{_userid},
1001           '{$tokenarray}'::bytea[], $spam_count, $ham_count, $atime)");

results in: 

2007-05-27 19:53:15 EDT ERROR:  function put_tokens(integer, bytea[], integer, integer, integer) does not exist
2007-05-27 19:53:15 EDT HINT:  No function matches the given name and argument types. You may need to add explicit type casts.

but I thought it now matches?!