Re: Odd DBI behavior

Re: Odd DBI behavior

am 21.10.2005 11:48:05 von Tim.Bunce

On Thu, Oct 20, 2005 at 04:57:24PM -0500, Ward.P.Fontenot@wellsfargo.com wrote:
> Script is below all this, and it is being performed on RHEL V3. The garbled
> field is a SHA1 blob computed from the
> FULLDATE,HOSTNAME,FACILITY,PRIORITY,MESSAGE fields.
>
> With the DBI commands commented out of this script I get what I'm expecting.
>
> INSERT INTO message(FULLDATE,HOSTNAME,FACILITY,PRIORITY,MESSAGE,SHA1)
> VALUES('2005-Oct-19 15:44:54','pkitest.wellsfargo.com','auth
> ','info','sshd(pam_unix)[8549]: session closed for user
> root','~MCà}M~DIB·~Nc^C4¼£¸^V¨~Wû');
>
> With the DBI commands not commented out I get the following:
>
> INSERT INTO message(FULLDATE,HOSTNAME,FACILITY,PRIORITY,MESSAGE,SHA1)
> VALUES('2005-Oct-19 15:44:54','pkitest.wellsfargo.com','auth
> ','info','sshd(pam_unix)[8549]: session closed for user
> root','~MCà}M~DIB·~Nc^C4¼£¸^V¨~Wû
> ');
>
> And "od -cx /spooldir/tmp/LOGFILE" shows a "\n" is inserted at the end of my
> SHA1 blob causing this insert statement to fail.

> $digest = "'" . sha1($_) . "'";
> @sql_data = split /[|]/, $_;
> @sql = ($sql_data[0],$sql_data[1],$sql_data[2],$sql_data[3],$sql_da ta[4],$digest);
>
> $sql_insert = "INSERT INTO
> message(FULLDATE,HOSTNAME,FACILITY,PRIORITY,MESSAGE,SHA1) VALUES(" . $sql[0]
> . "," . $sql[1] . "," . $sql[2] . "," . $sql[3] . "," . $sql[4] . "," .
> $sql[5] . ");";

This implies that sha1() is returning a string with a newline appended.
I can't see how the sha1 code could so that.

Please reduce the script down to the *absolute smallest*[1] script that
demonstrates the problem. In doing that you'll either uncover the
problem or make it much easier for someone else to do so.

Tim.

[1] Ideally ending up with just a few lines, no reading of external
files, no loop, no arrays, etc. etc.