Comments in .sql files - Mailing list pgsql-general

From Chad N. Tindel
Subject Comments in .sql files
Date
Msg-id 20030724043606.GA31855@calma.pair.com
Whole thread Raw
Responses Re: Comments in .sql files  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

Still working on converting our schemas over to postgres from mysql, and trying
to get the hang of the differences between the two products.

I'm trying to figure out how to put comments in our .sql schema files.
For example:

a.sql
-----------------------
drop table A;
create table A (
    id SERIAL PRIMARY KEY,
    foo int default 5,
    bar int default 10
);

# This is a comment
insert into A (foo, bar) values (1, 1);
insert into A (foo, bar) values (2, 2);
-------------------------

Running "psql --username=user -d DB < a.sql" yields the following result:

DROP TABLE
NOTICE:  CREATE TABLE will create implicit sequence 'a_id_seq' for SERIAL column 'a.id'
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 'a_pkey' for table 'a'
CREATE TABLE
ERROR:  parser: parse error at or near "#" at character 1
INSERT 66820 1

------------------

And the DB only shows the second entry:

Portal=# select * from A;
 id | foo | bar
----+-----+-----
  1 |   2 |   2
(1 row)

----------------

So, my questions are:

1.  It obviously doesn't like the # notation for comments.  What is the proper
way to put comments in schema files?

2.  Why does postgres ignore the first insert?  Shouldn't it just barf on
the "#" line and keep going?

3.  Is there a way to turn of the notices about creating implicit sequences
and indices?

Thanks,

Chad

pgsql-general by date:

Previous
From: merlyn@stonehenge.com (Randal L. Schwartz)
Date:
Subject: "field upgrade" of OSCON 2003 T-shirt
Next
From: William Yu
Date:
Subject: Re: optimum postgres server configuration