Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3535ebc

Browse files
Harmonize parameter names in ecpg code.
Make ecpg function declarations consistently use named parameters. Also make sure that the declarations use names that match corresponding names from function definitions. Like other recent commits that cleaned up function parameter names, this commit was written with help from clang-tidy. Author: Peter Geoghegan <pg@bowt.ie> Reviewed-By: David Rowley <dgrowleyml@gmail.com> Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
1 parent 163b099 commit 3535ebc

18 files changed

+271
-233
lines changed

src/interfaces/ecpg/ecpglib/ecpglib_extern.h

+47-31
Original file line numberDiff line numberDiff line change
@@ -172,52 +172,68 @@ bool ecpg_get_data(const PGresult *, int, int, int, enum ECPGttype type,
172172
#ifdef ENABLE_THREAD_SAFETY
173173
void ecpg_pthreads_init(void);
174174
#endif
175-
struct connection *ecpg_get_connection(const char *);
176-
char *ecpg_alloc(long, int);
177-
char *ecpg_auto_alloc(long, int);
178-
char *ecpg_realloc(void *, long, int);
179-
void ecpg_free(void *);
180-
bool ecpg_init(const struct connection *, const char *, const int);
181-
char *ecpg_strdup(const char *, int);
182-
const char *ecpg_type_name(enum ECPGttype);
183-
int ecpg_dynamic_type(Oid);
184-
int sqlda_dynamic_type(Oid, enum COMPAT_MODE);
175+
struct connection *ecpg_get_connection(const char *connection_name);
176+
char *ecpg_alloc(long size, int lineno);
177+
char *ecpg_auto_alloc(long size, int lineno);
178+
char *ecpg_realloc(void *ptr, long size, int lineno);
179+
void ecpg_free(void *ptr);
180+
bool ecpg_init(const struct connection *con,
181+
const char *connection_name,
182+
const int lineno);
183+
char *ecpg_strdup(const char *string, int lineno);
184+
const char *ecpg_type_name(enum ECPGttype typ);
185+
int ecpg_dynamic_type(Oid type);
186+
int sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat);
185187
void ecpg_clear_auto_mem(void);
186188

187189
struct descriptor *ecpg_find_desc(int line, const char *name);
188190

189-
struct prepared_statement *ecpg_find_prepared_statement(const char *,
190-
struct connection *, struct prepared_statement **);
191+
struct prepared_statement *ecpg_find_prepared_statement(const char *name,
192+
struct connection *con,
193+
struct prepared_statement **prev_);
191194

192195
bool ecpg_store_result(const PGresult *results, int act_field,
193196
const struct statement *stmt, struct variable *var);
194-
bool ecpg_store_input(const int, const bool, const struct variable *, char **, bool);
197+
bool ecpg_store_input(const int lineno, const bool force_indicator,
198+
const struct variable *var,
199+
char **tobeinserted_p, bool quote);
195200
void ecpg_free_params(struct statement *stmt, bool print);
196-
bool ecpg_do_prologue(int, const int, const int, const char *, const bool,
197-
enum ECPG_statement_type, const char *, va_list,
198-
struct statement **);
199-
bool ecpg_build_params(struct statement *);
201+
bool ecpg_do_prologue(int lineno, const int compat,
202+
const int force_indicator, const char *connection_name,
203+
const bool questionmarks, enum ECPG_statement_type statement_type,
204+
const char *query, va_list args,
205+
struct statement **stmt_out);
206+
bool ecpg_build_params(struct statement *stmt);
200207
bool ecpg_autostart_transaction(struct statement *stmt);
201208
bool ecpg_execute(struct statement *stmt);
202-
bool ecpg_process_output(struct statement *, bool);
203-
void ecpg_do_epilogue(struct statement *);
204-
bool ecpg_do(const int, const int, const int, const char *, const bool,
205-
const int, const char *, va_list);
206-
207-
bool ecpg_check_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
209+
bool ecpg_process_output(struct statement *stmt, bool clear_result);
210+
void ecpg_do_epilogue(struct statement *stmt);
211+
bool ecpg_do(const int lineno, const int compat,
212+
const int force_indicator, const char *connection_name,
213+
const bool questionmarks, const int st, const char *query,
214+
va_list args);
215+
216+
bool ecpg_check_PQresult(PGresult *results, int lineno,
217+
PGconn *connection, enum COMPAT_MODE compat);
208218
void ecpg_raise(int line, int code, const char *sqlstate, const char *str);
209219
void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
210-
char *ecpg_prepared(const char *, struct connection *);
211-
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *conn);
220+
char *ecpg_prepared(const char *name, struct connection *con);
221+
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *con);
212222
void ecpg_log(const char *format,...) pg_attribute_printf(1, 2);
213-
bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
214-
bool ecpg_register_prepared_stmt(struct statement *);
223+
bool ecpg_auto_prepare(int lineno, const char *connection_name,
224+
const int compat, char **name, const char *query);
225+
bool ecpg_register_prepared_stmt(struct statement *stmt);
215226
void ecpg_init_sqlca(struct sqlca_t *sqlca);
216227

