Commit 7a9c074c authored by Michael Meskes's avatar Michael Meskes

- Added some Informix error codes in Informix mode.

- Added just another pgtypeslib function.
parent 83f62e9d
......@@ -1595,6 +1595,11 @@ Thu Jul 24 10:33:51 CEST 2003
Fri Jul 25 18:08:18 CEST 2003
- Added explicit casts for date/timestamp/interval.
Fri Aug 1 08:54:02 CEST 2003
- Added some Informix error codes in Informix mode.
- Added just another pgtypeslib function.
- Set ecpg version to 3.0.0
- Set ecpg library to 4.0.0
- Set pgtypes library to 1.0.0
......
......@@ -823,7 +823,7 @@ rtypwidth(int sqltype, int sqllen)
int
dtcvfmtasc (char *inbuf, char *fmtstr, dtime_t *dtvalue)
{
return 0;
return PGTYPEStimestamp_defmt_asc(inbuf, fmtstr, dtvalue);
}
static struct var_list
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.12 2003/07/15 12:38:38 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.13 2003/08/01 08:21:04 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -116,7 +116,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
{
if ((results = PQexec(con->connection, "begin transaction")) == NULL)
{
ECPGraise(lineno, ECPG_TRANS, NULL);
ECPGraise(lineno, ECPG_TRANS, NULL, ECPG_COMPAT_PGSQL);
return false;
}
PQclear(results);
......@@ -130,7 +130,7 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
{
if ((results = PQexec(con->connection, "commit")) == NULL)
{
ECPGraise(lineno, ECPG_TRANS, NULL);
ECPGraise(lineno, ECPG_TRANS, NULL, ECPG_COMPAT_PGSQL);
return false;
}
PQclear(results);
......@@ -406,7 +406,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (strncmp(dbname, "unix:", 5) != 0)
{
ECPGlog("connect: socketname %s given for TCP connection in line %d\n", host, lineno);
ECPGraise(lineno, ECPG_CONNECT, realname ? realname : "<DEFAULT>");
ECPGraise(lineno, ECPG_CONNECT, realname ? realname : "<DEFAULT>", ECPG_COMPAT_PGSQL);
if (host)
ECPGfree(host);
if (port)
......@@ -429,7 +429,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (strcmp(dbname + offset, "localhost") != 0 && strcmp(dbname + offset, "127.0.0.1") != 0)
{
ECPGlog("connect: non-localhost access via sockets in line %d\n", lineno);
ECPGraise(lineno, ECPG_CONNECT, realname ? realname : "<DEFAULT>");
ECPGraise(lineno, ECPG_CONNECT, realname ? realname : "<DEFAULT>", ECPG_COMPAT_PGSQL);
if (host)
ECPGfree(host);
if (port)
......@@ -497,7 +497,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
user ? "for user " : "", user ? user : "",
lineno, errmsg);
ECPGraise(lineno, ECPG_CONNECT, db);
ECPGraise(lineno, ECPG_CONNECT, db, ECPG_COMPAT_PGSQL);
if (host)
ECPGfree(host);
if (port)
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.13 2003/07/18 14:32:56 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.14 2003/08/01 08:21:04 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -34,7 +34,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
{
if (*pval != '{')
{
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, NULL);
ECPGraise(lineno, ECPG_DATA_NOT_ARRAY, NULL, compat);
return (false);
}
......@@ -90,13 +90,13 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
else
{
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL);
ECPGraise(lineno, ECPG_MISSING_INDICATOR, NULL, compat);
return (false);
}
}
break;
default:
ECPGraise(lineno, ECPG_UNSUPPORTED, ECPGtype_name(ind_type));
ECPGraise(lineno, ECPG_UNSUPPORTED, ECPGtype_name(ind_type), compat);
return (false);
break;
}
......@@ -126,7 +126,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_INT_FORMAT, pval);
ECPGraise(lineno, ECPG_INT_FORMAT, pval, compat);
return (false);
}
}
......@@ -159,7 +159,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_UINT_FORMAT, pval);
ECPGraise(lineno, ECPG_UINT_FORMAT, pval, compat);
return (false);
}
}
......@@ -192,7 +192,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_INT_FORMAT, pval);
ECPGraise(lineno, ECPG_INT_FORMAT, pval, compat);
return (false);
}
}
......@@ -209,7 +209,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_UINT_FORMAT, pval);
ECPGraise(lineno, ECPG_UINT_FORMAT, pval, compat);
return (false);
}
}
......@@ -235,7 +235,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_FLOAT_FORMAT, pval);
ECPGraise(lineno, ECPG_FLOAT_FORMAT, pval, compat);
return (false);
}
}
......@@ -266,7 +266,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
else if (offset == sizeof(int))
*((int *) (var + offset * act_tuple)) = false;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size");
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size", compat);
break;
}
else if (pval[0] == 't' && pval[1] == '\0')
......@@ -276,7 +276,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
else if (offset == sizeof(int))
*((int *) (var + offset * act_tuple)) = true;
else
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size");
ECPGraise(lineno, ECPG_CONVERT_BOOL, "different size", compat);
break;
}
else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
......@@ -286,7 +286,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
}
}
ECPGraise(lineno, ECPG_CONVERT_BOOL, pval);
ECPGraise(lineno, ECPG_CONVERT_BOOL, pval, compat);
return (false);
break;
......@@ -396,7 +396,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_NUMERIC_FORMAT, pval);
ECPGraise(lineno, ECPG_NUMERIC_FORMAT, pval, compat);
return (false);
}
}
......@@ -423,7 +423,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_INTERVAL_FORMAT, pval);
ECPGraise(lineno, ECPG_INTERVAL_FORMAT, pval, compat);
return (false);
}
}
......@@ -446,7 +446,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_DATE_FORMAT, pval);
ECPGraise(lineno, ECPG_DATE_FORMAT, pval, compat);
return (false);
}
......@@ -468,7 +468,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if ((isarray && *scan_length != ',' && *scan_length != '}')
|| (!isarray && *scan_length != '\0' && *scan_length != ' ')) /* Garbage left */
{
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, pval);
ECPGraise(lineno, ECPG_TIMESTAMP_FORMAT, pval, compat);
return (false);
}
......@@ -477,7 +477,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
break;
default:
ECPGraise(lineno, ECPG_UNSUPPORTED, ECPGtype_name(type));
ECPGraise(lineno, ECPG_UNSUPPORTED, ECPGtype_name(type), compat);
return (false);
break;
}
......
/* dynamic SQL support routines
*
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.3 2003/06/15 04:07:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.4 2003/08/01 08:21:04 meskes Exp $
*/
#define POSTGRES_ECPG_INTERNAL
......@@ -103,7 +103,7 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
*(double *) var = (double) value;
break;
default:
ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, NULL);
ECPGraise(lineno, ECPG_VAR_NOT_NUMERIC, NULL, ECPG_COMPAT_PGSQL);
return (false);
}
......@@ -135,7 +135,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
}
break;
default:
ECPGraise(lineno, ECPG_VAR_NOT_CHAR, NULL);
ECPGraise(lineno, ECPG_VAR_NOT_CHAR, NULL, ECPG_COMPAT_PGSQL);
return (false);
}
......@@ -162,13 +162,13 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
ntuples = PQntuples(ECPGresult);
if (ntuples < 1)
{
ECPGraise(lineno, ECPG_NOT_FOUND, NULL);
ECPGraise(lineno, ECPG_NOT_FOUND, NULL, ECPG_COMPAT_PGSQL);
return (false);
}
if (index < 1 || index > PQnfields(ECPGresult))
{
ECPGraise(lineno, ECPG_INVALID_DESCRIPTOR_INDEX, NULL);
ECPGraise(lineno, ECPG_INVALID_DESCRIPTOR_INDEX, NULL, ECPG_COMPAT_PGSQL);
return (false);
}
......@@ -300,7 +300,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
{
ECPGlog("ECPGget_desc line %d: Incorrect number of matches: %d don't fit into array of %d\n",
lineno, ntuples, arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL, ECPG_COMPAT_PGSQL);
return false;
}
/* allocate storage if needed */
......@@ -324,7 +324,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
default:
snprintf(type_str, sizeof(type_str), "%d", type);
ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, type_str);
ECPGraise(lineno, ECPG_UNKNOWN_DESCRIPTOR_ITEM, type_str, ECPG_COMPAT_PGSQL);
return (false);
}
......@@ -361,7 +361,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
{
ECPGlog("ECPGget_desc line %d: Incorrect number of matches (indicator): %d don't fit into array of %d\n",
lineno, ntuples, data_var.ind_arrsize);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL);
ECPGraise(lineno, ECPG_TOO_MANY_MATCHES, NULL, ECPG_COMPAT_PGSQL);
return false;
}
/* allocate storage if needed */
......@@ -404,7 +404,7 @@ ECPGdeallocate_desc(int line, const char *name)
return true;
}
}
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, name);
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, name, ECPG_COMPAT_PGSQL);
return false;
}
......@@ -430,7 +430,7 @@ ECPGallocate_desc(int line, const char *name)
{
ECPGfree(new->name);
ECPGfree(new);
ECPGraise(line, ECPG_OUT_OF_MEMORY, NULL);
ECPGraise(line, ECPG_OUT_OF_MEMORY, NULL, ECPG_COMPAT_PGSQL);
return false;
}
strcpy(new->name, name);
......@@ -449,7 +449,7 @@ ECPGdescriptor_lvalue(int line, const char *descriptor)
return &i->result;
}
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, (char *) descriptor);
ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, (char *) descriptor, ECPG_COMPAT_PGSQL);
return NULL;
}
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.3 2003/07/15 12:38:38 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.4 2003/08/01 08:21:04 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -12,7 +12,7 @@
#include "sqlca.h"
void
ECPGraise(int line, int code, const char *str)
ECPGraise(int line, int code, const char *str, int compat)
{
struct sqlca_t *sqlca = ECPGget_sqlca();
sqlca->sqlcode = code;
......@@ -139,9 +139,9 @@ ECPGraise(int line, int code, const char *str)
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
"'%.*s' in line %d.", slen, str, line);
if (strncmp(str, "ERROR: Cannot insert a duplicate key", strlen("ERROR: Cannot insert a duplicate key")) == 0)
sqlca->sqlcode = ECPG_DUPLICATE_KEY;
sqlca->sqlcode = INFORMIX_MODE(compat) ? ECPG_INFORMIX_DUPLICATE_KEY : ECPG_DUPLICATE_KEY;
else if (strncmp(str, "ERROR: More than one tuple returned by a subselect", strlen("ERROR: More than one tuple returned by a subselect")) == 0)
sqlca->sqlcode = ECPG_SUBSELECT_NOT_ONE;
sqlca->sqlcode = INFORMIX_MODE(compat) ? ECPG_INFORMIX_SUBSELECT_NOT_ONE : ECPG_SUBSELECT_NOT_ONE;
break;
}
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.20 2003/07/25 16:10:26 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.21 2003/08/01 08:21:04 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
......@@ -124,7 +124,7 @@ create_statement(int lineno, int compat, int force_indicator, struct connection
/* if variable is NULL, the statement hasn't been prepared */
if (var->pointer == NULL)
{
ECPGraise(lineno, ECPG_INVALID_STMT, NULL);
ECPGraise(lineno, ECPG_INVALID_STMT, NULL, compat);
ECPGfree(var);
return false;
}
......@@ -351,7 +351,7 @@ ECPGstore_result(const PGresult *results, int act_field,
{
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
stmt->lineno, ntuples, var->arrsize);
ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL);
ECPGraise(stmt->lineno, ECPG_TOO_MANY_MATCHES, NULL, ECPG_COMPAT_PGSQL);
return false;
}
}
......@@ -362,7 +362,7 @@ ECPGstore_result(const PGresult *results, int act_field,
*/
if (var->arrsize == 0)
{
ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL);
ECPGraise(stmt->lineno, ECPG_NO_ARRAY, NULL, ECPG_COMPAT_PGSQL);
return false;
}
}
......@@ -484,7 +484,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
/* if (var->arrsize > 1 && ...)
{
ECPGraise(stmt->lineno, ECPG_ARRAY_INSERT, NULL);
ECPGraise(stmt->lineno, ECPG_ARRAY_INSERT, NULL, compat);
return false;
}*/
......@@ -757,7 +757,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
for (element = 0; element < var->arrsize; element++)
sprintf(mallocedval + strlen(mallocedval), "%c,", (((int *) var->value)[element]) ? 't' : 'f');
else
ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size");
ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size", ECPG_COMPAT_PGSQL);
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
}
......@@ -768,7 +768,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
else if (var->offset == sizeof(int))
sprintf(mallocedval, "'%c'", (*((int *) var->value)) ? 't' : 'f');
else
ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size");
ECPGraise(stmt->lineno, ECPG_CONVERT_BOOL, "different size", ECPG_COMPAT_PGSQL);
}
*tobeinserted_p = mallocedval;
......@@ -1021,7 +1021,7 @@ ECPGstore_input(const struct statement * stmt, const struct variable * var,
default:
/* Not implemented yet */
ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type));
ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *) ECPGtype_name(var->type), ECPG_COMPAT_PGSQL);
return false;
break;
}
......@@ -1073,7 +1073,7 @@ ECPGexecute(struct statement * stmt)
* We have an argument but we dont have the matched up string
* in the string
*/
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, NULL);
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, NULL, stmt->compat);
return false;
}
else
......@@ -1111,7 +1111,7 @@ ECPGexecute(struct statement * stmt)
/* Check if there are unmatched things left. */
if (next_insert(copiedquery) != NULL)
{
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL);
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL, stmt->compat);
return false;
}
......@@ -1121,7 +1121,7 @@ ECPGexecute(struct statement * stmt)
{
if ((results = PQexec(stmt->connection->connection, "begin transaction")) == NULL)
{
ECPGraise(stmt->lineno, ECPG_TRANS, NULL);
ECPGraise(stmt->lineno, ECPG_TRANS, NULL, stmt->compat);
return false;
}
PQclear(results);
......@@ -1136,7 +1136,7 @@ ECPGexecute(struct statement * stmt)
{
errmsg = PQerrorMessage(stmt->connection->connection);
ECPGlog("ECPGexecute line %d: error: %s", stmt->lineno, errmsg);
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg);
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg, stmt->compat);
}
else
......@@ -1167,7 +1167,7 @@ ECPGexecute(struct statement * stmt)
if (ntuples)
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
stmt->lineno, ntuples);
ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL);
ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL, stmt->compat);
status = false;
break;
}
......@@ -1198,21 +1198,21 @@ ECPGexecute(struct statement * stmt)
}
else if (!INFORMIX_MODE(stmt->compat))
{
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL);
ECPGraise(stmt->lineno, ECPG_TOO_FEW_ARGUMENTS, NULL, stmt->compat);
return (false);
}
}
if (status && var != NULL)
{
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, NULL);
ECPGraise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS, NULL, stmt->compat);
status = false;
}
break;
case PGRES_EMPTY_QUERY:
/* do nothing */
ECPGraise(stmt->lineno, ECPG_EMPTY, NULL);
ECPGraise(stmt->lineno, ECPG_EMPTY, NULL, stmt->compat);
break;
case PGRES_COMMAND_OK:
status = true;
......@@ -1225,13 +1225,13 @@ ECPGexecute(struct statement * stmt)
( !strncmp(cmdstat, "UPDATE", 6)
|| !strncmp(cmdstat, "INSERT", 6)
|| !strncmp(cmdstat, "DELETE", 6)))
ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL);
ECPGraise(stmt->lineno, ECPG_NOT_FOUND, NULL, stmt->compat);
break;
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
case PGRES_BAD_RESPONSE:
ECPGlog("ECPGexecute line %d: Error: %s", stmt->lineno, errmsg);
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg);
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg, stmt->compat);
status = false;
break;
case PGRES_COPY_OUT:
......@@ -1245,7 +1245,7 @@ ECPGexecute(struct statement * stmt)
default:
ECPGlog("ECPGexecute line %d: Got something else, postgres error.\n",
stmt->lineno);
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg);
ECPGraise(stmt->lineno, ECPG_PGSQL, errmsg, stmt->compat);
status = false;
break;
}
......@@ -1300,7 +1300,7 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name,
if (con == NULL || con->connection == NULL)
{
free_statement(stmt);
ECPGraise(lineno, ECPG_NOT_CONN, (con) ? con->name : "<empty>");
ECPGraise(lineno, ECPG_NOT_CONN, (con) ? con->name : "<empty>", stmt->compat);
setlocale(LC_NUMERIC, oldlocale);
ECPGfree(oldlocale);
return false;
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.2 2003/06/15 04:07:58 momjian Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/memory.c,v 1.3 2003/08/01 08:21:04 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -21,7 +21,7 @@ ECPGalloc(long size, int lineno)
if (!new)
{
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL, ECPG_COMPAT_PGSQL);
return NULL;
}
......@@ -36,7 +36,7 @@ ECPGrealloc(void *ptr, long size, int lineno)
if (!new)
{
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL, ECPG_COMPAT_PGSQL);
return NULL;
}
......@@ -50,7 +50,7 @@ ECPGstrdup(const char *string, int lineno)
if (!new)
{
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL);
ECPGraise(lineno, ECPG_OUT_OF_MEMORY, NULL, ECPG_COMPAT_PGSQL);
return NULL;
}
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.10 2003/07/17 07:54:29 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.11 2003/08/01 08:21:04 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -103,7 +103,7 @@ ECPGinit(const struct connection * con, const char *connection_name, const int l
ECPGinit_sqlca(sqlca);
if (con == NULL)
{
ECPGraise(lineno, ECPG_NO_CONN, connection_name ? connection_name : "NULL");
ECPGraise(lineno, ECPG_NO_CONN, connection_name ? connection_name : "NULL", ECPG_COMPAT_PGSQL);
return (false);
}
......@@ -150,7 +150,7 @@ ECPGstatus(int lineno, const char *connection_name)
/* are we connected? */
if (con->connection == NULL)
{
ECPGraise(lineno, ECPG_NOT_CONN, con->name);
ECPGraise(lineno, ECPG_NOT_CONN, con->name, ECPG_COMPAT_PGSQL);
return false;
}
......@@ -179,7 +179,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
{
if ((res = PQexec(con->connection, transaction)) == NULL)
{
ECPGraise(lineno, ECPG_TRANS, NULL);
ECPGraise(lineno, ECPG_TRANS, NULL, ECPG_COMPAT_PGSQL);
return FALSE;
}
PQclear(res);
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.6 2003/07/14 10:16:44 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.7 2003/08/01 08:21:04 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
......@@ -120,7 +120,7 @@ ECPGdeallocate(int lineno, int c, char *name)
}
if (!ret)
ECPGraise(lineno, ECPG_INVALID_STMT, name);
ECPGraise(lineno, ECPG_INVALID_STMT, name, ECPG_COMPAT_PGSQL);
return ret;
}
......
......@@ -50,6 +50,11 @@
#define ECPG_DUPLICATE_KEY -403
#define ECPG_SUBSELECT_NOT_ONE -404
/* for compatibility we define some different error codes for the same error
* if adding a new one make sure to not double define it */
#define ECPG_INFORMIX_DUPLICATE_KEY -239
#define ECPG_INFORMIX_SUBSELECT_NOT_ONE -284
/* backend WARNINGs, starting at 600 */
#define ECPG_WARNING_UNRECOGNIZED -600
/* WARNING: (transaction aborted): queries ignored until END */
......
......@@ -71,7 +71,7 @@ bool ECPGdo_descriptor(int line, const char *connection,
const char *descriptor, const char *query);
bool ECPGdeallocate_desc(int line, const char *name);
bool ECPGallocate_desc(int line, const char *name);
void ECPGraise(int line, int code, const char *str);
void ECPGraise(int line, int code, const char *str, int);
bool ECPGget_desc_header(int, char *, int *);
bool ECPGget_desc(int, char *, int,...);
......
......@@ -17,6 +17,6 @@ extern char *PGTYPEStimestamp_to_asc(Timestamp);
extern int PGTYPEStimestamp_sub (Timestamp *, Timestamp *, Interval *);
extern int PGTYPEStimestamp_fmt_asc (Timestamp *, char *, int, char *);
extern void PGTYPEStimestamp_current (Timestamp *);
extern int PGTYPEStimestamp_defmt_asc(char *, char *, Timestamp *);
#endif /* PGTYPES_TIMESTAMP */
......@@ -28,33 +28,33 @@ pgtypes_strdup(char *str)
}
int
pgtypes_fmt_replace(union un_fmt_replace replace_val, int replace_type, char** output, int *pstr_len) {
pgtypes_fmt_replace(union un_fmt_comb replace_val, int replace_type, char** output, int *pstr_len) {
/* general purpose variable, set to 0 in order to fix compiler
* warning */
int i = 0;
switch(replace_type) {
case PGTYPES_REPLACE_NOTHING:
case PGTYPES_TYPE_NOTHING:
break;
case PGTYPES_REPLACE_STRING_CONSTANT:
case PGTYPES_REPLACE_STRING_MALLOCED:
i = strlen(replace_val.replace_str);
case PGTYPES_TYPE_STRING_CONSTANT:
case PGTYPES_TYPE_STRING_MALLOCED:
i = strlen(replace_val.str_val);
if (i + 1 <= *pstr_len) {
/* copy over i + 1 bytes, that includes the
* tailing terminator */
strncpy(*output, replace_val.replace_str, i + 1);
strncpy(*output, replace_val.str_val, i + 1);
*pstr_len -= i;
*output += i;
if (replace_type == PGTYPES_REPLACE_STRING_MALLOCED) {
free(replace_val.replace_str);
if (replace_type == PGTYPES_TYPE_STRING_MALLOCED) {
free(replace_val.str_val);
}
return 0;
} else {
return -1;
}
break;
case PGTYPES_REPLACE_CHAR:
case PGTYPES_TYPE_CHAR:
if (*pstr_len >= 2) {
(*output)[0] = replace_val.replace_char;
(*output)[0] = replace_val.char_val;
(*output)[1] = '\0';
(*pstr_len)--;
(*output)++;
......@@ -63,48 +63,48 @@ pgtypes_fmt_replace(union un_fmt_replace replace_val, int replace_type, char** o
return -1;
}
break;
case PGTYPES_REPLACE_DOUBLE_NF:
case PGTYPES_REPLACE_INT64:
case PGTYPES_REPLACE_UINT:
case PGTYPES_REPLACE_UINT_2_LZ:
case PGTYPES_REPLACE_UINT_2_LS:
case PGTYPES_REPLACE_UINT_3_LZ:
case PGTYPES_REPLACE_UINT_4_LZ:
case PGTYPES_TYPE_DOUBLE_NF:
case PGTYPES_TYPE_INT64:
case PGTYPES_TYPE_UINT:
case PGTYPES_TYPE_UINT_2_LZ:
case PGTYPES_TYPE_UINT_2_LS:
case PGTYPES_TYPE_UINT_3_LZ:
case PGTYPES_TYPE_UINT_4_LZ:
{
char* t = pgtypes_alloc(PGTYPES_FMT_NUM_MAX_DIGITS);
if (!t) {
return ENOMEM;
}
switch (replace_type) {
case PGTYPES_REPLACE_DOUBLE_NF:
case PGTYPES_TYPE_DOUBLE_NF:
i = snprintf(t, PGTYPES_FMT_NUM_MAX_DIGITS,
"%0.0g", replace_val.replace_double);
"%0.0g", replace_val.double_val);
break;
#ifdef HAVE_INT6
case PGTYPES_REPLACE_INT64:
case PGTYPES_TYPE_INT64:
i = snprintf(t, PGTYPES_FMT_NUM_MAX_DIGITS,
INT64_FORMAT, replace_val.replace_int64);
break;
#endif
case PGTYPES_REPLACE_UINT:
case PGTYPES_TYPE_UINT:
i = snprintf(t, PGTYPES_FMT_NUM_MAX_DIGITS,
"%u", replace_val.replace_uint);
"%u", replace_val.uint_val);
break;
case PGTYPES_REPLACE_UINT_2_LZ:
case PGTYPES_TYPE_UINT_2_LZ:
i = snprintf(t, PGTYPES_FMT_NUM_MAX_DIGITS,
"%02u", replace_val.replace_uint);
"%02u", replace_val.uint_val);
break;
case PGTYPES_REPLACE_UINT_2_LS:
case PGTYPES_TYPE_UINT_2_LS:
i = snprintf(t, PGTYPES_FMT_NUM_MAX_DIGITS,
"%2u", replace_val.replace_uint);
"%2u", replace_val.uint_val);
break;
case PGTYPES_REPLACE_UINT_3_LZ:
case PGTYPES_TYPE_UINT_3_LZ:
i = snprintf(t, PGTYPES_FMT_NUM_MAX_DIGITS,
"%03u", replace_val.replace_uint);
"%03u", replace_val.uint_val);
break;
case PGTYPES_REPLACE_UINT_4_LZ:
case PGTYPES_TYPE_UINT_4_LZ:
i = snprintf(t, PGTYPES_FMT_NUM_MAX_DIGITS,
"%04u", replace_val.replace_uint);
"%04u", replace_val.uint_val);
break;
}
......
......@@ -168,10 +168,7 @@ PGTYPESdate_fmt_asc(Date dDate, char* fmtstring, char* outbuf) {
{ NULL, 0 }
};
union {
char* replace_str;
unsigned int replace_uint;
} replace_val;
union un_fmt_comb replace_val;
int replace_type;
int i;
......@@ -191,76 +188,76 @@ PGTYPESdate_fmt_asc(Date dDate, char* fmtstring, char* outbuf) {
while ((start_pattern = strstr(outbuf, mapping[i].format)) != NULL) {
switch(mapping[i].component) {
case PGTYPES_FMTDATE_DOW_LITERAL_SHORT:
replace_val.replace_str = pgtypes_date_weekdays_short[dow];
replace_type = PGTYPES_REPLACE_STRING_CONSTANT;
replace_val.str_val = pgtypes_date_weekdays_short[dow];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
case PGTYPES_FMTDATE_DAY_DIGITS_LZ:
replace_val.replace_uint = tm.tm_mday;
replace_type = PGTYPES_REPLACE_UINT_2_LZ;
replace_val.uint_val = tm.tm_mday;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
case PGTYPES_FMTDATE_MONTH_LITERAL_SHORT:
replace_val.replace_str = months[tm.tm_mon-1];
replace_type = PGTYPES_REPLACE_STRING_CONSTANT;
replace_val.str_val = months[tm.tm_mon-1];
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
break;
case PGTYPES_FMTDATE_MONTH_DIGITS_LZ:
replace_val.replace_uint = tm.tm_mon;
replace_type = PGTYPES_REPLACE_UINT_2_LZ;
replace_val.uint_val = tm.tm_mon;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
case PGTYPES_FMTDATE_YEAR_DIGITS_LONG:
replace_val.replace_uint = tm.tm_year;
replace_type = PGTYPES_REPLACE_UINT_4_LZ;
replace_val.uint_val = tm.tm_year;
replace_type = PGTYPES_TYPE_UINT_4_LZ;
break;
case PGTYPES_FMTDATE_YEAR_DIGITS_SHORT:
replace_val.replace_uint = tm.tm_year % 1000;
replace_type = PGTYPES_REPLACE_UINT_2_LZ;
replace_val.uint_val = tm.tm_year % 1000;
replace_type = PGTYPES_TYPE_UINT_2_LZ;
break;
default:
/* should not happen, set something
* anyway */
replace_val.replace_str = " ";
replace_type = PGTYPES_REPLACE_STRING_CONSTANT;
replace_val.str_val = " ";
replace_type = PGTYPES_TYPE_STRING_CONSTANT;
}
switch(replace_type) {
case PGTYPES_REPLACE_STRING_MALLOCED:
case PGTYPES_REPLACE_STRING_CONSTANT:
strncpy(start_pattern, replace_val.replace_str,
strlen(replace_val.replace_str));
if (replace_type == PGTYPES_REPLACE_STRING_MALLOCED) {
free(replace_val.replace_str);
case PGTYPES_TYPE_STRING_MALLOCED:
case PGTYPES_TYPE_STRING_CONSTANT:
strncpy(start_pattern, replace_val.str_val,
strlen(replace_val.str_val));
if (replace_type == PGTYPES_TYPE_STRING_MALLOCED) {
free(replace_val.str_val);
}
break;
case PGTYPES_REPLACE_UINT:
case PGTYPES_TYPE_UINT:
{
char* t = pgtypes_alloc(PGTYPES_DATE_NUM_MAX_DIGITS);
if (!t) {
return -1;
}
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%u", replace_val.replace_uint);
"%u", replace_val.uint_val);
strncpy(start_pattern, t, strlen(t));
free(t);
}
break;
case PGTYPES_REPLACE_UINT_2_LZ:
case PGTYPES_TYPE_UINT_2_LZ:
{
char* t = pgtypes_alloc(PGTYPES_DATE_NUM_MAX_DIGITS);
if (!t) {
return -1;
}
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%02u", replace_val.replace_uint);
"%02u", replace_val.uint_val);
strncpy(start_pattern, t, strlen(t));
free(t);
}
break;
case PGTYPES_REPLACE_UINT_4_LZ:
case PGTYPES_TYPE_UINT_4_LZ:
{
char* t = pgtypes_alloc(PGTYPES_DATE_NUM_MAX_DIGITS);
if (!t) {
return -1;
}
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%04u", replace_val.replace_uint);
"%04u", replace_val.uint_val);
strncpy(start_pattern, t, strlen(t));
free(t);
}
......@@ -268,7 +265,7 @@ PGTYPESdate_fmt_asc(Date dDate, char* fmtstring, char* outbuf) {
default:
/* doesn't happen (we set
* replace_type to
* PGTYPES_REPLACE_STRING_CONSTANT
* PGTYPES_TYPE_STRING_CONSTANT
* in case of an error above) */
break;
}
......
This diff is collapsed.
......@@ -5,32 +5,33 @@
/* These are the constants that decide which printf() format we'll use in
* order to get a string representation of the value */
#define PGTYPES_REPLACE_NOTHING 0
#define PGTYPES_REPLACE_STRING_MALLOCED 1
#define PGTYPES_REPLACE_STRING_CONSTANT 2
#define PGTYPES_REPLACE_CHAR 3
#define PGTYPES_REPLACE_DOUBLE_NF 4 /* no fractional part */
#define PGTYPES_REPLACE_INT64 5
#define PGTYPES_REPLACE_UINT 6
#define PGTYPES_REPLACE_UINT_2_LZ 7 /* 2 digits, pad with leading zero */
#define PGTYPES_REPLACE_UINT_2_LS 8 /* 2 digits, pad with leading space */
#define PGTYPES_REPLACE_UINT_3_LZ 9
#define PGTYPES_REPLACE_UINT_4_LZ 10
#define PGTYPES_TYPE_NOTHING 0
#define PGTYPES_TYPE_STRING_MALLOCED 1
#define PGTYPES_TYPE_STRING_CONSTANT 2
#define PGTYPES_TYPE_CHAR 3
#define PGTYPES_TYPE_DOUBLE_NF 4 /* no fractional part */
#define PGTYPES_TYPE_INT64 5
#define PGTYPES_TYPE_UINT 6
#define PGTYPES_TYPE_UINT_2_LZ 7 /* 2 digits, pad with leading zero */
#define PGTYPES_TYPE_UINT_2_LS 8 /* 2 digits, pad with leading space */
#define PGTYPES_TYPE_UINT_3_LZ 9
#define PGTYPES_TYPE_UINT_4_LZ 10
#define PGTYPES_TYPE_UINT_LONG 11
#define PGTYPES_FMT_NUM_MAX_DIGITS 40
union un_fmt_replace {
char* replace_str;
unsigned int replace_uint;
char replace_char;
unsigned long int replace_luint;
double replace_double;
union un_fmt_comb {
char* str_val;
unsigned int uint_val;
char char_val;
unsigned long int luint_val;
double double_val;
#ifdef HAVE_INT64_TIMESTAMP
int64 replace_int64;
int64 int64_val;
#endif
};
int pgtypes_fmt_replace(union un_fmt_replace, int, char**, int*);
int pgtypes_fmt_replace(union un_fmt_comb, int, char**, int*);
char *pgtypes_alloc(long);
char *pgtypes_strdup(char *);
......
This diff is collapsed.
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.75 2003/06/26 11:37:05 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.76 2003/08/01 08:21:04 meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
......@@ -382,11 +382,13 @@ main(int argc, char *const argv[])
lex_init();
/* we need several includes */
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
/* add some compatibility headers */
if (INFORMIX_MODE)
fprintf(yyout, "/* Needed for informix compatibility */\n#include <ecpg_informix.h>\n");
fprintf(yyout, "/* End of automatic include section */\n");
/* and parse the source */
yyparse();
......
......@@ -19,7 +19,7 @@ main()
char *fmt, *out, *in;
char *d1 = "Mon Jan 17 1966";
char *t1 = "2000-7-12 17:34:29";
int i;
FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL)
......@@ -71,7 +71,7 @@ main()
printf("Today in format \"%s\" is \"%s\"\n", fmt, out);
free(out);
/* rdefmtdate() */
/* rdate_defmt_asc() */
date1 = 0; text = "";
fmt = "yy/mm/dd";
......@@ -81,78 +81,232 @@ main()
*/
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate1: %s\n", text);
printf("date_defmt_asc1: %s\n", text);
date1 = 0; text = "";
fmt = "mmmm. dd. yyyy";
in = "12/25/95";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate2: %s\n", text);
printf("date_defmt_asc2: %s\n", text);
date1 = 0; text = "";
fmt = "yy/mm/dd";
in = "95/12/25";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate3: %s\n", text);
printf("date_defmt_asc3: %s\n", text);
date1 = 0; text = "";
fmt = "yy/mm/dd";
in = "1995, December 25th";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate4: %s\n", text);
printf("date_defmt_asc4: %s\n", text);
date1 = 0; text = "";
fmt = "dd-mm-yy";
in = "This is 25th day of December, 1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate5: %s\n", text);
printf("date_defmt_asc5: %s\n", text);
date1 = 0; text = "";
fmt = "mmddyy";
in = "Dec. 25th, 1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate6: %s\n", text);
printf("date_defmt_asc6: %s\n", text);
date1 = 0; text = "";
fmt = "mmm. dd. yyyy";
in = "dec 25th 1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate7: %s\n", text);
printf("date_defmt_asc7: %s\n", text);
date1 = 0; text = "";
fmt = "mmm. dd. yyyy";
in = "DEC-25-1995";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate8: %s\n", text);
printf("date_defmt_asc8: %s\n", text);
date1 = 0; text = "";
fmt = "mm yy dd.";
in = "12199525";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate9: %s\n", text);
printf("date_defmt_asc9: %s\n", text);
date1 = 0; text = "";
fmt = "yyyy fierj mm dd.";
in = "19951225";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate10: %s\n", text);
printf("date_defmt_asc10: %s\n", text);
date1 = 0; text = "";
fmt = "mm/dd/yy";
in = "122595";
PGTYPESdate_defmt_asc(&date1, fmt, in);
text = PGTYPESdate_to_asc(date1);
printf("defmtdate12: %s\n", text);
printf("date_defmt_asc12: %s\n", text);
PGTYPEStimestamp_current(&ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_current: Now: %s\n", text);
ts1 = PGTYPEStimestamp_from_asc("96-02-29", NULL);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_to_asc1: %s\n", text);
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 3:10:35", NULL);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_to_asc2: %s\n", text);
ts1 = PGTYPEStimestamp_from_asc("1994-02-11 26:10:35", NULL);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_to_asc3: %s\n", text);
/* abc-03:10:35-def-02/11/94-gh */
/* 12345678901234567890123456789 */
out = (char*) malloc(32);
i = PGTYPEStimestamp_fmt_asc(&ts1, out, 31, "abc-%X-def-%x-ghi%%");
printf("timestamp_fmt_asc: %d: %s\n", i, out);
fmt = "This is a %m/%d/%y %H-%Ml%Stest";
in = "This is a 4/12/80 3-39l12test";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%a %b %d %H:%M:%S %z %Y";
in = "Tue Jul 22 17:28:44 +0200 2003";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%a %b %d %H:%M:%S %z %Y";
in = "Tue Feb 29 17:28:44 +0200 2000";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%a %b %d %H:%M:%S %z %Y";
in = "Tue Feb 29 17:28:44 +0200 1900";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
fmt = "%a %b %d %H:%M:%S %z %Y";
in = "Tue Feb 29 17:28:44 +0200 1996";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%b %d %H:%M:%S %z %Y";
in = " Jul 31 17:28:44 +0200 1996";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%b %d %H:%M:%S %z %Y";
in = " Jul 32 17:28:44 +0200 1996";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
fmt = "%a %b %d %H:%M:%S %z %Y";
in = "Tue Feb 29 17:28:44 +0200 1997";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
fmt = "%";
in = "Tue Jul 22 17:28:44 +0200 2003";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
fmt = "a %";
in = "Tue Jul 22 17:28:44 +0200 2003";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
fmt = "%b, %d %H_%M`%S %z %Y";
in = " Jul, 22 17_28 `44 +0200 2003 ";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
in = "Tue Jul %22 17:28:44 CEST 2003";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%a %b %%%d %H:%M:%S %Z %Y";
in = "Tue Jul %22 17:28:44 CEST 2003";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %Y";
in = "abc\n 19 October %22 17:28:44 CEST 2003";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "abc%n %C %B %%%d %H:%M:%S %Z %y";
in = "abc\n 18 October %34 17:28:44 CEST 80";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
fmt = "";
in = "abc\n 18 October %34 17:28:44 CEST 80";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error (should be error!): %d\n", in, fmt, text, i);
fmt = NULL;
in = "1980-04-12 3:49:44 ";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
fmt = "%B %d, %Y. Time: %I:%M%p";
in = "July 14, 1988. Time: 9:15am";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
in = "September 6 at 01:30 pm in the year 1983";
fmt = "%B %d at %I:%M %p in the year %Y";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
in = " 1976, July 14. Time: 9:15am";
fmt = "%Y, %B %d. Time: %I:%M %p";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
in = " 1976, July 14. Time: 9:15 am";
fmt = "%Y, %B %d. Time: %I:%M%p";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
in = " 1976, P.M. July 14. Time: 9:15";
fmt = "%Y, %P %B %d. Time: %I:%M";
i = PGTYPEStimestamp_defmt_asc(in, fmt, &ts1);
text = PGTYPEStimestamp_to_asc(ts1);
printf("timestamp_defmt_asc(%s, %s) = %s, error: %d\n", in, fmt, text, i);
exec sql rollback;
exec sql disconnect;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment