Thread

  1. Text data type doesn't accept newlines?

    Randall Perry <rgp@systame.com> — 2001-06-05T14:22:02Z

    I have a logging database that logs errors. The error messages contain
    newlines. Pgsql doesn't accept them on insert in a text data field.
    
    MySQL has the 'blob' data type which does accept newlines.
    
    Do I have to convert all newlines to '\n' to use them in Pgsql?
    
    -- 
    Randy Perry
    sysTame
    Mac Consulting/Sales
    
    
    
    
    
    
  2. Re: Text data type doesn't accept newlines?

    Bryan White <bryan@arcamax.com> — 2001-06-05T16:00:33Z

    > I have a logging database that logs errors. The error messages contain
    > newlines. Pgsql doesn't accept them on insert in a text data field.
    
    I have never had a problem storing newlines in a text field.  What interface
    are you using?
    The only ascii character that I have found I have to escape is the single
    quote character.
    ---------
    Bryan White
    
    
    
  3. Re: Text data type doesn't accept newlines?

    Jan Wieck <janwieck@yahoo.com> — 2001-06-05T16:15:27Z

    Randall Perry wrote:
    > I have a logging database that logs errors. The error messages contain
    > newlines. Pgsql doesn't accept them on insert in a text data field.
    >
    > MySQL has the 'blob' data type which does accept newlines.
    >
    > Do I have to convert all newlines to '\n' to use them in Pgsql?
    
        I  don't  see  a reason why it shouldn't accept them, and the
        last time I stuffed html pages into via  libpgtcl  it  worked
        IIRC.
    
        What interface does your client use?
    
    
    Jan
    
    --
    
    #======================================================================#
    # It's easier to get forgiveness for being wrong than for being right. #
    # Let's break this rule - forgive me.                                  #
    #================================================== JanWieck@Yahoo.com #
    
    
    
    _________________________________________________________
    Do You Yahoo!?
    Get your free @yahoo.com address at http://mail.yahoo.com
    
    
    
  4. Re: Text data type doesn't accept newlines?

    Peter Eisentraut <peter_e@gmx.net> — 2001-06-05T17:02:52Z

    Randall Perry writes:
    
    > I have a logging database that logs errors. The error messages contain
    > newlines. Pgsql doesn't accept them on insert in a text data field.
    
    I don't think so.
    
    peter=# create table test1 (a text);
    CREATE
    peter=# insert into test1 values ('with
    peter'# newline');
    INSERT 145809 1
    peter=# select * from test1;
          a
    --------------
     with
    newline
    (1 row)
    
    Please make a more detailed report if you have a problem.
    
    -- 
    Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter
    
    
    
  5. Re: Text data type doesn't accept newlines?

    Randall Perry <rgp@systame.com> — 2001-06-05T18:13:40Z

    on 6/5/01 12:00 PM, Bryan White at bryan@arcamax.com wrote:
    
    >> I have a logging database that logs errors. The error messages contain
    >> newlines. Pgsql doesn't accept them on insert in a text data field.
    > 
    > I have never had a problem storing newlines in a text field.  What interface
    > are you using?
    > The only ascii character that I have found I have to escape is the single
    > quote character.
    > ---------
    > Bryan White
    > 
    > 
    > ---------------------------(end of broadcast)---------------------------
    > TIP 2: you can get off all lists at once with the unregister command
    > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
    > 
    
    I'm using the Pg perl interface. But, think my problem was that I had
    unescaped single quotes in the string. Added the following to my code to
    escape them and it works now:
    
        $self->{errors} =~ s"'"\\'"g;        # escape single quotes
    
    
    -- 
    Randy Perry
    sysTame
    Mac Consulting/Sales
    
    
    
    
    
    
  6. Re: Text data type doesn't accept newlines?

    Gordan Bobic <gordan@freeuk.com> — 2001-06-06T07:54:31Z

    Are you using the "quote" function? You have to use it if you are to
    guarantee that the data will be acceptable as "input".
    
    $myVar = $myDB -> quote ($myVar)
    
    
    > I'm using the Pg perl interface. But, think my problem was that I
    had
    > unescaped single quotes in the string. Added the following to my
    code to
    > escape them and it works now:
    >
    >     $self->{errors} =~ s"'"\\'"g;        # escape single quotes
    
    
    
    
    
  7. Re: Text data type doesn't accept newlines?

    Randall Perry <rgp@systame.com> — 2001-06-06T13:24:19Z

    Just checked the Pg docs, don't see a quote function. What is it part of?
    
    
    > Are you using the "quote" function? You have to use it if you are to
    > guarantee that the data will be acceptable as "input".
    > 
    > $myVar = $myDB -> quote ($myVar)
    > 
    > 
    >> I'm using the Pg perl interface. But, think my problem was that I
    > had
    >> unescaped single quotes in the string. Added the following to my
    > code to
    >> escape them and it works now:
    >> 
    >> $self->{errors} =~ s"'"\\'"g;        # escape single quotes
    > 
    > 
    > 
    > 
    > ---------------------------(end of broadcast)---------------------------
    > TIP 4: Don't 'kill -9' the postmaster
    > 
    
    -- 
    Randy Perry
    sysTame
    Mac Consulting/Sales
    
    phn                 561.589.6449
    mobile email        help@systame.com
    
    
    
    
    
  8. Re: Text data type doesn't accept newlines?

    Neil Conway <nconway@klamath.dyndns.org> — 2001-06-06T22:31:58Z

    On Wed, Jun 06, 2001 at 09:24:19AM -0400, Randall Perry wrote:
    > Just checked the Pg docs, don't see a quote function. What is it part of?
    
    It's part of DBI, a system for connecting Perl to databases. You can use
    DBI with Postgres -- but apparently you're not doing this, since you
    mentioned you're using Pg.pm (the plain interface to libpq). The
    Postgres driver for DBI is called DBD::Pg, BTW -- make sure you don't
    get them confused.
    
    So the advice below WRT using 'quote' doesn't apply.
    
    BTW, you might want to checkout DBI -- I find it to be more pleasant to
    use than Pg.pm
    
    Cheers,
    
    Neil
    
    > > Are you using the "quote" function? You have to use it if you are to
    > > guarantee that the data will be acceptable as "input".
    > > 
    > > $myVar = $myDB -> quote ($myVar)
    
    
    
  9. Re: Text data type doesn't accept newlines?

    Gordan Bobic <gordan@freeuk.com> — 2001-06-07T08:03:11Z

    Not sure, but the syntax is as I described below. Try checking the
    perl DBD::Pg documentation. I think that's where I read about it
    originally, many moons ago.
    
    > Just checked the Pg docs, don't see a quote function. What is it
    part of?
    >
    >
    > > Are you using the "quote" function? You have to use it if you are
    to
    > > guarantee that the data will be acceptable as "input".
    > >
    > > $myVar = $myDB -> quote ($myVar)
    > >
    > >
    > >> I'm using the Pg perl interface. But, think my problem was that I
    > > had
    > >> unescaped single quotes in the string. Added the following to my
    > > code to
    > >> escape them and it works now:
    > >>
    > >> $self->{errors} =~ s"'"\\'"g;        # escape single quotes
    > >
    > >
    > >
    > >
    > > ---------------------------(end of
    broadcast)---------------------------
    > > TIP 4: Don't 'kill -9' the postmaster
    > >
    >
    > --
    > Randy Perry
    > sysTame
    > Mac Consulting/Sales
    >
    > phn                 561.589.6449
    > mobile email        help@systame.com
    >
    >
    >
    >
    >
    
    
    
    
  10. Re: Text data type doesn't accept newlines?

    Keith G. Murphy <keithmur@mindspring.com> — 2001-06-13T14:39:47Z

    Gordan Bobic wrote:
    > 
    > Not sure, but the syntax is as I described below. Try checking the
    > perl DBD::Pg documentation. I think that's where I read about it
    > originally, many moons ago.
    > 
    > > Just checked the Pg docs, don't see a quote function. What is it
    > part of?
    > >
    For the sake of future generations, it's in 'man DBI', which makes
    sense, because it's useful for those other databases as well.  :-)