Results 1 to 4 of 4

Thread: Column Comments

  1. #1
    Join Date
    Sep 2013
    Posts
    13

    Unanswered: Column Comments

    I have many column comments that are multi-line. I extract the comment and display it as a visual studio tool tip.
    Problem:
    If you dump and reload as plain text, the line feeds get lost. I cannot find any escape sequence that works for comments. E'text' is available for column data, but not column comments.

    Any comparisons that I do fail because of this.
    Any idea how to fix this?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    What do you mean with "dump and reload as plain text"?

    The script from pg_dump does preserve newlines:

    Code:
    psql (9.3.4)
    Type "help" for help.
    
    postgres=> create table x (id integer);
    ERROR:  relation "x" already exists
    postgres=> create table x (id integer);
    CREATE TABLE
    postgres=> comment on column x.id is 'comment
    postgres'> on
    postgres'> three lines';
    COMMENT
    postgres=> \q
    
    c:\>pg_dump -U username -t x dbname
    --
    -- PostgreSQL database dump
    --
    
    ....
    
    --
    -- Name: x; Type: TABLE; Schema: public; Owner: username; Tablespace:
    --
    
    CREATE TABLE x (
        id integer
    );
    
    
    ALTER TABLE public.x OWNER TO username;
    
    --
    -- Name: COLUMN x.id; Type: COMMENT; Schema: public; Owner: username
    --
    
    COMMENT ON COLUMN x.id IS 'comment
    on
    three lines';
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Sep 2013
    Posts
    13
    shammat,

    I have been testing this for the last couple of hours.
    It appears that the dump puts the data in a mixed format (UNIX and DOS).
    When reading the file into a pgAdmin query editor, it complained. It appears in the query editor as formatted, but does not load correctly.
    Next I loaded the file into Ultraedit and did a UNIX to DOS conversion.
    Once this was done, all comments but one worked! I am sure that I can correct the one.
    There must be a setting in Postgresql / pgAdmin how to format text files with the desired line terminator.

    Therefore, I think my problem is solved.

    Thanks,

  4. #4
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    Sorry, no idea. I don't use pgAdmin
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •