codecheck修复
This commit is contained in:
@ -130,7 +130,7 @@ struct connection* ecpg_get_connection(const char*);
|
|||||||
char* ecpg_alloc(long, int);
|
char* ecpg_alloc(long, int);
|
||||||
char* ecpg_realloc(void*, long, int);
|
char* ecpg_realloc(void*, long, int);
|
||||||
void ecpg_free(void*);
|
void ecpg_free(void*);
|
||||||
bool ecpg_init(const struct connection*, const char*, const int);
|
bool ecpg_init(const struct connection* con, const char* connection_name, const int lineno);
|
||||||
char* ecpg_strdup(const char*, int);
|
char* ecpg_strdup(const char*, int);
|
||||||
const char* ecpg_type_name(enum ECPGttype);
|
const char* ecpg_type_name(enum ECPGttype);
|
||||||
int ecpg_dynamic_type(Oid);
|
int ecpg_dynamic_type(Oid);
|
||||||
@ -145,7 +145,7 @@ struct descriptor* ecpg_find_desc(int line, const char* name);
|
|||||||
struct prepared_statement* ecpg_find_prepared_statement(const char*, struct connection*, struct prepared_statement**);
|
struct prepared_statement* ecpg_find_prepared_statement(const char*, struct connection*, struct prepared_statement**);
|
||||||
|
|
||||||
bool ecpg_store_result(const PGresult* results, int act_field, const struct statement* stmt, struct variable* var);
|
bool ecpg_store_result(const PGresult* results, int act_field, const struct statement* stmt, struct variable* var);
|
||||||
bool ecpg_store_input(const int, const bool, const struct variable*, char**, bool);
|
bool ecpg_store_input(const int lineno, const bool force_indicator, const struct variable* var, char** tobeinserted_p, bool quote);
|
||||||
|
|
||||||
bool ecpg_check_PQresult(PGresult*, int, PGconn*, enum COMPAT_MODE);
|
bool ecpg_check_PQresult(PGresult*, int, PGconn*, enum COMPAT_MODE);
|
||||||
void ecpg_raise(int line, int code, const char* sqlstate, const char* str);
|
void ecpg_raise(int line, int code, const char* sqlstate, const char* str);
|
||||||
|
@ -342,8 +342,8 @@ typedef struct {
|
|||||||
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
|
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
|
||||||
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
|
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
|
||||||
|
|
||||||
int DecodeInterval(char**, const int*, int, int*, struct tm*, fsec_t*);
|
int DecodeInterval2(char** field, const int* ftype, int nf, int* dtype, struct tm* tm, fsec_t* fsec);
|
||||||
int DecodeTime(const char*, unsigned int*, struct tm*, fsec_t*);
|
int DecodeTime(const char* str, unsigned int* tmask, struct tm* tm, fsec_t* fsec);
|
||||||
int EncodeDateTime(
|
int EncodeDateTime(
|
||||||
struct tm* tm, fsec_t fsec, bool print_tz, int tz, const char* tzn, int style, char* str, bool EuroDates);
|
struct tm* tm, fsec_t fsec, bool print_tz, int tz, const char* tzn, int style, char* str, bool EuroDates);
|
||||||
int EncodeInterval(struct tm* tm, fsec_t fsec, int style, char* str);
|
int EncodeInterval(struct tm* tm, fsec_t fsec, int style, char* str);
|
||||||
@ -359,6 +359,9 @@ void GetCurrentDateTime(struct tm*);
|
|||||||
int date2j(int, int, int);
|
int date2j(int, int, int);
|
||||||
void TrimTrailingZeros(char*);
|
void TrimTrailingZeros(char*);
|
||||||
void dt2time(double, int*, int*, int*, fsec_t*);
|
void dt2time(double, int*, int*, int*, fsec_t*);
|
||||||
|
int PGTYPEStimestamp_defmt_scan(
|
||||||
|
char** str, char* fmt, timestamp* d, int* year, int* month, int* day, int* hour, int* minute, int* second, int* tz);
|
||||||
|
|
||||||
|
|
||||||
extern char* pgtypes_date_weekdays_short[];
|
extern char* pgtypes_date_weekdays_short[];
|
||||||
extern char* pgtypes_date_months[];
|
extern char* pgtypes_date_months[];
|
||||||
|
@ -2308,9 +2308,6 @@ static int pgtypes_defmt_scan(union un_fmt_comb* scan_val, int scan_type, char**
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX range checking */
|
|
||||||
int PGTYPEStimestamp_defmt_scan(char**, char*, timestamp*, int*, int*, int*, int*, int*, int*, int*);
|
|
||||||
|
|
||||||
int PGTYPEStimestamp_defmt_scan(
|
int PGTYPEStimestamp_defmt_scan(
|
||||||
char** str, char* fmt, timestamp* d, int* year, int* month, int* day, int* hour, int* minute, int* second, int* tz)
|
char** str, char* fmt, timestamp* d, int* year, int* month, int* day, int* hour, int* minute, int* second, int* tz)
|
||||||
{
|
{
|
||||||
|
@ -317,8 +317,8 @@ static int DecodeISO8601Interval(char* str, int* dtype, struct /* pg_ */ tm* tm,
|
|||||||
*
|
*
|
||||||
* * Assert wasn't available so removed it.
|
* * Assert wasn't available so removed it.
|
||||||
*/
|
*/
|
||||||
int DecodeInterval(char** field, const int* ftype, int nf, /* int range, */
|
int DecodeInterval2(char** field, const int* ftype, int nf,
|
||||||
int* dtype, struct /* pg_ */ tm* tm, fsec_t* fsec)
|
int* dtype, struct tm* tm, fsec_t* fsec)
|
||||||
{
|
{
|
||||||
int IntervalStyle = INTSTYLE_POSTGRES_VERBOSE;
|
int IntervalStyle = INTSTYLE_POSTGRES_VERBOSE;
|
||||||
int range = INTERVAL_FULL_RANGE;
|
int range = INTERVAL_FULL_RANGE;
|
||||||
@ -1006,7 +1006,7 @@ interval* PGTYPESinterval_from_asc(char* str, char** endptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
|
if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
|
||||||
(DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0 &&
|
(DecodeInterval2(field, ftype, nf, &dtype, tm, &fsec) != 0 &&
|
||||||
DecodeISO8601Interval(str, &dtype, tm, &fsec) != 0)) {
|
DecodeISO8601Interval(str, &dtype, tm, &fsec) != 0)) {
|
||||||
errno = PGTYPES_INTVL_BAD_INTERVAL;
|
errno = PGTYPES_INTVL_BAD_INTERVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "pgtypes_timestamp.h"
|
#include "pgtypes_timestamp.h"
|
||||||
#include "pgtypes_date.h"
|
#include "pgtypes_date.h"
|
||||||
|
|
||||||
int PGTYPEStimestamp_defmt_scan(char**, char*, timestamp*, int*, int*, int*, int*, int*, int*, int*);
|
|
||||||
|
|
||||||
#ifdef HAVE_INT64_TIMESTAMP
|
#ifdef HAVE_INT64_TIMESTAMP
|
||||||
static int64 time2t(const int hour, const int min, const int sec, const fsec_t fsec)
|
static int64 time2t(const int hour, const int min, const int sec, const fsec_t fsec)
|
||||||
|
@ -100,8 +100,9 @@ void drop_descriptor(char* name, char* connection)
|
|||||||
if ((!connection && !i->connection) ||
|
if ((!connection && !i->connection) ||
|
||||||
(connection && i->connection && strcmp(connection, i->connection) == 0)) {
|
(connection && i->connection && strcmp(connection, i->connection) == 0)) {
|
||||||
*lastptr = i->next;
|
*lastptr = i->next;
|
||||||
if (i->connection)
|
if (i->connection) {
|
||||||
free_current_memory(i->connection);
|
free_current_memory(i->connection);
|
||||||
|
}
|
||||||
free_current_memory(i->name);
|
free_current_memory(i->name);
|
||||||
free_current_memory(i);
|
free_current_memory(i);
|
||||||
return;
|
return;
|
||||||
|
@ -50,10 +50,10 @@ extern struct ECPGstruct_member* struct_member_list[STRUCT_DEPTH];
|
|||||||
extern const char* get_dtype(enum ECPGdtype);
|
extern const char* get_dtype(enum ECPGdtype);
|
||||||
extern void lex_init(void);
|
extern void lex_init(void);
|
||||||
extern void output_line_number(void);
|
extern void output_line_number(void);
|
||||||
extern void output_statement(char*, int, enum ECPG_statement_type);
|
extern void output_statement(char* stmt, int whenever_mode, enum ECPG_statement_type st);
|
||||||
extern void output_prepare_statement(char*, char*);
|
extern void output_prepare_statement(char* name, char* stmt);
|
||||||
extern void output_deallocate_prepare_statement(char*);
|
extern void output_deallocate_prepare_statement(char* name);
|
||||||
extern void output_simple_statement(char*);
|
extern void output_simple_statement(char* stmt);
|
||||||
extern char* hashline_number(void);
|
extern char* hashline_number(void);
|
||||||
extern int base_yyparse(void);
|
extern int base_yyparse(void);
|
||||||
extern int base_yylex(void);
|
extern int base_yylex(void);
|
||||||
@ -63,29 +63,30 @@ extern char* mm_strdup(const char*);
|
|||||||
extern void mmerror(int, enum errortype, const char*, ...)
|
extern void mmerror(int, enum errortype, const char*, ...)
|
||||||
/* This extension allows gcc to check the format string */
|
/* This extension allows gcc to check the format string */
|
||||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
|
||||||
extern void output_get_descr_header(char*);
|
extern void output_get_descr_header(char* desc_name);
|
||||||
extern void output_get_descr(char*, char*);
|
extern void output_get_descr(char* desc_name, char* index);
|
||||||
extern void output_set_descr_header(char*);
|
extern void output_set_descr_header(char* desc_name);
|
||||||
extern void output_set_descr(char*, char*);
|
extern void output_set_descr(char* desc_name, char* index);
|
||||||
extern void push_assignment(char*, enum ECPGdtype);
|
extern void push_assignment(char* var, enum ECPGdtype value);
|
||||||
extern struct variable* find_variable(char*);
|
extern struct variable* find_variable(char* name);
|
||||||
extern void whenever_action(int);
|
extern void whenever_action(int mode);
|
||||||
extern void add_descriptor(char*, char*);
|
extern void add_descriptor(char* name, char* connection);
|
||||||
extern void drop_descriptor(char*, char*);
|
extern void drop_descriptor(char* name, char* connection);
|
||||||
extern struct descriptor* lookup_descriptor(char*, char*);
|
extern struct descriptor* lookup_descriptor(char* name, char* connection);
|
||||||
extern struct variable* descriptor_variable(const char* name, int input);
|
extern struct variable* descriptor_variable(const char* name, int input);
|
||||||
extern struct variable* sqlda_variable(const char* name);
|
extern struct variable* sqlda_variable(const char* name);
|
||||||
extern void add_variable_to_head(struct arguments**, struct variable*, struct variable*);
|
extern void add_variable_to_head(struct arguments** list, struct variable* var, struct variable* ind);
|
||||||
extern void add_variable_to_tail(struct arguments**, struct variable*, struct variable*);
|
extern void add_variable_to_tail(struct arguments** list, struct variable* var, struct variable* ind);
|
||||||
extern void remove_variable_from_list(struct arguments** list, struct variable* var);
|
extern void remove_variable_from_list(struct arguments** list, struct variable* var);
|
||||||
extern void dump_variables(struct arguments*, int);
|
extern void dump_variables(struct arguments* list, int mode);
|
||||||
extern struct typedefs* get_typedef(char*);
|
extern struct typedefs* get_typedef(char* name);
|
||||||
extern void adjust_array(enum ECPGttype, char**, char**, char*, char*, int, bool);
|
extern void adjust_array(enum ECPGttype type_enum, char** dimension, char** length, char* type_dimension, char* type_index,
|
||||||
|
int pointer_len, bool type_definition);
|
||||||
extern void reset_variables(void);
|
extern void reset_variables(void);
|
||||||
extern void check_indicator(struct ECPGtype*);
|
extern void check_indicator(struct ECPGtype* var);
|
||||||
extern void remove_typedefs(int);
|
extern void remove_typedefs(int brace_level);
|
||||||
extern void remove_variables(int);
|
extern void remove_variables(int brace_level);
|
||||||
extern struct variable* new_variable(const char*, struct ECPGtype*, int);
|
extern struct variable* new_variable(const char* name, struct ECPGtype* type, int brace_level);
|
||||||
extern const ScanKeyword* ScanCKeywordLookup(const char*);
|
extern const ScanKeyword* ScanCKeywordLookup(const char*);
|
||||||
extern const ScanKeyword* ScanECPGKeywordLookup(const char* text);
|
extern const ScanKeyword* ScanECPGKeywordLookup(const char* text);
|
||||||
extern void scanner_init(const char*);
|
extern void scanner_init(const char*);
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
static void output_escaped_str(char* cmd, bool quoted);
|
static void output_escaped_str(char* str, bool quoted);
|
||||||
|
|
||||||
|
|
||||||
void output_line_number(void)
|
void output_line_number(void)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* src/interfaces/ecpg/preproc/type.c */
|
/* src/interfaces/ecpg/preproc/type.c */
|
||||||
|
|
||||||
#include "postgres_fe.h"
|
#include "postgres_fe.h"
|
||||||
|
#include "type.h"
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
#define indicator_set ind_type != NULL && ind_type->type != ECPGt_NO_INDICATOR
|
#define indicator_set ind_type != NULL && ind_type->type != ECPGt_NO_INDICATOR
|
||||||
@ -15,7 +15,6 @@ void insert_current_memory(void *ptr)
|
|||||||
{
|
{
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return;
|
return;
|
||||||
//printf("insert ptr =%p\n", ptr);
|
|
||||||
struct Current_memory *pcm = (struct Current_memory *)malloc(sizeof(struct Current_memory));
|
struct Current_memory *pcm = (struct Current_memory *)malloc(sizeof(struct Current_memory));
|
||||||
|
|
||||||
pcm->p = ptr;
|
pcm->p = ptr;
|
||||||
@ -28,22 +27,18 @@ void insert_current_memory(void *ptr)
|
|||||||
|
|
||||||
void free_current_memory(void *ptr)
|
void free_current_memory(void *ptr)
|
||||||
{
|
{
|
||||||
if(ptr == NULL)
|
if (ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//printf("free ptr =%p\n", ptr);
|
|
||||||
struct Current_memory *pcm = Currentmemoryused;
|
struct Current_memory *pcm = Currentmemoryused;
|
||||||
struct Current_memory *pfront = NULL;
|
struct Current_memory *pfront = NULL;
|
||||||
while(pcm)
|
while (pcm) {
|
||||||
{
|
if (pcm->p == ptr) {
|
||||||
if(pcm->p == ptr)
|
if (pfront)
|
||||||
{
|
|
||||||
if(pfront)
|
|
||||||
pfront->next = pcm->next;
|
pfront->next = pcm->next;
|
||||||
else
|
else
|
||||||
Currentmemoryused = pcm->next;
|
Currentmemoryused = pcm->next;
|
||||||
|
|
||||||
if(pcm->p)
|
if (pcm->p)
|
||||||
free(pcm->p);
|
free(pcm->p);
|
||||||
free(pcm);
|
free(pcm);
|
||||||
|
|
||||||
@ -55,8 +50,7 @@ void free_current_memory(void *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pcm = Currentmemoryused;
|
pcm = Currentmemoryused;
|
||||||
while(pcm)
|
while (pcm) {
|
||||||
{
|
|
||||||
printf("Currentmemoryused ptr =%p\n", pcm);
|
printf("Currentmemoryused ptr =%p\n", pcm);
|
||||||
pcm = pcm->next;
|
pcm = pcm->next;
|
||||||
}
|
}
|
||||||
@ -66,10 +60,7 @@ void free_current_memory(void *ptr)
|
|||||||
void free_current_memory_all()
|
void free_current_memory_all()
|
||||||
{
|
{
|
||||||
struct Current_memory *pcm = Currentmemoryused;
|
struct Current_memory *pcm = Currentmemoryused;
|
||||||
while(pcm)
|
while (pcm) {
|
||||||
{
|
|
||||||
//printf("free_current_memory_all ss num %d, %p\n",Currentmemoryused_num, pcm->p);
|
|
||||||
//fflush(stdout);
|
|
||||||
|
|
||||||
struct Current_memory *pfree = pcm;
|
struct Current_memory *pfree = pcm;
|
||||||
pcm = pcm->next;
|
pcm = pcm->next;
|
||||||
@ -80,8 +71,6 @@ void free_current_memory_all()
|
|||||||
--Currentmemoryused_num;
|
--Currentmemoryused_num;
|
||||||
}
|
}
|
||||||
Currentmemoryused = NULL;
|
Currentmemoryused = NULL;
|
||||||
//printf("free_current_memory_all num %d\n",Currentmemoryused_num);
|
|
||||||
//fflush(stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* malloc + error check */
|
/* malloc + error check */
|
||||||
@ -584,7 +573,7 @@ static void ECPGdump_a_simple(FILE* o, const char* name, enum ECPGttype type, ch
|
|||||||
if (atoi(arrsize) < 0)
|
if (atoi(arrsize) < 0)
|
||||||
strcpy(arrsize, "1");
|
strcpy(arrsize, "1");
|
||||||
|
|
||||||
if (siz == NULL || strlen(siz) == 0 )
|
if (siz == NULL || strlen(siz) == 0)
|
||||||
fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, offset);
|
fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, offset);
|
||||||
else
|
else
|
||||||
fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, siz);
|
fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, siz);
|
||||||
|
@ -13,8 +13,7 @@ struct ECPGstruct_member {
|
|||||||
struct ECPGstruct_member* next;
|
struct ECPGstruct_member* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Current_memory
|
struct Current_memory {
|
||||||
{
|
|
||||||
void *p;
|
void *p;
|
||||||
struct Current_memory *next;
|
struct Current_memory *next;
|
||||||
};
|
};
|
||||||
@ -37,18 +36,19 @@ struct ECPGtype {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Everything is malloced. */
|
/* Everything is malloced. */
|
||||||
void ECPGmake_struct_member(char*, struct ECPGtype*, struct ECPGstruct_member**);
|
void ECPGmake_struct_member(char* name, struct ECPGtype* type, struct ECPGstruct_member** start);
|
||||||
struct ECPGtype* ECPGmake_simple_type(enum ECPGttype, char*, int);
|
struct ECPGtype* ECPGmake_simple_type(enum ECPGttype type, char* size, int counter);
|
||||||
struct ECPGtype* ECPGmake_array_type(struct ECPGtype*, char*);
|
struct ECPGtype* ECPGmake_array_type(struct ECPGtype* type, char* size);
|
||||||
struct ECPGtype* ECPGmake_struct_type(struct ECPGstruct_member*, enum ECPGttype, char*, char*);
|
struct ECPGtype* ECPGmake_struct_type( struct ECPGstruct_member* rm, enum ECPGttype type, char* type_name, char* struct_sizeof);
|
||||||
struct ECPGstruct_member* ECPGstruct_member_dup(struct ECPGstruct_member*);
|
struct ECPGstruct_member* ECPGstruct_member_dup(struct ECPGstruct_member*);
|
||||||
|
|
||||||
/* Frees a type. */
|
/* Frees a type. */
|
||||||
void ECPGfree_struct_member(struct ECPGstruct_member*);
|
void ECPGfree_struct_member(struct ECPGstruct_member* rm);
|
||||||
void ECPGfree_type(struct ECPGtype*);
|
void ECPGfree_type(struct ECPGtype* type);
|
||||||
|
|
||||||
|
void insert_current_memory(void *ptr);
|
||||||
void free_current_memory(void *ptr);
|
void free_current_memory(void *ptr);
|
||||||
void free_current_memory_all();
|
void free_current_memory_all(void);
|
||||||
|
|
||||||
/* Dump a type.
|
/* Dump a type.
|
||||||
The type is dumped as:
|
The type is dumped as:
|
||||||
@ -60,8 +60,10 @@ void free_current_memory_all();
|
|||||||
size is the maxsize in case it is a varchar. Otherwise it is the size of
|
size is the maxsize in case it is a varchar. Otherwise it is the size of
|
||||||
the variable (required to do array fetches of structs).
|
the variable (required to do array fetches of structs).
|
||||||
*/
|
*/
|
||||||
void ECPGdump_a_type(FILE*, const char*, struct ECPGtype*, const int, const char*, struct ECPGtype*, const int,
|
void ECPGdump_a_type(FILE* o, const char* name, struct ECPGtype* type, const int brace_level, const char* ind_name,
|
||||||
const char*, const char*, char*, const char*, const char*);
|
struct ECPGtype* ind_type, const int ind_brace_level, const char* prefix, const char* ind_prefix, char* arr_str_siz,
|
||||||
|
const char* struct_sizeof, const char* ind_struct_sizeof);
|
||||||
|
|
||||||
|
|
||||||
/* A simple struct to keep a variable and its type. */
|
/* A simple struct to keep a variable and its type. */
|
||||||
struct ECPGtemp_type {
|
struct ECPGtemp_type {
|
||||||
|
@ -437,8 +437,9 @@ void dump_variables(struct arguments* list, int mode)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Then release the list element. */
|
/* Then release the list element. */
|
||||||
if (mode != 0)
|
if (mode != 0) {
|
||||||
free_current_memory(list);
|
free_current_memory(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_indicator(struct ECPGtype* var)
|
void check_indicator(struct ECPGtype* var)
|
||||||
|
Reference in New Issue
Block a user