217-
struct sqlda_compat *ecpg_build_compat_sqlda(int, PGresult *, int, enum COMPAT_MODE);
218-
void ecpg_set_compat_sqlda(int, struct sqlda_compat **, const PGresult *, int, enum COMPAT_MODE);
219-
struct sqlda_struct *ecpg_build_native_sqlda(int, PGresult *, int, enum COMPAT_MODE);
220-
void ecpg_set_native_sqlda(int, struct sqlda_struct **, const PGresult *, int, enum COMPAT_MODE);
228+
struct sqlda_compat *ecpg_build_compat_sqlda(int line, PGresult *res, int row,
229+
enum COMPAT_MODE compat);
230+
void ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda,
231+
const PGresult *res, int row,
232+
enum COMPAT_MODE compat);
233+
struct sqlda_struct *ecpg_build_native_sqlda(int line, PGresult *res, int row,
234+
enum COMPAT_MODE compat);
235+
void ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda,
236+
const PGresult *res, int row, enum COMPAT_MODE compat);
221237
unsigned ecpg_hex_dec_len(unsigned srclen);
222238
unsigned ecpg_hex_enc_len(unsigned srclen);
223239
unsigned ecpg_hex_encode(const char *src, unsigned len, char *dst);

src/interfaces/ecpg/include/ecpg_informix.h

