Skip to content

Commit 148f43e

Browse files
authored
Merge pull request IvorySQL#993 from bigplaice/clean_warning
Clean build warning and fix "invalid zero OID reference in pg_type.dat" issue
2 parents b1caefd + 6b23023 commit 148f43e

File tree

11 files changed

+85
-62
lines changed

11 files changed

+85
-62
lines changed

contrib/uuid-ossp/uuid-ossp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,15 @@ Datum
562562
ora_sys_guid(PG_FUNCTION_ARGS)
563563
{
564564
bytea *result;
565+
#ifdef HAVE_UUID_OSSP
566+
uuid_t *uuid;
567+
uuid_rc_t rc;
568+
#endif
569+
565570
result = (bytea *)palloc(VARHDRSZ + SYS_GUID_LENGTH);
566571
SET_VARSIZE(result, VARHDRSZ + SYS_GUID_LENGTH);
567572

568573
#ifdef HAVE_UUID_OSSP
569-
uuid_t *uuid;
570-
uuid_rc_t rc;
571574
uuid = get_cached_uuid_t(0);
572575
rc = uuid_make(uuid, UUID_MAKE_V4, NULL, NULL);
573576
if (rc != UUID_RC_OK) {
@@ -589,4 +592,4 @@ ora_sys_guid(PG_FUNCTION_ARGS)
589592
memcpy(VARDATA(result), byte_array, SYS_GUID_LENGTH);
590593
#endif
591594
PG_RETURN_BYTEA_P(result);
592-
}
595+
}

