Chris Browne cbbrowne at lists.slony.info
Tue Sep 4 13:36:21 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/parsestatements
In directory main.slony.info:/tmp/cvs-serv4317

Modified Files:
      Tag: REL_1_2_STABLE
	Makefile scanner.c test_sql.expected test_sql.sql 
Added Files:
      Tag: REL_1_2_STABLE
	cstylecomments.expected cstylecomments.sql 
Log Message:
Make C-style comments work, add in test for them


--- NEW FILE: cstylecomments.expected ---
Input: -- Have two statements separated by a C-style string
select * from a;
/*
select count(distinct person_id)
from
    person
    join dictionary on dic_category_id=11
    left join person_settings on ps_person_id=person_id and ps_did=dic_id
where
    ps_person_id is null
-- only 9000!
*/
select * from b;
/************ *foooo*   /- *
/   here is a tremendously ugly C-style comment
* * * * * /
-- **{***(***[****/
select * from c;

/* lets have a comment and a  /* nested comment */ */
-- Force a query to be at the end...

create table foo;

statement 0
-------------------------------------------
-- Have two statements separated by a C-style string
select * from a;
statement 1
-------------------------------------------

/*
select count(distinct person_id)
from
    person
    join dictionary on dic_category_id=11
    left join person_settings on ps_person_id=person_id and ps_did=dic_id
where
    ps_person_id is null
-- only 9000!
*/
select * from b;
statement 2
-------------------------------------------

/************ *foooo*   /- *
/   here is a tremendously ugly C-style comment
* * * * * /
-- **{***(***[****/
select * from c;
statement 3
-------------------------------------------


/* lets have a comment and a  /* nested comment */ */
-- Force a query to be at the end...

create table foo; 
Index: test_sql.expected
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/test_sql.expected,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** test_sql.expected	31 Jul 2007 14:55:34 -0000	1.2.2.1
--- test_sql.expected	4 Sep 2007 20:36:19 -0000	1.2.2.2
***************
*** 60,65 ****
  
  -- Some more torturing per Weslee Bilodeau
! 
! -- I figure the $_$, $$, etc edge-casees would be another fun one to roll
  -- into a custom parser.
  
--- 60,64 ----
  
  -- Some more torturing per Weslee Bilodeau
! -- I figure the $_$, $$, etc edge-cases would be another fun one to roll
  -- into a custom parser.
  
***************
*** 194,199 ****
  
  -- Some more torturing per Weslee Bilodeau
! 
! -- I figure the $_$, $$, etc edge-casees would be another fun one to roll
  -- into a custom parser.
  
--- 193,197 ----
  
  -- Some more torturing per Weslee Bilodeau
! -- I figure the $_$, $$, etc edge-cases would be another fun one to roll
  -- into a custom parser.
  

Index: Makefile
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/Makefile,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -d -r1.4 -r1.4.2.1
*** Makefile	1 Jun 2006 08:33:04 -0000	1.4
--- Makefile	4 Sep 2007 20:36:19 -0000	1.4.2.1
***************
*** 24,27 ****
--- 24,29 ----
  	./test-scanner < ./test_sql.sql > test_sql.log
  	cmp ./test_sql.log ./test_sql.expected$(SUFFIX)
+ 	./test-scanner < ./cstylecomments.sql > cstylecomments.log
+ 	cmp ./cstylecomments.log ./cstylecomments.expected$(SUFFIX)
  
  install:

Index: test_sql.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/test_sql.sql,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** test_sql.sql	31 Jul 2007 14:55:34 -0000	1.1.2.1
--- test_sql.sql	4 Sep 2007 20:36:19 -0000	1.1.2.2
***************
*** 60,65 ****
  
  -- Some more torturing per Weslee Bilodeau
! 
! -- I figure the $_$, $$, etc edge-casees would be another fun one to roll
  -- into a custom parser.
  
--- 60,64 ----
  
  -- Some more torturing per Weslee Bilodeau
! -- I figure the $_$, $$, etc edge-cases would be another fun one to roll
  -- into a custom parser.
  

Index: scanner.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/scanner.c,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C2 -d -r1.3.2.1 -r1.3.2.2
*** scanner.c	31 Jul 2007 14:55:34 -0000	1.3.2.1
--- scanner.c	4 Sep 2007 20:36:19 -0000	1.3.2.2
***************
*** 42,45 ****
--- 42,47 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
+       
      case ')':
        if (state == Q_NORMAL_STATE) {
***************
*** 47,50 ****
--- 49,53 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
      case '[':
        if (state == Q_NORMAL_STATE) {
***************
*** 52,55 ****
--- 55,59 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
      case ']':
        if (state == Q_NORMAL_STATE) {
***************
*** 57,60 ****
--- 61,65 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
      case '{':
        if (state == Q_NORMAL_STATE) {
***************
*** 62,65 ****
--- 67,72 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
+ 
      case '}':
        if (state == Q_NORMAL_STATE) {
***************
*** 68,71 ****
--- 75,79 ----
        }
  
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
      case '/':
        if (state == Q_NORMAL_STATE) {
***************
*** 83,86 ****
--- 91,99 ----
  	break;
        }
+       if (state == Q_CCOMMENT) {
+ 	state = Q_HOPE_CEND;
+ 	break;
+       }
+ 
        break;
      case '\\':
***************
*** 92,95 ****
--- 105,109 ----
  	}
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      case '$':
***************
*** 132,135 ****
--- 146,150 ----
  	}
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      case '"':
***************
*** 146,149 ****
--- 161,165 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      case '\'':
***************
*** 160,163 ****
--- 176,180 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      case '-':
***************
*** 170,173 ****
--- 187,191 ----
  	break;
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      case '\n':
***************
*** 177,180 ****
--- 195,199 ----
        if (state == Q_DOLLAR_BUILDING) state = Q_NORMAL_STATE;
        if (state == Q_DOLLAR_UNBUILDING) state = Q_DOLLAR_QUOTING;
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      case '\r':
***************
*** 184,191 ****
--- 203,212 ----
        if (state == Q_DOLLAR_BUILDING) state = Q_NORMAL_STATE;
        if (state == Q_DOLLAR_UNBUILDING) state = Q_DOLLAR_QUOTING;
+       if (state == Q_HOPE_CEND) state = Q_CCOMMENT;
        break;
      case ' ':
        if (state == Q_DOLLAR_BUILDING) state = Q_NORMAL_STATE;
        if (state == Q_DOLLAR_UNBUILDING) state = Q_DOLLAR_QUOTING;
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      case ';':
***************
*** 196,201 ****
--- 217,224 ----
  	}
        }
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      default:
+       if (state == Q_HOPE_CEND)	state = Q_CCOMMENT;
        break;
      }

--- NEW FILE: cstylecomments.sql ---
-- Have two statements separated by a C-style string
select * from a;
/*
select count(distinct person_id)
from
    person
    join dictionary on dic_category_id=11
    left join person_settings on ps_person_id=person_id and ps_did=dic_id
where
    ps_person_id is null
-- only 9000!
*/
select * from b;
/************ *foooo*   /- *
/   here is a tremendously ugly C-style comment
* * * * * /
-- **{***(***[****/
select * from c;

/* lets have a comment and a  /* nested comment */ */
-- Force a query to be at the end...

create table foo;


More information about the Slony1-commit mailing list