Index: src/backend/parser/scan.l =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/parser/scan.l,v retrieving revision 1.103 diff -u -r1.103 scan.l --- src/backend/parser/scan.l 2002/11/11 03:33:38 1.103 +++ src/backend/parser/scan.l 2003/02/04 23:16:48 @@ -226,7 +226,7 @@ newline [\n\r] non_newline [^\n\r] -comment ("--"{non_newline}*) +comment (("--"|"//"){non_newline}*) whitespace ({space}+|{comment}) @@ -425,23 +425,29 @@ {operator} { /* - * Check for embedded slash-star or dash-dash; those - * are comment starts, so operator must stop there. - * Note that slash-star or dash-dash at the first - * character will match a prior rule, not this one. + * Check for embedded slash-star, dash-dash, or + * slash-slash; those are comment starts, so operator + * must stop there. Note that comment beginning at + * the first character will match a prior rule, not + * this one. */ int nchars = yyleng; char *slashstar = strstr(yytext, "/*"); char *dashdash = strstr(yytext, "--"); + char *slashslash = strstr(yytext, "//"); - if (slashstar && dashdash) + if (slashstar && (dashdash && slashslash)) { /* if both appear, take the first one */ if (slashstar > dashdash) slashstar = dashdash; + else if (slashstar > slashslash) + slashstar = slashslash; } - else if (!slashstar) + else if (!slashstar && dashdash) slashstar = dashdash; + else if (!slashstar && slashslash) + slashstar = slashslash; if (slashstar) nchars = slashstar - yytext; Index: doc/src/sgml/syntax.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/syntax.sgml,v retrieving revision 1.74 diff -u -r1.74 syntax.sgml --- doc/src/sgml/syntax.sgml 2002/11/15 03:11:17 1.74 +++ doc/src/sgml/syntax.sgml 2003/02/04 23:16:48 @@ -493,9 +493,9 @@ - -- and /* cannot appear - anywhere in an operator name, since they will be taken as the - start of a comment. + --, /*, and // + cannot appear anywhere in an operator name, since they will be taken as + the start of a comment. @@ -615,10 +615,13 @@ - A comment is an arbitrary sequence of characters beginning with - double dashes and extending to the end of the line, e.g.: + A comment is an arbitrary sequence of characters beginning with either + double dashes or forward slashes and extending to the end of the line, e.g.: -- This is a standard SQL92 comment + + +// This is a standard (??) SQL?? comment Index: src/test/regress/sql/comments.sql =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/test/regress/sql/comments.sql,v retrieving revision 1.3 diff -u -r1.3 comments.sql --- src/test/regress/sql/comments.sql 2000/07/14 15:43:57 1.3 +++ src/test/regress/sql/comments.sql 2003/02/04 23:16:49 @@ -3,14 +3,20 @@ -- SELECT 'trailing' AS first; -- trailing single line +SELECT 'trailing' AS first; // trailing single line SELECT /* embedded single line */ 'embedded' AS second; SELECT /* both embedded and trailing single line */ 'both' AS third; -- trailing single line +SELECT /* both embedded and trailing single line */ 'both' AS third; // trailing single line SELECT 'before multi-line' AS fourth; /* This is an example of SQL which should not execute: * select 'multi-line'; */ SELECT 'after multi-line' AS fifth; +SELECT 'before multi-line' -- trailing single line + AS sixth; +SELECT 'before multi-line' // trailing single line + AS seventh; -- -- Nested comments @@ -37,6 +43,6 @@ */ Now just one deep... */ -'deeply nested example' AS sixth; +'deeply nested example' AS eighth; /* and this is the end of the file */ Index: src/test/regress/expected/comments.out =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/test/regress/expected/comments.out,v retrieving revision 1.3 diff -u -r1.3 comments.out --- src/test/regress/expected/comments.out 2000/07/14 15:43:55 1.3 +++ src/test/regress/expected/comments.out 2003/02/04 23:16:49 @@ -7,6 +7,12 @@ trailing (1 row) +SELECT 'trailing' AS first; // trailing single line + first +---------- + trailing +(1 row) + SELECT /* embedded single line */ 'embedded' AS second; second ---------- @@ -19,6 +25,12 @@ both (1 row) +SELECT /* both embedded and trailing single line */ 'both' AS third; // trailing single line + third +------- + both +(1 row) + SELECT 'before multi-line' AS fourth; fourth ------------------- @@ -34,6 +46,20 @@ after multi-line (1 row) +SELECT 'before multi-line' -- trailing single line + AS sixth; + sixth +------------------- + before multi-line +(1 row) + +SELECT 'before multi-line' // trailing single line + AS seventh; + seventh +------------------- + before multi-line +(1 row) + -- -- Nested comments -- @@ -56,8 +82,8 @@ */ Now just one deep... */ -'deeply nested example' AS sixth; - sixth +'deeply nested example' AS eighth; + eighth ----------------------- deeply nested example (1 row)