+41-41
Original file line numberDiff line numberDiff line change
@@ -33,55 +33,55 @@ extern "C"
3333
{
3434
#endif
3535

36-
extern int rdatestr(date, char *);
37-
extern void rtoday(date *);
38-
extern int rjulmdy(date, short *);
39-
extern int rdefmtdate(date *, const char *, const char *);
40-
extern int rfmtdate(date, const char *, char *);
41-
extern int rmdyjul(short *, date *);
42-
extern int rstrdate(const char *, date *);
43-
extern int rdayofweek(date);
36+
extern int rdatestr(date d, char *str);
37+
extern void rtoday(date * d);
38+
extern int rjulmdy(date d, short *mdy);
39+
extern int rdefmtdate(date * d, const char *fmt, const char *str);
40+
extern int rfmtdate(date d, const char *fmt, char *str);
41+
extern int rmdyjul(short *mdy, date * d);
42+
extern int rstrdate(const char *str, date * d);
43+
extern int rdayofweek(date d);
4444

45-
extern int rfmtlong(long, const char *, char *);
46-
extern int rgetmsg(int, char *, int);
47-
extern int risnull(int, const char *);
48-
extern int rsetnull(int, char *);
49-
extern int rtypalign(int, int);
50-
extern int rtypmsize(int, int);
51-
extern int rtypwidth(int, int);
52-
extern void rupshift(char *);
45+
extern int rfmtlong(long lng_val, const char *fmt, char *outbuf);
46+
extern int rgetmsg(int msgnum, char *s, int maxsize);
47+
extern int risnull(int t, const char *ptr);
48+
extern int rsetnull(int t, char *ptr);
49+
extern int rtypalign(int offset, int type);
50+
extern int rtypmsize(int type, int len);
51+
extern int rtypwidth(int sqltype, int sqllen);
52+
extern void rupshift(char *str);
5353

54-
extern int byleng(char *, int);
55-
extern void ldchar(char *, int, char *);
54+
extern int byleng(char *str, int len);
55+
extern void ldchar(char *src, int len, char *dest);
5656

57-
extern void ECPG_informix_set_var(int, void *, int);
58-
extern void *ECPG_informix_get_var(int);
57+
extern void ECPG_informix_set_var(int number, void *pointer, int lineno);
58+
extern void *ECPG_informix_get_var(int number);
5959
extern void ECPG_informix_reset_sqlca(void);
6060

6161
/* Informix defines these in decimal.h */
62-
int decadd(decimal *, decimal *, decimal *);
63-
int deccmp(decimal *, decimal *);
64-
void deccopy(decimal *, decimal *);
65-
int deccvasc(const char *, int, decimal *);
66-
int deccvdbl(double, decimal *);
67-
int deccvint(int, decimal *);
68-
int deccvlong(long, decimal *);
69-
int decdiv(decimal *, decimal *, decimal *);
70-
int decmul(decimal *, decimal *, decimal *);
71-
int decsub(decimal *, decimal *, decimal *);
72-
int dectoasc(decimal *, char *, int, int);
73-
int dectodbl(decimal *, double *);
74-
int dectoint(decimal *, int *);
75-
int dectolong(decimal *, long *);
62+
int decadd(decimal *arg1, decimal *arg2, decimal *sum);
63+
int deccmp(decimal *arg1, decimal *arg2);
64+
void deccopy(decimal *src, decimal *target);
65+
int deccvasc(const char *cp, int len, decimal *np);
66+
int deccvdbl(double dbl, decimal *np);
67+
int deccvint(int in, decimal *np);
68+
int deccvlong(long lng, decimal *np);
69+
int decdiv(decimal *n1, decimal *n2, decimal *result);
70+
int decmul(decimal *n1, decimal *n2, decimal *result);
71+
int decsub(decimal *n1, decimal *n2, decimal *result);
72+
int dectoasc(decimal *np, char *cp, int len, int right);
73+
int dectodbl(decimal *np, double *dblp);
74+
int dectoint(decimal *np, int *ip);
75+
int dectolong(decimal *np, long *lngp);
7676

7777
/* Informix defines these in datetime.h */
78-
extern void dtcurrent(timestamp *);
79-
extern int dtcvasc(char *, timestamp *);
80-
extern int dtsub(timestamp *, timestamp *, interval *);
81-
extern int dttoasc(timestamp *, char *);
82-
extern int dttofmtasc(timestamp *, char *, int, char *);
83-
extern int intoasc(interval *, char *);
84-
extern int dtcvfmtasc(char *, char *, timestamp *);
78+
extern void dtcurrent(timestamp * ts);
79+
extern int dtcvasc(char *str, timestamp * ts);
80+
extern int dtsub(timestamp * ts1, timestamp * ts2, interval * iv);
81+
extern int dttoasc(timestamp * ts, char *output);
82+
extern int dttofmtasc(timestamp * ts, char *output, int str_len, char *fmtstr);
83+
extern int intoasc(interval * i, char *str);
84+
extern int dtcvfmtasc(char *inbuf, char *fmtstr, timestamp * dtvalue);
8585

8686
#ifdef __cplusplus
8787
}

src/interfaces/ecpg/include/ecpglib.h

+33-27
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,24 @@ extern "C"
4949
{
5050
#endif
5151

52-
void ECPGdebug(int, FILE *);
53-
bool ECPGstatus(int, const char *);
54-
bool ECPGsetcommit(int, const char *, const char *);
55-
bool ECPGsetconn(int, const char *);
56-
bool ECPGconnect(int, int, const char *, const char *, const char *, const char *, int);
57-
bool ECPGdo(const int, const int, const int, const char *, const bool, const int, const char *,...);
58-
bool ECPGtrans(int, const char *, const char *);
59-
bool ECPGdisconnect(int, const char *);
60-
bool ECPGprepare(int, const char *, const bool, const char *, const char *);
61-
bool ECPGdeallocate(int, int, const char *, const char *);
62-
bool ECPGdeallocate_all(int, int, const char *);
63-
char *ECPGprepared_statement(const char *, const char *, int);
64-
PGconn *ECPGget_PGconn(const char *);
65-
PGTransactionStatusType ECPGtransactionStatus(const char *);
52+
void ECPGdebug(int n, FILE *dbgs);
53+
bool ECPGstatus(int lineno, const char *connection_name);
54+
bool ECPGsetcommit(int lineno, const char *mode, const char *connection_name);
55+
bool ECPGsetconn(int lineno, const char *connection_name);
56+
bool ECPGconnect(int lineno, int c, const char *name, const char *user,
57+
const char *passwd, const char *connection_name, int autocommit);
58+
bool ECPGdo(const int lineno, const int compat, const int force_indicator,
59+
const char *connection_name, const bool questionmarks,
60+
const int st, const char *query,...);
61+
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction);
62+
bool ECPGdisconnect(int lineno, const char *connection_name);
63+
bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks,
64+
const char *name, const char *variable);
65+
bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name);
66+
bool ECPGdeallocate_all(int lineno, int compat, const char *connection_name);
67+
char *ECPGprepared_statement(const char *connection_name, const char *name, int lineno);
68+
PGconn *ECPGget_PGconn(const char *connection_name);
69+
PGTransactionStatusType ECPGtransactionStatus(const char *connection_name);
6670

