Skip to content

Commit a1a2431

Browse files
committed
fix review comments per Cedric suggestions
1 parent bc5192b commit a1a2431

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/bin/psql/common.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3730,7 +3730,6 @@ SendQuery_PBE(const char *query, HostVariable *hv)
37303730
PGTransactionStatusType transaction_status;
37313731
double elapsed_msec = 0;
37323732
bool OK = false;
3733-
int i = 0;
37343733
bool on_error_rollback_savepoint = false;
37353734
static bool on_error_rollback_warning = false;
37363735

@@ -3837,7 +3836,6 @@ SendQuery_PBE(const char *query, HostVariable *hv)
38373836
struct _variable **bindvar;
38383837
char *p = NULL;
38393838
bool missing = false;
3840-
int j;
38413839
instr_time before,
38423840
after;
38433841

@@ -3851,13 +3849,13 @@ SendQuery_PBE(const char *query, HostVariable *hv)
38513849
* the order of detection in the Oracle error message is from the
38523850
* back to the front.
38533851
*/
3854-
for (j = hv->length; j > 0; j--)
3852+
for (int i = hv->length; i > 0; i--)
38553853
{
3856-
p = hv->hostvars[j - 1].name;
3854+
p = hv->hostvars[i - 1].name;
38573855
p++; /* skip colon */
3858-
bindvar[j - 1] = BindVariableExist(pset.vars, p);
3856+
bindvar[i - 1] = BindVariableExist(pset.vars, p);
38593857

3860-
if (bindvar[j - 1] == NULL)
3858+
if (bindvar[i - 1] == NULL)
38613859
{
38623860
missing= true;
38633861
break;
@@ -4039,7 +4037,7 @@ SendQuery_PBE(const char *query, HostVariable *hv)
40394037

40404038
/* reset \crosstabview trigger */
40414039
pset.crosstab_flag = false;
4042-
for (i = 0; i < lengthof(pset.ctv_args); i++)
4040+
for (int i = 0; i < lengthof(pset.ctv_args); i++)
40434041
{
40444042
pg_free(pset.ctv_args[i]);
40454043
pset.ctv_args[i] = NULL;

src/interfaces/libpq/ivy-exec.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,7 +3763,6 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
37633763
size_t size_error_buf,
37643764
bool *iscallinto)
37653765
{
3766-
int i = 0;
37673766
Ivyresult *res;
37683767
IvyBindOutNameInfo *tmp;
37693768

@@ -3787,7 +3786,7 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
37873786
char *convertcall = NULL;
37883787
char *newsql = NULL;
37893788
char *ptr = NULL;
3790-
int j = 0;
3789+
const char *query_ptr = NULL;
37913790

37923791
query_len = (stmtHandle->query_len * 2) + strlen("select * from get_parameter_description(") + 5;
37933792
query = (char *) malloc(query_len);
@@ -3800,12 +3799,14 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
38003799

38013800
newsql = malloc(stmtHandle->query_len * 2); /* enough */
38023801
ptr = newsql;
3803-
while (stmtHandle->query[j] != '\0')
3802+
query_ptr = stmtHandle->query;
3803+
3804+
while (*query_ptr != '\0')
38043805
{
3805-
if (stmtHandle->query[j] == '\'')
3806-
*ptr++ = stmtHandle->query[j];
3807-
*ptr++ = stmtHandle->query[j];
3808-
j++;
3806+
if (*query_ptr == '\'')
3807+
*ptr++ = *query_ptr;
3808+
*ptr++ = *query_ptr;
3809+
query_ptr++;
38093810
}
38103811
*ptr = '\0';
38113812

@@ -3965,14 +3966,14 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
39653966

39663967
stmtHandle->paramNames = (char **) malloc(sizeof(char *) * (n_tuples - 1));
39673968
memset(stmtHandle->paramNames, 0x00, sizeof(char *) * (n_tuples - 1));
3968-
for (j = 1; j < n_tuples; j++)
3969+
for (int i = 1; i < n_tuples; i++)
39693970
{
39703971
int position;
39713972
char *name;
39723973
size_t name_len;
39733974

3974-
position = atoi(Ivygetvalue(res, j, 1)) - 1;
3975-
name = Ivygetvalue(res, j, 0);
3975+
position = atoi(Ivygetvalue(res, i, 1)) - 1;
3976+
name = Ivygetvalue(res, i, 0);
39763977

39773978
if (stmtHandle->paramNames[position] != NULL)
39783979
goto error_handle;
@@ -4034,7 +4035,7 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
40344035
"get_parameter_description return failed");
40354036

40364037
Ivyclear(res);
4037-
for (i = 0; i < stmtHandle->nParams; i++)
4038+
for (int i = 0; i < stmtHandle->nParams; i++)
40384039
{
40394040
if (stmtHandle->paramNames[i] != NULL)
40404041
free(stmtHandle->paramNames[i]);
@@ -4073,7 +4074,7 @@ Ivyreplacenamebindtoposition2(Ivyconn *tconn,
40734074
char *newsql = NULL;
40744075
char *ptr = NULL;
40754076
const char *query_ptr = NULL;
4076-
4077+
40774078
query_len = (strlen(stmtHandle->query) * 2) + strlen("select * from get_parameter_description(") + 5;
40784079
query = (char *) malloc(query_len);
40794080

0 commit comments

Comments
 (0)