Chris Browne cbbrowne at lists.slony.info
Tue Aug 21 15:17:57 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/parsestatements
In directory main.slony.info:/tmp/cvs-serv6390

Modified Files:
	emptytestresult.expected scanner.c test_sql.expected 
	test_sql.sql 
Log Message:
Apply updates to scanner previously applied to 1.2 branch


Index: scanner.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/scanner.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** scanner.c	4 Aug 2006 20:40:19 -0000	1.3
--- scanner.c	21 Aug 2007 22:17:55 -0000	1.4
***************
*** 12,15 ****
--- 12,18 ----
    int d1start, d1end, d2start, d2end, d1stemp;
    int statements;
+   int nparens;
+   int nbrokets;
+   int nsquigb;
    
    /* Initialize */
***************
*** 22,25 ****
--- 25,31 ----
    d1end = 0;
    state = Q_NORMAL_STATE;
+   nparens = 0;
+   nbrokets = 0;
+   nsquigb = 0;
    
    while (state != Q_DONE) {
***************
*** 27,32 ****
--- 33,71 ----
      switch (cchar) {
      case '\0':
+       STMTS[statements++] = ++cpos;
        state = Q_DONE;
        break;
+ 
+     case '(':
+       if (state == Q_NORMAL_STATE) {
+ 	nparens ++;
+ 	break;
+       }
+     case ')':
+       if (state == Q_NORMAL_STATE) {
+ 	nparens --;
+ 	break;
+       }
+     case '[':
+       if (state == Q_NORMAL_STATE) {
+ 	nbrokets ++;
+ 	break;
+       }
+     case ']':
+       if (state == Q_NORMAL_STATE) {
+ 	nbrokets --;
+ 	break;
+       }
+     case '{':
+       if (state == Q_NORMAL_STATE) {
+ 	nsquigb ++;
+ 	break;
+       }
+     case '}':
+       if (state == Q_NORMAL_STATE) {
+ 	nsquigb --;
+ 	break;
+       }
+ 
      case '/':
        if (state == Q_NORMAL_STATE) {
***************
*** 52,57 ****
  	  break;
  	}
!       } 
! 
        break;
      case '$':
--- 91,95 ----
  	  break;
  	}
!       }
        break;
      case '$':
***************
*** 124,128 ****
        break;
      case '-':