6771
/* print an error message */
6872
void sqlprint(void);
@@ -74,19 +78,21 @@ void sqlprint(void);
7478

7579
/* dynamic SQL */
7680

77-
bool ECPGdo_descriptor(int, const char *, const char *, const char *);
78-
bool ECPGdeallocate_desc(int, const char *);
79-
bool ECPGallocate_desc(int, const char *);
80-
bool ECPGget_desc_header(int, const char *, int *);
81-
bool ECPGget_desc(int, const char *, int,...);
82-
bool ECPGset_desc_header(int, const char *, int);
83-
bool ECPGset_desc(int, const char *, int,...);
84-
85-
void ECPGset_noind_null(enum ECPGttype, void *);
86-
bool ECPGis_noind_null(enum ECPGttype, const void *);
87-
bool ECPGdescribe(int, int, bool, const char *, const char *,...);
88-
89-
void ECPGset_var(int, void *, int);
81+
bool ECPGdo_descriptor(int line, const char *connection,
82+
const char *descriptor, const char *query);
83+
bool ECPGdeallocate_desc(int line, const char *name);
84+
bool ECPGallocate_desc(int line, const char *name);
85+
bool ECPGget_desc_header(int lineno, const char *desc_name, int *count);
86+
bool ECPGget_desc(int lineno, const char *desc_name, int index,...);
87+
bool ECPGset_desc_header(int lineno, const char *desc_name, int count);
88+
bool ECPGset_desc(int lineno, const char *desc_name, int index,...);
89+
90+
void ECPGset_noind_null(enum ECPGttype type, void *ptr);
91+
bool ECPGis_noind_null(enum ECPGttype type, const void *ptr);
92+
bool ECPGdescribe(int line, int compat, bool input,
93+
const char *connection_name, const char *stmt_name,...);
94+
95+
void ECPGset_var(int number, void *pointer, int lineno);
9096
void *ECPGget_var(int number);
9197

9298
/* dynamic result allocation */

src/interfaces/ecpg/include/pgtypes_date.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ extern "C"
1414
#endif
1515

1616
extern date * PGTYPESdate_new(void);
17-
extern void PGTYPESdate_free(date *);
18-
extern date PGTYPESdate_from_asc(char *, char **);
19-
extern char *PGTYPESdate_to_asc(date);
20-
extern date PGTYPESdate_from_timestamp(timestamp);
21-
extern void PGTYPESdate_julmdy(date, int *);
22-
extern void PGTYPESdate_mdyjul(int *, date *);
23-
extern int PGTYPESdate_dayofweek(date);
24-
extern void PGTYPESdate_today(date *);
25-
extern int PGTYPESdate_defmt_asc(date *, const char *, const char *);
26-
extern int PGTYPESdate_fmt_asc(date, const char *, char *);
17+
extern void PGTYPESdate_free(date * d);
18+
extern date PGTYPESdate_from_asc(char *str, char **endptr);
19+
extern char *PGTYPESdate_to_asc(date dDate);
20+
extern date PGTYPESdate_from_timestamp(timestamp dt);
21+
extern void PGTYPESdate_julmdy(date jd, int *mdy);
22+
extern void PGTYPESdate_mdyjul(int *mdy, date * jdate);
23+
extern int PGTYPESdate_dayofweek(date dDate);
24+
extern void PGTYPESdate_today(date * d);
25+
extern int PGTYPESdate_defmt_asc(date * d, const char *fmt, const char *str);
26+
extern int PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf);
2727

2828
#ifdef __cplusplus
2929
}

src/interfaces/ecpg/include/pgtypes_interval.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ extern "C"
3636
#endif
3737

3838
extern interval * PGTYPESinterval_new(void);
39-
extern void PGTYPESinterval_free(interval *);
40-
extern interval * PGTYPESinterval_from_asc(char *, char **);
41-
extern char *PGTYPESinterval_to_asc(interval *);
42-
extern int PGTYPESinterval_copy(interval *, interval *);
39+
extern void PGTYPESinterval_free(interval *intvl);
40+
extern interval * PGTYPESinterval_from_asc(char *str, char **endptr);
41+
extern char *PGTYPESinterval_to_asc(interval *span);
42+
extern int PGTYPESinterval_copy(interval *intvlsrc, interval *intvldest);
4343

