01.patch

text/x-patch

Filename: 01.patch
Type: text/x-patch
Part: 0
Message: ECPG fixes, was: Re: ECPG FETCH readahead

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/interfaces/ecpg/preproc/ecpg.trailer 6 1
commit f167aaa9693305e08cd6b2946af8528dada799b4
Author: Böszörményi Zoltán <zb@cybertec.at>
Date:   Wed Nov 20 10:31:21 2013 +0100

    ECPG: Make the preprocessor emit ';' if the variable type for
    a list of variables is varchar. This fixes this test case:
    
    int main(void)
    {
        exec sql begin declare section;
        varchar a[50], b[50];
        exec sql end declare section;
    
        return 0;
    }
    
    Since varchars are internally turned into custom structs and
    the type name is emitted for these variable declarations,
    the preprocessed code previously had:
    
    struct varchar_1  { ... }  a _,_  struct varchar_2  { ... }  b ;
    
    The comma in the generated C file was a syntax error.
    
    There are no regression test changes since it's not exercised.

diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 342b7bc..fd35dfc 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -837,7 +837,12 @@ opt_signed: SQL_SIGNED
 variable_list: variable
 			{ $$ = $1; }
 		| variable_list ',' variable
-			{ $$ = cat_str(3, $1, mm_strdup(","), $3); }
+		{
+			if (actual_type[struct_level].type_enum == ECPGt_varchar)
+				$$ = cat_str(3, $1, mm_strdup(";"), $3);
+			else
+				$$ = cat_str(3, $1, mm_strdup(","), $3);
+		}
 		;
 
 variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initializer