!       if (state == Q_NORMAL_STATE) {
  	state = Q_HOPE_TO_DASH;
  	break;
--- 162,166 ----
        break;
      case '-':
!       if (state == Q_NORMAL_STATE && extended_statement[cpos+1] == '-') {
  	state = Q_HOPE_TO_DASH;
  	break;
***************
*** 152,156 ****
        break;
      case ';':
!       if (state == Q_NORMAL_STATE) {
  	STMTS[statements++] = ++cpos;
  	if (statements >= MAXSTATEMENTS) {
--- 190,194 ----
        break;
      case ';':
!       if ((state == Q_NORMAL_STATE) && (nparens == 0) && (nbrokets == 0) && (nsquigb == 0)) {
  	STMTS[statements++] = ++cpos;
  	if (statements >= MAXSTATEMENTS) {

Index: test_sql.expected
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/test_sql.expected,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_sql.expected	24 Feb 2006 18:48:12 -0000	1.2
--- test_sql.expected	21 Aug 2007 22:17:55 -0000	1.3
***************
*** 38,41 ****
--- 38,80 ----
  
  
+ -- Here is a rule creation with an embedded semicolon
+ -- "Dmitry Koterov" <dmitry at koterov.ru>
+ 
+ create table "public"."position";
+ 
+ CREATE RULE "position_get_last_id_on_insert2"
+ AS ON INSERT TO "public"."position" DO (SELECT
+ currval('position_position_id_seq'::regclass) AS id;);
+ 
+ -- Added to verify handling of queries tried by
+ -- "Dmitry Koterov" <dmitry at koterov.ru>
+ 
+ CREATE INDEX aaa ON public.bbb USING btree ((-ccc), ddd);
+ 
+ --  Apparently a pair of backslashes fold down into one?
+ -- "Dmitry Koterov" <dmitry at koterov.ru>
+ 
+ CREATE UNIQUE INDEX "i_dictionary_uni_abbr" ON "static"."dictionary"
+ USING btree ((substring(dic_russian, E'^([^(]*[^( ]) *\\('::text)))
+ WHERE (dic_category_id = 26);
+ 
+ -- Some more torturing per Weslee Bilodeau
+ 
+ -- I figure the $_$, $$, etc edge-casees would be another fun one to roll
+ -- into a custom parser.
+ 
+ CREATE FUNCTION test( ) RETURNS text AS $_$ SELECT ';', E'\';\'',
+ '"";""', E'"\';' ; SELECT 'OK'::text ; $_$ LANGUAGE SQL ;
+ 
+ SELECT $_$ hello; this ; - is '\" a '''' test $_$ ;
+ 
+ SELECT $$ $ test ; $ ;  $$ ;
+ 
+ -- All really funky, but perfectly valid.
+ 
+ -- Force a query to be at the end...
+ 
+ create table foo;
+ 
  statement 0
  -------------------------------------------
***************
*** 115,117 ****
      return NULL;
    end;
! $$ language plpgsql;
\ No newline at end of file
--- 154,223 ----
      return NULL;
    end;
! $$ language plpgsql;
! statement 14
! -------------------------------------------
! 
! 
! 
! -- Here is a rule creation with an embedded semicolon
! -- "Dmitry Koterov" <dmitry at koterov.ru>
! 
! create table "public"."position";
! statement 15
! -------------------------------------------
! 
! 
! CREATE RULE "position_get_last_id_on_insert2"
! AS ON INSERT TO "public"."position" DO (SELECT
! currval('position_position_id_seq'::regclass) AS id;);
! statement 16
! -------------------------------------------
! 
! 
! -- Added to verify handling of queries tried by
! -- "Dmitry Koterov" <dmitry at koterov.ru>
! 
! CREATE INDEX aaa ON public.bbb USING btree ((-ccc), ddd);
! statement 17
! -------------------------------------------
! 
! 
! --  Apparently a pair of backslashes fold down into one?
! -- "Dmitry Koterov" <dmitry at koterov.ru>
! 
! CREATE UNIQUE INDEX "i_dictionary_uni_abbr" ON "static"."dictionary"
! USING btree ((substring(dic_russian, E'^([^(]*[^( ]) *\\('::text)))
! WHERE (dic_category_id = 26);
! statement 18
! -------------------------------------------
! 
! 
! -- Some more torturing per Weslee Bilodeau
! 
! -- I figure the $_$, $$, etc edge-casees would be another fun one to roll
! -- into a custom parser.
! 
! CREATE FUNCTION test( ) RETURNS text AS $_$ SELECT ';', E'\';\'',
! '"";""', E'"\';' ; SELECT 'OK'::text ; $_$ LANGUAGE SQL ;
! statement 19
! -------------------------------------------
! 
! 
! SELECT $_$ hello; this ; - is '\" a '''' test $_$ ;
! statement 20
! -------------------------------------------
! 
! 
! SELECT $$ $ test ; $ ;  $$ ;
! statement 21
! -------------------------------------------
! 
! 
! -- All really funky, but perfectly valid.
! 
! -- Force a query to be at the end...
! 
! create table foo;
! statement 22
! -------------------------------------------
!   
\ No newline at end of file

Index: emptytestresult.expected
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/emptytestresult.expected,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
Binary files /tmp/cvsdqaIoX and /tmp/cvsbTSZoP differ

Index: test_sql.sql
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/test_sql.sql,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_sql.sql	24 Feb 2006 18:33:02 -0000	1.1
--- test_sql.sql	21 Aug 2007 22:17:55 -0000	1.2
***************
*** 36,37 ****
--- 36,77 ----
    end;
  $$ language plpgsql;
+ 
+ 
+ -- Here is a rule creation with an embedded semicolon
+ -- "Dmitry Koterov" <dmitry at koterov.ru>
+ 
+ create table "public"."position";
+ 
+ CREATE RULE "position_get_last_id_on_insert2"
+ AS ON INSERT TO "public"."position" DO (SELECT
+ currval('position_position_id_seq'::regclass) AS id;);
+ 
+ -- Added to verify handling of queries tried by
+ -- "Dmitry Koterov" <dmitry at koterov.ru>
+ 
+ CREATE INDEX aaa ON public.bbb USING btree ((-ccc), ddd);
+ 
+ --  Apparently a pair of backslashes fold down into one?
+ -- "Dmitry Koterov" <dmitry at koterov.ru>
+ 
+ CREATE UNIQUE INDEX "i_dictionary_uni_abbr" ON "static"."dictionary"
+ USING btree ((substring(dic_russian, E'^([^(]*[^( ]) *\\('::text)))
+ WHERE (dic_category_id = 26);
+ 
+ -- Some more torturing per Weslee Bilodeau
+ 
+ -- I figure the $_$, $$, etc edge-casees would be another fun one to roll
+ -- into a custom parser.
+ 
+ CREATE FUNCTION test( ) RETURNS text AS $_$ SELECT ';', E'\';\'',
+ '"";""', E'"\';' ; SELECT 'OK'::text ; $_$ LANGUAGE SQL ;
+ 
+ SELECT $_$ hello; this ; - is '\" a '''' test $_$ ;
+ 
+ SELECT $$ $ test ; $ ;  $$ ;
+ 
+ -- All really funky, but perfectly valid.
+ 
+ -- Force a query to be at the end...
+ 
+ create table foo;
\ No newline at end of file



More information about the Slony1-commit mailing list