src/backend/catalog/genbki.pl

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,10 +1118,27 @@ sub lookup_oids
11181118
push @lookupoids, $lookupname;
11191119
if ($lookupname eq '-' or $lookupname eq '0')
11201120
{
1121-
warn sprintf
1122-
"invalid zero OID reference in %s.dat field %s line %s\n",
1123-
$catname, $attname, $bki_values->{line_number}
1124-
if !$lookup_opt;
1121+
if (defined($bki_values->{type_name})
1122+
and $bki_values->{type_name} ne 'oracharchar'
1123+
and $bki_values->{type_name} ne 'oracharbyte'
1124+
and $bki_values->{type_name} ne 'oravarcharchar'
1125+
and $bki_values->{type_name} ne 'oravarcharbyte'
1126+
and $bki_values->{type_name} ne 'oradate'
1127+
and $bki_values->{type_name} ne 'oratimestamp'
1128+
and $bki_values->{type_name} ne 'oratimestamptz'
1129+
and $bki_values->{type_name} ne 'oratimestampltz'
1130+
and $bki_values->{type_name} ne 'yminterval'
1131+
and $bki_values->{type_name} ne 'dsinterval'
1132+
and $bki_values->{type_name} ne 'number'
1133+
and $bki_values->{type_name} ne 'binary_float'
1134+
and $bki_values->{type_name} ne 'binary_double'
1135+
)
1136+
{
1137+
warn sprintf
1138+
"invalid zero OID reference in %s.dat field %s line %s\n",
1139+
$catname, $attname, $bki_values->{line_number}
1140+
if !$lookup_opt;
1141+
}
11251142
}
11261143
else
11271144
{

src/backend/utils/adt/arrayfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ ReadArrayDimensions(char **srcptr, int *ndim_p, int *dim, int *lBound,
465465
if (!ReadDimensionInt(&p, &ub, origStr, escontext))
466466
return false;
467467
if (p == q) /* no digits? */
468-
return(escontext, false,
468+
ereturn(escontext, false,
469469
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
470470
errmsg("malformed array literal: \"%s\"", origStr),
471471
errdetail("Missing array dimension value.")));

src/backend/utils/adt/ruleutils.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14410,7 +14410,7 @@ pg_get_function_arg_reference_typerowtype_internal(Tuplestorestate **tupstore,
1441014410
{
1441114411
RangeVar *rel = makeRangeVar(NULL, NULL, typeName->location);
1441214412
char *field = NULL;
14413-
Oid relid;
14413+
Oid relid_1;
1441414414
AttrNumber attnum;
1441514415

1441614416
/* deconstruct the name list */
@@ -14447,12 +14447,12 @@ pg_get_function_arg_reference_typerowtype_internal(Tuplestorestate **tupstore,
1444714447
break;
1444814448
}
1444914449

14450-
relid = RangeVarGetRelid(rel, NoLock, true);
14451-
attnum = get_attnum(relid, field);
14450+
relid_1 = RangeVarGetRelid(rel, NoLock, true);
14451+
attnum = get_attnum(relid_1, field);
1445214452

1445314453
if (attnum != InvalidAttrNumber)
1445414454
{
14455-
get_atttypetypmodcoll(relid, attnum,
14455+
get_atttypetypmodcoll(relid_1, attnum,
1445614456
&fieldTypeId, &fieldTypMod, &fieldCollation);
1445714457

1445814458
/* this construct should never have an array indicator */

src/bin/psql/common.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,7 +3601,7 @@ get_hostvariables(const char *sql, bool *error)
36013601
HostVariable *host = NULL;
36023602
char *newsql = NULL;
36033603
char *ptr = NULL;
3604-
int i = 0;
3604+
int j = 0;
36053605

36063606
*error = false;
36073607
if (!sql)
@@ -3610,12 +3610,12 @@ get_hostvariables(const char *sql, bool *error)
36103610
/* double write quote */
36113611
newsql = pg_malloc0(strlen(sql) * 2); /* enough */
36123612
ptr = newsql;
3613-
while (sql[i] != '\0')
3613+
while (sql[j] != '\0')
36143614
{
3615-
if (sql[i] == '\'')
3616-
*ptr++ = sql[i];
3617-
*ptr++ = sql[i];
3618-
i++;
3615+
if (sql[j] == '\'')
3616+
*ptr++ = sql[j];
3617+
*ptr++ = sql[j];
3618+
j++;
36193619
}
36203620
*ptr = '\0';
36213621

@@ -3695,7 +3695,7 @@ SendQuery_PBE(const char *query, HostVariable *hv)
36953695
PGTransactionStatusType transaction_status;
36963696
double elapsed_msec = 0;
36973697
bool OK = false;
3698-
int i;
3698+
int i = 0;
36993699
bool on_error_rollback_savepoint = false;
37003700
static bool on_error_rollback_warning = false;
37013701

@@ -3802,7 +3802,7 @@ SendQuery_PBE(const char *query, HostVariable *hv)
38023802
struct _variable **bindvar;
38033803
char *p = NULL;
38043804
bool missing = false;
3805-
int i;
3805+
int j;
38063806
instr_time before,
38073807
after;
38083808

@@ -3816,13 +3816,13 @@ SendQuery_PBE(const char *query, HostVariable *hv)
38163816
* the order of detection in the Oracle error message is from the
38173817
* back to the front.
38183818
*/
3819-
for (i = hv->length; i > 0; i--)
3819+
for (j = hv->length; j > 0; j--)
38203820
{
3821-
p = hv->hostvars[i - 1].name;
3821+
p = hv->hostvars[j - 1].name;
38223822
p++; /* skip colon */
3823-
bindvar[i - 1] = BindVariableExist(pset.vars, p);
3823+
bindvar[j - 1] = BindVariableExist(pset.vars, p);
38243824

3825-
if (bindvar[i - 1] == NULL)
3825+
if (bindvar[j - 1] == NULL)
38263826
{
38273827
missing= true;
38283828
break;

src/fe_utils/string_utils.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,16 @@ getFmtEncoding(void)
104104
const char *
105105
fmtIdEnc(const char *rawid, int encoding)
106106
{
107-
if (DB_ORACLE == db_mode)
108-
return ora_fmtId(rawid);
109-
110-
PQExpBuffer id_return = getLocalPQExpBuffer();
111-
107+
PQExpBuffer id_return;
112108
const char *cp;
113109
bool need_quotes = false;
114110
size_t remaining = strlen(rawid);
115111

112+
if (DB_ORACLE == db_mode)
113+
return ora_fmtId(rawid);
114+
115+
id_return = getLocalPQExpBuffer();
116+
116117
/*
117118
* These checks need to match the identifier production in scan.l. Don't
118119
* use islower() etc.

src/interfaces/libpq/ivy-exec.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,10 @@ IvyreplaceParamTypeByOutParameter(IvyBindOutInfo *bindinfo, int nParams, Oid *pa
29972997
static Ivylist*
29982998
IvyaddValueToList(Ivylist *list, void *value)
29992999
{
3000+
Ivylist *pre = NULL;
3001+
Ivylist *tmp = NULL;
3002+
int find = 0;
3003+
30003004
if (list == NULL)
30013005
{
30023006
Ivylist *new = (Ivylist *) malloc(sizeof(Ivylist));
@@ -3014,10 +3018,6 @@ IvyaddValueToList(Ivylist *list, void *value)
30143018
return new;
30153019
}
30163020

3017-
Ivylist *pre = NULL;
3018-
Ivylist *tmp = NULL;
3019-
int find = 0;
3020-
30213021
for (tmp = list, pre = list; tmp != NULL; pre = tmp, tmp = tmp->next)
30223022
{
30233023
if (tmp->value == value)
@@ -3763,7 +3763,7 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
37633763
size_t size_error_buf,
37643764
bool *iscallinto)
37653765
{
3766-
int i;
3766+
int i = 0;
37673767
Ivyresult *res;
37683768
IvyBindOutNameInfo *tmp;
37693769

@@ -3787,7 +3787,7 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
37873787
char *convertcall = NULL;
37883788
char *newsql = NULL;
37893789
char *ptr = NULL;
3790-
int i = 0;
3790+
int j = 0;
37913791

37923792
query_len = (stmtHandle->query_len * 2) + strlen("select * from get_parameter_description(") + 5;
37933793
query = (char *) malloc(query_len);
@@ -3800,12 +3800,12 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
38003800

38013801
newsql = malloc(stmtHandle->query_len * 2); /* enough */
38023802
ptr = newsql;
3803-
while (stmtHandle->query[i] != '\0')
3803+
while (stmtHandle->query[j] != '\0')
38043804
{
3805-
if (stmtHandle->query[i] == '\'')
3806-
*ptr++ = stmtHandle->query[i];
3807-
*ptr++ = stmtHandle->query[i];
3808-
i++;
3805+
if (stmtHandle->query[j] == '\'')
3806+
*ptr++ = stmtHandle->query[j];
3807+
*ptr++ = stmtHandle->query[j];
3808+
j++;
38093809
}
38103810
*ptr = '\0';
38113811

@@ -3965,14 +3965,14 @@ Ivyreplacenamebindtoposition(Ivyconn *tconn,
39653965

39663966
stmtHandle->paramNames = (char **) malloc(sizeof(char *) * (n_tuples - 1));
39673967
memset(stmtHandle->paramNames, 0x00, sizeof(char *) * (n_tuples - 1));
3968-
for (i = 1; i < n_tuples; i++)
3968+
for (j = 1; j < n_tuples; j++)
39693969
{
39703970
int position;
39713971
char *name;
39723972
size_t name_len;
39733973

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

39773977
if (stmtHandle->paramNames[position] != NULL)
39783978
goto error_handle;
@@ -4055,9 +4055,9 @@ Ivyreplacenamebindtoposition2(Ivyconn *tconn,
40554055
IvyPreparedStatement *stmtHandle,
40564056
IvyError *errhp)
40574057
{
4058-
int i;
40594058
Ivyresult *res;
40604059
IvyBindNameInfo *tmp;
4060+
int i = 0;
40614061

40624062
if (stmtHandle->paramNames == NULL)
40634063
{
@@ -4072,7 +4072,7 @@ Ivyreplacenamebindtoposition2(Ivyconn *tconn,
40724072
char *convertcall = NULL;
40734073
char *newsql = NULL;
40744074
char *ptr = NULL;
4075-
int i = 0;
4075+
int j = 0;
40764076

40774077
query_len = (strlen(stmtHandle->query) * 2) + strlen("select * from get_parameter_description(") + 5;
40784078
query = (char *) malloc(query_len);
@@ -4086,12 +4086,12 @@ Ivyreplacenamebindtoposition2(Ivyconn *tconn,
40864086

40874087
newsql = malloc(strlen(stmtHandle->query) * 2); /* enough */
40884088
ptr = newsql;
4089-
while (stmtHandle->query[i] != '\0')
4089+
while (stmtHandle->query[j] != '\0')
40904090
{
4091-
if (stmtHandle->query[i] == '\'')
4092-
*ptr++ = stmtHandle->query[i];
4093-
*ptr++ = stmtHandle->query[i];
4094-
i++;
4091+
if (stmtHandle->query[j] == '\'')
4092+
*ptr++ = stmtHandle->query[j];
4093+
*ptr++ = stmtHandle->query[j];
4094+
j++;
40954095
}
40964096
*ptr = '\0';
40974097

@@ -4233,14 +4233,14 @@ Ivyreplacenamebindtoposition2(Ivyconn *tconn,
42334233
stmtHandle->paramNames = (char **) malloc(sizeof(char *) * (n_tuples - 1));
42344234
stmtHandle->nParams = n_tuples - 1;
42354235
memset(stmtHandle->paramNames, 0x00, sizeof(char *) * (n_tuples - 1));
4236-
for (i = 1; i < n_tuples; i++)
4236+
for (j = 1; j < n_tuples; j++)
42374237
{
42384238
int position;
42394239
char *name;
42404240
size_t name_len;
42414241

4242-
position = atoi(Ivygetvalue(res, i, 1)) - 1;
4243-
name = Ivygetvalue(res, i, 0);
4242+
position = atoi(Ivygetvalue(res, j, 1)) - 1;
4243+
name = Ivygetvalue(res, j, 0);
42444244

42454245
if (stmtHandle->paramNames[position] != NULL)
42464246
goto error_handle;

src/pl/plisql/src/pl_comp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,21 +1095,21 @@ do_compile(FunctionCallInfo fcinfo,
10951095
* and the function returned datatype.
10961096
*
10971097
*/
1098-
char **argtypenames = NULL;
1099-
char *rettypename = NULL;
1098+
argtypenames = NULL;
1099+
rettypename = NULL;
11001100

11011101
get_func_typename_info(procTup, &argtypenames, &rettypename);
11021102
if (argtypenames != NULL)
11031103
{
1104-
int i = 0;
1104+
int j = 0;
11051105

1106-
for (i = 0; i < procStruct->pronargs; i++)
1106+
for (j = 0; j < procStruct->pronargs; j++)
11071107
{
1108-
if (strcmp(argtypenames[i], "") != 0)
1108+
if (strcmp(argtypenames[j], "") != 0)
11091109
{
11101110
TypeName *typeName;
11111111

1112-
typeName = (TypeName *) stringToNode(argtypenames[i]);
1112+
typeName = (TypeName *) stringToNode(argtypenames[j]);
11131113
plisql_add_type_referenced_objects(typeName);
11141114
}
11151115
}

src/pl/plisql/src/pl_handler.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ _PG_init(void)
225225
/*
226226
* Cleanup: deregister internal routines.
227227
*/
228+
void _PG_fini(void);
229+
228230
void
229231
_PG_fini(void)
230232
{

src/pl/plisql/src/pl_scanner.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static int plisql_yyleng;
118118
/* Current token's code (corresponds to plisql_yylval and plisql_yylloc) */
119119
static int plisql_yytoken;
120120

121-
static yyscan_t plisql_scanner;
121+
//static yyscan_t plisql_scanner;
122122

123123
/* The semantic value of the lookahead symbol. */
124124
static YYSTYPE plisql_yylval;
@@ -140,7 +140,7 @@ static TokenAuxData pushback_auxdata[MAX_PUSHBACKS];
140140
/* State for plisql_location_to_lineno() */
141141
static const char *cur_line_start;
142142
static const char *cur_line_end;
143-
static int cur_line_num;
143+
//static int cur_line_num;
144144

145145
/*
146146
* yylex used global variable in pl_scanner.c

0 commit comments

Comments
 (0)