diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5fa111c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.o +*.so +*.a +*.so.* diff --git a/postgresql-8.3.3/src/interfaces/ecpg/preproc/Makefile b/postgresql-8.3.3/src/interfaces/ecpg/preproc/Makefile index 8ada492..68d4ea0 100644 --- a/postgresql-8.3.3/src/interfaces/ecpg/preproc/Makefile +++ b/postgresql-8.3.3/src/interfaces/ecpg/preproc/Makefile @@ -53,6 +53,8 @@ endif $(srcdir)/pgc.c: pgc.l ifdef FLEX $(FLEX) $(FLEXFLAGS) -o'$@' $< + sed -i 's/int yylineno/yy_size_t yylineno/g' pgc.c + sed -i 's/int yyleng/yy_size_t yyleng/g' pgc.c else @$(missing) flex $< $@ endif diff --git a/postgresql-8.3.3/src/interfaces/ecpg/preproc/extern.h b/postgresql-8.3.3/src/interfaces/ecpg/preproc/extern.h index c9097c8..cfc37d3 100644 --- a/postgresql-8.3.3/src/interfaces/ecpg/preproc/extern.h +++ b/postgresql-8.3.3/src/interfaces/ecpg/preproc/extern.h @@ -36,9 +36,12 @@ extern char *yytext, *token_start; #ifdef YYDEBUG -extern int yydebug; +extern int yydebug; #endif -extern int yylineno, +#ifndef yy_size_t +typedef size_t yy_size_t; +#endif +extern yy_size_t yylineno, yyleng; extern FILE *yyin, *yyout; diff --git a/postgresql-8.3.3/src/interfaces/ecpg/preproc/output.c b/postgresql-8.3.3/src/interfaces/ecpg/preproc/output.c index e58a752..924a3ff 100644 --- a/postgresql-8.3.3/src/interfaces/ecpg/preproc/output.c +++ b/postgresql-8.3.3/src/interfaces/ecpg/preproc/output.c @@ -97,7 +97,7 @@ hashline_number(void) { char *line = mm_alloc(strlen("\n#line %d \"%s\"\n") + sizeof(int) * CHAR_BIT * 10 / 3 + strlen(input_filename)); - sprintf(line, "\n#line %d \"%s\"\n", yylineno, input_filename); + sprintf(line, "\n#line %lu \"%s\"\n", yylineno, input_filename); return line; } @@ -195,8 +195,8 @@ output_escaped_str(char *str, bool quoted) else if (str[i] == '\\') { int j = i; - - /* check whether this is a continuation line + + /* check whether this is a continuation line * if it is, do not output anything because newlines are escaped anyway */ /* accept blanks after the '\' as some other compilers do too */ diff --git a/postgresql-8.3.3/src/interfaces/ecpg/preproc/pgc.l b/postgresql-8.3.3/src/interfaces/ecpg/preproc/pgc.l index 2ad415d..fdf52b6 100644 --- a/postgresql-8.3.3/src/interfaces/ecpg/preproc/pgc.l +++ b/postgresql-8.3.3/src/interfaces/ecpg/preproc/pgc.l @@ -52,8 +52,8 @@ static bool isinformixdefine(void); char *token_start; int state_before; -struct _yy_buffer -{ +struct _yy_buffer +{ YY_BUFFER_STATE buffer; long lineno; char *filename; @@ -65,7 +65,7 @@ static char *old; #define MAX_NESTED_IF 128 static short preproc_tos; static short ifcond; -static struct _if_value +static struct _if_value { short condition; short else_branch; @@ -80,7 +80,7 @@ static struct _if_value %option yylineno -%x C SQL incl def def_ident undef +%x C SQL incl def def_ident undef /* * OK, here is a short description of lex/flex rules behavior. @@ -473,7 +473,7 @@ cppline {space}*#(.*\\{space})*.*{newline} /* throw back all but the initial "$" */ yyless(1); /* and treat it as {other} */ - return yytext[0]; + return yytext[0]; } {dolqdelim} { token_start = yytext; @@ -675,7 +675,7 @@ cppline {space}*#(.*\\{space})*.*{newline} } {identifier} { const ScanKeyword *keyword; - + if (!isdefine()) { /* Is it an SQL/ECPG keyword? */ @@ -702,7 +702,7 @@ cppline {space}*#(.*\\{space})*.*{newline} } {other} { return yytext[0]; } {exec_sql} { BEGIN(SQL); return SQL_START; } -{informix_special} { +{informix_special} { /* are we simulating Informix? */ if (INFORMIX_MODE) { @@ -743,7 +743,7 @@ cppline {space}*#(.*\\{space})*.*{newline} } {identifier} { const ScanKeyword *keyword; - + /* Informix uses SQL defines only in SQL space */ /* however, some defines have to be taken care of for compatibility */ if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine()) @@ -854,7 +854,7 @@ cppline {space}*#(.*\\{space})*.*{newline} yyterminate(); } {exec_sql}{include}{space}* { BEGIN(incl); } -{informix_special}{include}{space}* { +{informix_special}{include}{space}* { /* are we simulating Informix? */ if (INFORMIX_MODE) { @@ -867,7 +867,7 @@ cppline {space}*#(.*\\{space})*.*{newline} } } {exec_sql}{ifdef}{space}* { ifcond = TRUE; BEGIN(xcond); } -{informix_special}{ifdef}{space}* { +{informix_special}{ifdef}{space}* { /* are we simulating Informix? */ if (INFORMIX_MODE) { @@ -881,7 +881,7 @@ cppline {space}*#(.*\\{space})*.*{newline} } } {exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); } -{informix_special}{ifndef}{space}* { +{informix_special}{ifndef}{space}* { /* are we simulating Informix? */ if (INFORMIX_MODE) { @@ -905,7 +905,7 @@ cppline {space}*#(.*\\{space})*.*{newline} ifcond = TRUE; BEGIN(xcond); } -{informix_special}{elif}{space}* { +{informix_special}{elif}{space}* { /* are we simulating Informix? */ if (INFORMIX_MODE) { @@ -1004,7 +1004,7 @@ cppline {space}*#(.*\\{space})*.*{newline} {identifier}{space}*";" { if (preproc_tos >= MAX_NESTED_IF-1) mmerror(PARSE_ERROR, ET_FATAL, "Too many nested 'EXEC SQL IFDEF' conditions"); - else + else { struct _defines *defptr; unsigned int i; @@ -1047,7 +1047,7 @@ cppline {space}*#(.*\\{space})*.*{newline} {other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "Missing identifier in 'EXEC SQL DEFINE' command"); yyterminate(); - } + } {space}*";" { struct _defines *ptr, *this; @@ -1085,7 +1085,7 @@ cppline {space}*#(.*\\{space})*.*{newline} <> { if (yy_buffer == NULL) { - if ( preproc_tos > 0 ) + if ( preproc_tos > 0 ) { preproc_tos = 0; mmerror(PARSE_ERROR, ET_FATAL, "Missing 'EXEC SQL ENDIF;'"); @@ -1104,7 +1104,7 @@ cppline {space}*#(.*\\{space})*.*{newline} ptr->used = NULL; break; } - + if (yyin != NULL) fclose(yyin); @@ -1124,7 +1124,7 @@ cppline {space}*#(.*\\{space})*.*{newline} if (i != 0) output_line_number(); - + } } {other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "Internal error: unreachable state, please inform pgsql-bugs@postgresql.org"); } @@ -1157,7 +1157,7 @@ addlit(char *ytext, int yleng) /* enlarge buffer if needed */ if ((literallen+yleng) >= literalalloc) { - do + do literalalloc *= 2; while ((literallen+yleng) >= literalalloc); literalbuf = (char *) realloc(literalbuf, literalalloc); @@ -1203,7 +1203,7 @@ parse_include(void) /* * skip the ";" if there is one and trailing whitespace. Note that - * yytext contains at least one non-space character plus the ";" + * yytext contains at least one non-space character plus the ";" */ for (i = strlen(yytext)-2; i > 0 && ecpg_isspace(yytext[i]); @@ -1214,7 +1214,7 @@ parse_include(void) i--; yytext[i+1] = '\0'; - + yyin = NULL; /* If file name is enclosed in '"' remove these and look only in '.' */ @@ -1224,7 +1224,7 @@ parse_include(void) { yytext[i] = '\0'; memmove(yytext, yytext+1, strlen(yytext)); - + strncpy(inc_file, yytext, sizeof(inc_file)); yyin = fopen(inc_file, "r"); if (!yyin) @@ -1235,7 +1235,7 @@ parse_include(void) yyin = fopen(inc_file, "r"); } } - + } else { @@ -1244,12 +1244,12 @@ parse_include(void) yytext[i] = '\0'; memmove(yytext, yytext+1, strlen(yytext)); } - + for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next) { if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH) { - fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno); + fprintf(stderr, "Error: Path %s/%s is too long in line %lu, skipping.\n", ip->path, yytext, yylineno); continue; } snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext); @@ -1265,7 +1265,7 @@ parse_include(void) } } if (!yyin) - mmerror(NO_INCLUDE_FILE, ET_FATAL, "Cannot open include file %s in line %d\n", yytext, yylineno); + mmerror(NO_INCLUDE_FILE, ET_FATAL, "Cannot open include file %s in line %lu\n", yytext, yylineno); input_filename = mm_strdup(inc_file); yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE )); diff --git a/postgresql-8.3.3/src/interfaces/ecpg/preproc/preproc.y b/postgresql-8.3.3/src/interfaces/ecpg/preproc/preproc.y index aa7413e..eeec29e 100644 --- a/postgresql-8.3.3/src/interfaces/ecpg/preproc/preproc.y +++ b/postgresql-8.3.3/src/interfaces/ecpg/preproc/preproc.y @@ -60,7 +60,7 @@ mmerror(int error_code, enum errortype type, char * error, ...) { va_list ap; - fprintf(stderr, "%s:%d: ", input_filename, yylineno); + fprintf(stderr, "%s:%lu: ", input_filename, yylineno); switch(type) { @@ -423,7 +423,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT - COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS + COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS CONTENT_P CONVERSION_P COPY COST CREATE CREATEDB CREATEROLE CREATEUSER CROSS CSV CURRENT_P CURRENT_DATE CURRENT_ROLE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE @@ -480,7 +480,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu STATISTICS STDIN STDOUT STORAGE STRICT_P STRIP_P SUBSTRING SUPERUSER_P SYMMETRIC SYSID SYSTEM_P - TABLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN TIME TIMESTAMP TO + TABLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN TIME TIMESTAMP TO TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P TRUNCATE TRUSTED TYPE_P UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNTIL @@ -586,7 +586,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu %type RemoveOperStmt RenameStmt all_Op opt_trusted opt_lancompiler %type VariableSetStmt var_value zone_value VariableShowStmt %type VariableResetStmt AlterTableStmt from_list overlay_list -%type relation_name OptTableSpace LockStmt opt_lock +%type relation_name OptTableSpace LockStmt opt_lock %type CreateUserStmt AlterUserStmt CreateSeqStmt OptSeqList %type OptSeqElem TriggerForSpec TriggerForOpt TriggerForType %type DropTrigStmt TriggerOneEvent TriggerEvents RuleActionStmt @@ -616,7 +616,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu %type OptSchemaName OptSchemaEltList schema_stmt opt_drop_behavior %type handler_name any_name_list any_name opt_as insert_column_list %type columnref values_clause AllConstVar prep_type_clause ExecuteStmt -%type insert_column_item DropRuleStmt ctext_expr execute_param_clause +%type insert_column_item DropRuleStmt ctext_expr execute_param_clause %type createfunc_opt_item set_rest alter_rel_cmd %type CreateFunctionStmt createfunc_opt_list func_table %type DropUserStmt copy_from copy_opt_list copy_opt_item @@ -647,7 +647,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu %type ECPGGetDescriptorHeader ECPGColLabel SetResetClause AlterUserSetStmt %type reserved_keyword unreserved_keyword ecpg_interval opt_ecpg_using %type col_name_keyword precision opt_scale ECPGExecuteImmediateStmt -%type ECPGTypeName using_list ECPGColLabelCommon UsingConst +%type ECPGTypeName using_list ECPGColLabelCommon UsingConst %type using_descriptor into_descriptor opt_nulls_order opt_asc_desc %type prepared_name struct_union_type_with_symbol OptConsTableSpace %type ECPGunreserved ECPGunreserved_interval cvariable opt_bit_field @@ -665,7 +665,7 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu %type opclass_drop_list opclass_drop DropOpFamilyStmt opt_opfamily %type CreateOpFamilyStmt AlterOpFamilyStmt create_as_target %type xml_attributes xml_attribute_list document_or_content xml_whitespace_option -%type opt_xml_root_standalone xml_root_version xml_attribute_el +%type opt_xml_root_standalone xml_root_version xml_attribute_el %type where_or_current_clause AlterTSConfigurationStmt AlterTSDictionaryStmt %type s_struct_union_symbol @@ -787,7 +787,7 @@ stmt: AlterDatabaseStmt { output_statement($1, 0, ECPGst_normal); } { if (connection) mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement.\n"); - + output_deallocate_prepare_statement($1); } | DeclareCursorStmt { output_simple_statement($1); } @@ -819,15 +819,15 @@ stmt: AlterDatabaseStmt { output_statement($1, 0, ECPGst_normal); } | LoadStmt { output_statement($1, 0, ECPGst_normal); } | LockStmt { output_statement($1, 0, ECPGst_normal); } | NotifyStmt { output_statement($1, 0, ECPGst_normal); } - | PrepareStmt { + | PrepareStmt { if ($1.type == NULL || strlen($1.type) == 0) /* use PQprepare without type parameters */ - output_prepare_statement($1.name, $1.stmt); + output_prepare_statement($1.name, $1.stmt); else /* use PQexec and let backend do its stuff */ { char *txt = cat_str(5, make_str("prepare"), $1.name, $1.type, make_str("as"), $1.stmt); output_statement(txt, 0, ECPGst_normal); } - } + } | ReassignOwnedStmt { output_statement($1, 0, ECPGst_normal); } | ReindexStmt { output_statement($1, 0, ECPGst_normal); } | RemoveAggrStmt { output_statement($1, 0, ECPGst_normal); } @@ -1500,14 +1500,14 @@ CopyStmt: COPY opt_binary qualified_name opt_oids copy_from mmerror(PARSE_ERROR, ET_ERROR, "copy from stdout not possible.\n"); else if (strcmp($5, "from") == 0 && strcmp($6, "stdin") == 0) mmerror(PARSE_ERROR, ET_WARNING, "copy from stdin not implemented.\n"); - + $$ = cat_str(9, make_str("copy"), $2, $3, $4, $5, $6, $7, $8, $9); } | COPY select_with_parens TO copy_file_name opt_with copy_opt_list { if (strcmp($4, "stdin") == 0) mmerror(PARSE_ERROR, ET_ERROR, "copy to stdin not possible.\n"); - + $$ = cat_str(6, make_str("copy"), $2, make_str("to"), $4, $5, $6); } ; @@ -2573,12 +2573,12 @@ opt_class: any_name { $$ = $1; } ; opt_asc_desc: ASC { $$ = make_str("asc"); } - | DESC { $$ = make_str("desc"); } + | DESC { $$ = make_str("desc"); } | /*EMPTY*/ { $$ = EMPTY; } ; opt_nulls_order: NULLS_FIRST { $$ = make_str("nulls first"); } - | NULLS_LAST { $$ = make_str("nulls last"); } + | NULLS_LAST { $$ = make_str("nulls last"); } | /*EMPTY*/ { $$ = EMPTY; } ; @@ -3059,12 +3059,12 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list AS SelectStmt opt_ */ opt_check_option: WITH_CHECK OPTION - { + { mmerror(PARSE_ERROR, ET_ERROR, "WITH CHECK OPTION not implemented"); $$ = EMPTY; } | WITH_CASCADED CHECK OPTION - { + { mmerror(PARSE_ERROR, ET_ERROR, "WITH CHECK OPTION not implemented"); $$ = EMPTY; } @@ -3074,7 +3074,7 @@ opt_check_option: $$ = EMPTY; } | /* EMPTY */ - { $$ = EMPTY; } + { $$ = EMPTY; } ; /***************************************************************************** @@ -3377,7 +3377,7 @@ InsertStmt: INSERT INTO qualified_name insert_rest returning_clause { $$ = cat_str(4, make_str("insert into"), $3, $4, $5); } ; -insert_rest: +insert_rest: SelectStmt { $$ = $1; } | '(' insert_column_list ')' SelectStmt @@ -3700,7 +3700,7 @@ for_locking_clause: | FOR READ ONLY { $$ = make_str("for read only");} ; -opt_for_locking_clause: +opt_for_locking_clause: for_locking_clause { $$ = $1; } | /* EMPTY */ { $$ = EMPTY; } ; @@ -3959,7 +3959,7 @@ GenericType: type_function_name opt_type_modifiers { $$ = cat2_str($1, $2); } opt_type_modifiers: '(' expr_list ')' { $$ = cat_str(3, make_str("("), $2, make_str(")")); } | /* EMPTY */ { $$ = EMPTY; } ; - + /* SQL92 numeric data types * Check FLOAT() precision limits assuming IEEE floating types. * Provide real DECIMAL() and NUMERIC() implementations now - Jan 1998-12-30 @@ -4252,7 +4252,7 @@ a_expr: c_expr { $$ = cat_str(4, $1, $2, $3, $4); } | a_expr subquery_Op sub_type '(' a_expr ')' %prec Op { $$ = cat_str(6, $1, $2, $3, make_str("("), $5, make_str(")")); } - | UNIQUE select_with_parens + | UNIQUE select_with_parens { $$ = cat2_str(make_str("unique"), $2); } | a_expr IS DOCUMENT_P { $$ = cat2_str($1, make_str("is document")); } @@ -4730,7 +4730,7 @@ update_target_list: '(' inf_col_list ')' '=' '(' inf_val_list ')' vals = cat_str( 3, vals, ptrv->val, make_str(")") ); } $$ = cat_str( 3, cols, make_str("="), vals ); - } + } ; inf_col_list: ColId opt_indirection @@ -4875,7 +4875,7 @@ Sconst: SCONST } | DOLCONST { - $$ = $1; + $$ = $1; } ; @@ -5009,7 +5009,7 @@ connection_target: opt_database_name opt_server opt_port /* old style: dbname[@server][:port] */ if (strlen($2) > 0 && *($2) != '@') mmerror(PARSE_ERROR, ET_ERROR, "Expected '@', found '%s'", $2); - + /* C strings need to be handled differently */ if ($1[0] == '\"') $$ = $1; @@ -5221,7 +5221,7 @@ ECPGCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR prepared_name ; ECPGExecuteImmediateStmt: EXECUTE IMMEDIATE execstring - { + { /* execute immediate means prepare the statement and * immediately execute it */ $$ = $3; @@ -5497,7 +5497,7 @@ var_type: simple_type $$.type_index = this->type->type_index; if (this->type->type_sizeof && strlen(this->type->type_sizeof) != 0) $$.type_sizeof = this->type->type_sizeof; - else + else $$.type_sizeof = cat_str(3, make_str("sizeof("), mm_strdup(this->name), make_str(")")); struct_member_list[struct_level] = ECPGstruct_member_dup(this->struct_member_list); @@ -5728,7 +5728,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length, yylineno); else type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length, yylineno), dimension); - + if (strcmp(dimension, "0") == 0 || abs(atoi(dimension)) == 1) *dim = '\0'; else @@ -5739,7 +5739,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_bit_field opt_initialize /* make sure varchar struct name is unique by adding linenumer of its definition */ vcn = (char *) mm_alloc(strlen($2) + sizeof(int) * CHAR_BIT * 10 / 3); - sprintf(vcn, "%s_%d", $2, yylineno); + sprintf(vcn, "%s_%lu", $2, yylineno); if (strcmp(dimension, "0") == 0) $$ = cat_str(7, make2_str(make_str(" struct varchar_"), vcn), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } *"), mm_strdup($2), $4, $5); else @@ -5839,7 +5839,7 @@ execstring: char_variable { $$ = make3_str(make_str("\""), $1, make_str("\"")); } ; -prepared_name: name { +prepared_name: name { if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */ $$ = $1; else /* not quoted => convert to lowercase */