return TRUE;
return FALSE;
}
+
+#ifdef UNICODE_SUPPORT
+enum {
+ ErrorOutConversionErrors /* error out conversion errors */
+ , ReturnZeroLengthString /* simply returns zero length strings */
+};
+static int convert_err_flag =
+#ifdef WIN32
+ ReturnZeroLengthString;
+#else
+ ErrorOutConversionErrors;
+#endif /* WIN32 */
+
+static BOOL
+handle_lu_onvert_error(QueryBuild *qb, int flag, char *buffer, SQLLEN paralen)
+{
+ int blen = paralen;
+
+ if (!buffer)
+ return FALSE;
+ if (get_mylog() > 0 || ReturnZeroLengthString != flag)
+ {
+ const UCHAR *buf = (UCHAR *) buffer;
+ int i;
+ PQExpBufferData pbuf = {0};
+
+ if (SQL_NTS == blen)
+ blen = strlen(buffer);
+ initPQExpBuffer(&pbuf);
+ appendPQExpBuffer(&pbuf, "Could not convert the current data '");
+ for (i = 0; i < blen; i++)
+ {
+ if (buf[i] >= 0x80)
+ appendPQExpBuffer(&pbuf, "\\%03o", buf[i]);
+ else if ('\\' == buf[i])
+ appendPQExpBuffer(&pbuf, "\\\\");
+ else
+ appendPQExpBuffer(&pbuf, "%c", buf[i]);
+ }
+ appendPQExpBuffer(&pbuf, "' to wide chars");
+ MYLOG(0, "%s\n", pbuf.data);
+ if (ReturnZeroLengthString != flag)
+ {
+ if (qb->stmt)
+ SC_set_error(qb->stmt, STMT_EXEC_ERROR, pbuf.data, __FUNCTION__);
+ else
+ qb->errormsg = "could not convert the current data to wide chars";
+ }
+ termPQExpBuffer(&pbuf);
+
+ }
+ switch (flag)
+ {
+ case ReturnZeroLengthString:
+ if (qb->stmt)
+ SC_set_error(qb->stmt, STMT_ERROR_IN_ROW, "conversion error to wide chars occured", __FUNCTION__);
+ return TRUE;
+ default:
+ qb->errornumber = STMT_EXEC_ERROR;
+ return FALSE;
+ }
+}
+#endif /* UNICODE_SUPPORT */
+
/*
* Resolve one parameter.
*
SIMPLE_TIME st;
struct tm *tim;
SQLLEN used;
- char *send_buf;
+ const char *send_buf;
char *buffer, *allocbuf = NULL, *lastadd = NULL;
OID lobj_oid;
#endif
}
- allocbuf = send_buf = NULL;
+ allocbuf = NULL;
+ send_buf = NULL;
param_string[0] = '\0';
cbuf[0] = '\0';
memset(&st, 0, sizeof(st));
case SQL_C_CHAR:
if (!same_encoding || wcs_debug)
{
+ SQLLEN paralen = used;
+
MYLOG(0, "locale param convert\n");
if ((used = bindpara_msg_to_utf8(buffer, &allocbuf, used)) < 0)
{
- qb->errormsg = "Could not convert from the current locale to wide characters";
- qb->errornumber = STMT_EXEC_ERROR;
- retval = SQL_ERROR;
- goto cleanup;
+ if (!handle_lu_onvert_error(qb, convert_err_flag, buffer, paralen))
+ goto cleanup;
+ send_buf = NULL_STRING;
+ used = 0;
}
- send_buf = allocbuf;
+ else
+ send_buf = allocbuf;
}
break;
case SQL_C_WCHAR:
{
qb->errormsg = "Could not convert from wide characters to the current locale";
qb->errornumber = STMT_EXEC_ERROR;
- retval = SQL_ERROR;
goto cleanup;
}
send_buf = allocbuf;
qb->errormsg = "Unrecognized C_parameter type in copy_statement_with_parameters";
qb->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
CVT_TERMINATE(qb); /* just in case */
- retval = SQL_ERROR;
goto cleanup;
}
case PG_TYPE_FLOAT8:
case PG_TYPE_NUMERIC:
if (NULL != send_buf)
- set_server_decimal_point(send_buf, used);
+ set_server_decimal_point((char *) send_buf, used);
break;
}
if (!send_buf)
default:
qb->errormsg = "Could not convert the ctype to binary type";
qb->errornumber = STMT_EXEC_ERROR;
- retval = SQL_ERROR;
goto cleanup;
}
if (param_pgtype == PG_TYPE_BYTEA)
{
qb->errormsg = "Could not convert binary other than LO type";
qb->errornumber = STMT_EXEC_ERROR;
- retval = SQL_ERROR;
goto cleanup;
}
{
qb->errormsg = "Could not begin (in-line) a transaction";
qb->errornumber = STMT_EXEC_ERROR;
- retval = SQL_ERROR;
goto cleanup;
}
}
{
qb->errornumber = STMT_EXEC_ERROR;
qb->errormsg = "Couldn't create (in-line) large object.";
- retval = SQL_ERROR;
goto cleanup;
}
{
qb->errornumber = STMT_EXEC_ERROR;
qb->errormsg = "Couldn't open (in-line) large object for writing.";
- retval = SQL_ERROR;
goto cleanup;
}
{
qb->errornumber = STMT_EXEC_ERROR;
qb->errormsg = "Couldn't write to (in-line) large object.";
- retval = SQL_ERROR;
goto cleanup;
}
{
qb->errormsg = "Could not commit (in-line) a transaction";
qb->errornumber = STMT_EXEC_ERROR;
- retval = SQL_ERROR;
goto cleanup;
}
}
/* must be quoted (0 or 1 is ok to use inside the quotes) */
case SQL_REAL:
- set_server_decimal_point(send_buf, used);
+ set_server_decimal_point((char *) send_buf, used);
lastadd = "::float4";
break;
case SQL_FLOAT:
case SQL_DOUBLE:
- set_server_decimal_point(send_buf, used);
+ set_server_decimal_point((char *) send_buf, used);
lastadd = "::float8";
break;
case SQL_NUMERIC: