Skip to content

Commit

Permalink
Assorted fixes and improvements for the recent patches, release 0.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurenz Albe committed Jun 25, 2012
1 parent 369f492 commit 14c4dbc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version 0.9.6 (beta)
Version 0.9.6 (beta), released 2012-06-25
Enhancements:
- Support Oracle types LONG and LONG RAW.
Introduce table option "max_long" (default 32767) to set the maximal
Expand Down
6 changes: 3 additions & 3 deletions README.oracle_fdw
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ Foreign table options
- max_long (optional, defaults to "32767")

The maximal length of any LONG or LONG RAW columns in the Oracle table.
Possible values are integers between 1 and 2147483642. This amount of
memory will be allocated at least twice, so large values will consume a lot
of memory.
Possible values are integers between 1 and 1073741823 (the maximal size of a
bytea in PostgreSQL). This amount of memory will be allocated at least
twice, so large values will consume a lot of memory.
If "max_long" is less than the length of the longest value retrieved,
you will receive the error message "ORA-01406: fetched column value was
truncated".
Expand Down
6 changes: 3 additions & 3 deletions oracle_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ oracle_fdw_validator(PG_FUNCTION_ARGS)
char *val = ((Value *) (def->arg))->val.str;
char *endptr;
unsigned long max_long = strtoul(val, &endptr, 0);
if (val[0] == '\0' || *endptr != '\0' || max_long < 1 || max_long > 2147483642ul)
if (val[0] == '\0' || *endptr != '\0' || max_long < 1 || max_long > 1073741823ul)
ereport(ERROR,
(errcode(ERRCODE_FDW_INVALID_ATTRIBUTE_VALUE),
errmsg("invalid value for option \"%s\"", def->defname),
errhint("Valid values in this context are integers between 1 and 2147483642")));
errhint("Valid values in this context are integers between 1 and 1073741823")));
}
}

Expand Down Expand Up @@ -2572,7 +2572,7 @@ struct OracleFdwState
state->oraTable->cols[i]->val_size = deserializeLong(lfirst(cell));
cell = lnext(cell);
/* allocate memory for the result value */
state->oraTable->cols[i]->val = (char *)palloc(state->oraTable->cols[i]->val_size);
state->oraTable->cols[i]->val = (char *)palloc(state->oraTable->cols[i]->val_size + 1);
state->oraTable->cols[i]->val_len = 0;
state->oraTable->cols[i]->val_null = 1;
}
Expand Down
20 changes: 10 additions & 10 deletions oracle_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct oracleSession
static void setOracleEnvironment(char *nls_lang);
static void oracleQueryPlan(oracleSession *session, const char *query, const char *desc_query, int nres, dvoid **res, sb4 *res_size, ub2 *res_type, ub2 *res_len, sb2 *res_ind);
static sword checkerr(sword status, dvoid *handle, ub4 handleType);
static char *copyOraText(const OraText *string, ub4 size, int quote);
static char *copyOraText(const OraText *string, int size, int quote);
static void closeSession(OCIEnv *envhp, OCIServer *srvhp, OCISession *userhp, int disconnect);
static void disconnectServer(OCIEnv *envhp, OCIServer *srvhp);
static void removeEnvironment(OCIEnv *envhp);
Expand Down Expand Up @@ -708,7 +708,7 @@ struct oraTable
oraMessage);
}

name = copyOraText(ident, ident_size, 1);
name = copyOraText(ident, (int)ident_size, 1);

/* referenced table schema */
if (checkerr(
Expand All @@ -721,7 +721,7 @@ struct oraTable
oraMessage);
}

schema = copyOraText(ident, ident_size, 1);
schema = copyOraText(ident, (int)ident_size, 1);

/* referenced table database link */
if (checkerr(
Expand All @@ -734,7 +734,7 @@ struct oraTable
oraMessage);
}

link = copyOraText(ident, ident_size, 0);
link = copyOraText(ident, (int)ident_size, 0);

/* construct a table name for the next lookup */
synonym_len = strlen(name);
Expand Down Expand Up @@ -861,7 +861,7 @@ struct oraTable
oraMessage);
}

reply->cols[i-1]->name = copyOraText(ident, ident_size, 1);
reply->cols[i-1]->name = copyOraText(ident, (int)ident_size, 1);

/* get the data type */
if (checkerr(
Expand Down Expand Up @@ -1029,12 +1029,12 @@ struct oraTable
case SQLT_LBI:
/* LONG RAW */
reply->cols[i-1]->oratype = ORA_TYPE_LONGRAW;
reply->cols[i-1]->val_size = max_long + 5;
reply->cols[i-1]->val_size = max_long + 4;
break;
case SQLT_LNG:
/* LONG */
reply->cols[i-1]->oratype = ORA_TYPE_LONG;
reply->cols[i-1]->val_size = max_long + 5;
reply->cols[i-1]->val_size = max_long + 4;
break;
case SQLT_BIN:
/* RAW(n) */
Expand Down Expand Up @@ -1911,15 +1911,15 @@ checkerr(sword status, dvoid *handle, ub4 handleType)
* Returns a palloc'ed string containing a (possibly quoted) copy of "string".
*/
char
*copyOraText(const OraText *string, ub4 size, int quote)
*copyOraText(const OraText *string, int size, int quote)
{
int resultsize = (quote ? size + 2 : size);
register int i, j=-1;
char *result;

if (quote)
{
for (i=0; i<(int)size; ++i)
for (i=0; i<size; ++i)
{
if (string[i] == '"')
++resultsize;
Expand All @@ -1929,7 +1929,7 @@ char
result = oracleAlloc(resultsize + 1);
if (quote)
result[++j] = '"';
for (i=0; i<(int)size; ++i)
for (i=0; i<size; ++i)
{
result[++j] = string[i];
if (quote && string[i] == '"')
Expand Down

0 comments on commit 14c4dbc

Please sign in to comment.