4444
#ifdef __cplusplus
4545
}

src/interfaces/ecpg/include/pgtypes_numeric.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,24 @@ extern "C"
4343

4444
numeric *PGTYPESnumeric_new(void);
4545
decimal *PGTYPESdecimal_new(void);
46-
void PGTYPESnumeric_free(numeric *);
47-
void PGTYPESdecimal_free(decimal *);
48-
numeric *PGTYPESnumeric_from_asc(char *, char **);
49-
char *PGTYPESnumeric_to_asc(numeric *, int);
50-
int PGTYPESnumeric_add(numeric *, numeric *, numeric *);
51-
int PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
52-
int PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
53-
int PGTYPESnumeric_div(numeric *, numeric *, numeric *);
54-
int PGTYPESnumeric_cmp(numeric *, numeric *);
55-
int PGTYPESnumeric_from_int(signed int, numeric *);
56-
int PGTYPESnumeric_from_long(signed long int, numeric *);
57-
int PGTYPESnumeric_copy(numeric *, numeric *);
58-
int PGTYPESnumeric_from_double(double, numeric *);
59-
int PGTYPESnumeric_to_double(numeric *, double *);
60-
int PGTYPESnumeric_to_int(numeric *, int *);
61-
int PGTYPESnumeric_to_long(numeric *, long *);
62-
int PGTYPESnumeric_to_decimal(numeric *, decimal *);
63-
int PGTYPESnumeric_from_decimal(decimal *, numeric *);
46+
void PGTYPESnumeric_free(numeric *var);
47+
void PGTYPESdecimal_free(decimal *var);
48+
numeric *PGTYPESnumeric_from_asc(char *str, char **endptr);
49+
char *PGTYPESnumeric_to_asc(numeric *num, int dscale);
50+
int PGTYPESnumeric_add(numeric *var1, numeric *var2, numeric *result);
51+
int PGTYPESnumeric_sub(numeric *var1, numeric *var2, numeric *result);
52+
int PGTYPESnumeric_mul(numeric *var1, numeric *var2, numeric *result);
53+
int PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result);
54+
int PGTYPESnumeric_cmp(numeric *var1, numeric *var2);
55+
int PGTYPESnumeric_from_int(signed int int_val, numeric *var);
56+
int PGTYPESnumeric_from_long(signed long int long_val, numeric *var);
57+
int PGTYPESnumeric_copy(numeric *src, numeric *dst);
58+
int PGTYPESnumeric_from_double(double d, numeric *dst);
59+
int PGTYPESnumeric_to_double(numeric *nv, double *dp);
60+
int PGTYPESnumeric_to_int(numeric *nv, int *ip);
61+
int PGTYPESnumeric_to_long(numeric *nv, long *lp);
62+
int PGTYPESnumeric_to_decimal(numeric *src, decimal *dst);
63+
int PGTYPESnumeric_from_decimal(decimal *src, numeric *dst);
6464

6565
#ifdef __cplusplus
6666
}

src/interfaces/ecpg/include/pgtypes_timestamp.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ extern "C"
1515
{
1616
#endif
1717

18-
extern timestamp PGTYPEStimestamp_from_asc(char *, char **);
19-
extern char *PGTYPEStimestamp_to_asc(timestamp);
20-
extern int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *);
21-
extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, const char *);
22-
extern void PGTYPEStimestamp_current(timestamp *);
23-
extern int PGTYPEStimestamp_defmt_asc(const char *, const char *, timestamp *);
18+
extern timestamp PGTYPEStimestamp_from_asc(char *str, char **endptr);
19+
extern char *PGTYPEStimestamp_to_asc(timestamp tstamp);
20+
extern int PGTYPEStimestamp_sub(timestamp * ts1, timestamp * ts2, interval * iv);
21+
extern int PGTYPEStimestamp_fmt_asc(timestamp * ts, char *output, int str_len, const char *fmtstr);
22+
extern void PGTYPEStimestamp_current(timestamp * ts);
23+
extern int PGTYPEStimestamp_defmt_asc(const char *str, const char *fmt, timestamp * d);
2424
extern int PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout);
2525
extern int PGTYPEStimestamp_sub_interval(timestamp * tin, interval * span, timestamp * tout);
2626

0 commit comments

Comments
 (0)