Tue Jul 31 07:55:36 PDT 2007
- Previous message: [Slony1-commit] slony1-engine/src/slon confoptions.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/src/parsestatements
In directory main.slony.info:/tmp/cvs-serv16120
Modified Files:
Tag: REL_1_2_STABLE
emptytestresult.expected scanner.c test_sql.expected
test_sql.sql
Log Message:
Fixes to DDL statement parser, along with additional torture tests
provided by Weslee Bilodeau
Index: scanner.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/parsestatements/scanner.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** scanner.c 4 Aug 2006 20:40:19 -0000 1.3
--- scanner.c 31 Jul 2007 14:55:34 -0000 1.3.2.1
***************
*** 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.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** test_sql.expected 24 Feb 2006 18:48:12 -0000 1.2
--- test_sql.expected 31 Jul 2007 14:55:34 -0000 1.2.2.1
***************
*** 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.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
Binary files /tmp/cvsEsxAhM and /tmp/cvstVlo4U 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.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
*** test_sql.sql 24 Feb 2006 18:33:02 -0000 1.1
--- test_sql.sql 31 Jul 2007 14:55:34 -0000 1.1.2.1
***************
*** 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
- Previous message: [Slony1-commit] slony1-engine/src/slon confoptions.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list