Fix the slonik script scanner to accept two single quotes
authorJan Wieck <JanWieck@Yahoo.com>
Tue, 28 May 2013 19:05:23 +0000 (15:05 -0400)
committerJan Wieck <JanWieck@Yahoo.com>
Tue, 28 May 2013 19:05:23 +0000 (15:05 -0400)
inside a single quoted string.

clustertest/regression/testtabnames/init_add_tables.ik
clustertest/regression/testtabnames/init_schema.sql
clustertest/regression/testtabnames/testtabnames.js
src/slonik/scan.l

index f3ef1a1252219f2f025cd9955c7701f9e02be186..467bbc127cacf93071453b63fe132af8536ea71c 100644 (file)
@@ -8,3 +8,5 @@ set add table (set id = 1, origin = 1, id = 5, fully qualified name =
 set add table (set id = 1, origin = 1, id = 6, fully qualified name ='"Schema.name".user', comment = 'Table with evil name - user, and a field called user');
 
 set add table (set id = 1, origin = 1, id = 7, fully qualified name ='"Schema.name"."Capital Idea"', comment = 'Table with spaces in its name, caps, and a user field as PK');
+
+set add table (set id = 1, origin = 1, id = 8, fully qualified name ='public."Jan''s bad ideas"', comment = 'Table single quote in name');
index ab496af248abf7a864cd7b539b2725292bb2624b..78492f20018dbd7b089b1178c9209cac84952bed 100644 (file)
@@ -41,3 +41,7 @@ create table public.evil_index_table (
   "eViL StudlyCaps column" text
 );
 create unique index "user" on public.evil_index_table(id);
+
+create table public."Jan's bad ideas" (
+       id int4 primary key
+);
index e7764124e873c9ff08fe2190ec6997f8ac09387d..10cbec34f343bdf09c46f0e81dc2051f80e3f01e 100644 (file)
@@ -99,6 +99,7 @@ function get_compare_queries() {
                     ,"SELECT id, \"user\" from \"Schema.name\".\"user\" order by id"
                     ,"SELECT \"user\", description from \"Schema.name\".\"Capital Idea\" order by \"user\""
                     ,"SELECT id, name, \"eViL StudlyCaps column\" from public.evil_index_table order by id"
+                                ,"SELECT id from \"Jan's bad ideas\" order by id"
 
                    ];
 
index 319f18851bd6959a370ce32100555460d828c103..4ae1c238de861fe98f45f19b425d36ef6fc02ed1 100644 (file)
@@ -178,7 +178,16 @@ yes                                { return K_YES;                         }
                        instring_buffer[instring_length]=*yytext;
                        BEGIN(IN_STRING);
                }
-<IN_STRING>''  
+<IN_STRING>''  {
+                               if (  instring_buf_length < instring_length + yyleng+1 )
+                               {
+                                               instring_buffer=realloc(instring_buffer,instring_buf_length*2);
+                                               instring_buf_length=instring_buf_length*2;
+                               }
+                               instring_buffer[instring_length++] = '\'';
+
+                               
+               }
 <IN_STRING>[^']+ { 
                                if (  instring_buf_length < instring_length + yyleng+1 )
                                {