-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.82 2009/02/03 08:55:45 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.83 2009/05/20 16:13:18 meskes Exp $ */
/*
* The aim is to get a simpler inteface to the database routines.
*/
if (statement_type == ECPGst_prepnormal)
{
- if (!ecpg_auto_prepare(lineno, connection_name, compat, questionmarks, &prepname, query))
+ if (!ecpg_auto_prepare(lineno, connection_name, compat, &prepname, query))
return (false);
/*
if (statement_type == ECPGst_execute)
{
/* if we have an EXECUTE command, only the name is send */
- char *command = ecpg_prepared(stmt->command, con, lineno);
+ char *command = ecpg_prepared(stmt->command, con);
if (command)
{
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.34 2008/02/07 11:09:12 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.35 2009/05/20 16:13:18 meskes Exp $ */
#ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H
bool ecpg_check_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
void ecpg_raise(int line, int code, const char *sqlstate, const char *str);
void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
-char *ecpg_prepared(const char *, struct connection *, int);
+char *ecpg_prepared(const char *, struct connection *);
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection * conn);
void ecpg_log(const char *format,...);
-bool ecpg_auto_prepare(int, const char *, int, const int, char **, const char *);
+bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
void ecpg_init_sqlca(struct sqlca_t * sqlca);
/* SQLSTATE values generated or processed by ecpglib (intentionally
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.29 2008/05/16 15:20:03 petere Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.30 2009/05/20 16:13:18 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
}
static bool
-replace_variables(char **text, int lineno, bool questionmarks)
+replace_variables(char **text, int lineno)
{
bool string = false;
int counter = 1,
}
/* handle the EXEC SQL PREPARE statement */
+/* questionmarks is not needed but remians in there for the time being to not change the API */
bool
-ECPGprepare(int lineno, const char *connection_name, const int questionmarks, const char *name, const char *variable)
+ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
{
struct connection *con;
struct statement *stmt;
stmt->inlist = stmt->outlist = NULL;
/* if we have C variables in our statment replace them with '?' */
- replace_variables(&(stmt->command), lineno, questionmarks);
+ replace_variables(&(stmt->command), lineno);
/* add prepared statement to our list */
this->name = (char *) name;
}
char *
-ecpg_prepared(const char *name, struct connection * con, int lineno)
+ecpg_prepared(const char *name, struct connection * con)
{
struct prepared_statement *this;
}
/* return the prepared statement */
+/* lineno is not used here, but kept in to not break API */
char *
ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
{
- return ecpg_prepared(name, ecpg_get_connection(connection_name), lineno);
+ return ecpg_prepared(name, ecpg_get_connection(connection_name));
}
/*
/* handle cache and preparation of statments in auto-prepare mode */
bool
-ecpg_auto_prepare(int lineno, const char *connection_name, int compat, const int questionmarks, char **name, const char *query)
+ecpg_auto_prepare(int lineno, const char *connection_name, int compat, char **name, const char *query)
{
int entNo;
*name = (char *) ecpg_alloc(STMTID_SIZE, lineno);
sprintf(*name, "ecpg%d", nextStmtID++);
- if (!ECPGprepare(lineno, connection_name, questionmarks, ecpg_strdup(*name, lineno), query))
+ if (!ECPGprepare(lineno, connection_name, 0, ecpg_strdup(*name, lineno), query))
return (false);
if (AddStmtToCache(lineno, *name, connection_name, compat, query) < 0)
return (false);
/*
* this is a small part of c.h since we don't want to leak all postgres
* definitions into ecpg programs
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.77 2008/05/16 15:20:04 petere Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.78 2009/05/20 16:13:18 meskes Exp $
*/
#ifndef _ECPGLIB_H
bool ECPGdo(const int, const int, const int, const char *, const bool, const int, const char *,...);
bool ECPGtrans(int, const char *, const char *);
bool ECPGdisconnect(int, const char *);
-bool ECPGprepare(int, const char *, const int, const char *, const char *);
+bool ECPGprepare(int, const char *, const bool, const char *, const char *);
bool ECPGdeallocate(int, int, const char *, const char *);
bool ECPGdeallocate_all(int, int, const char *);
char *ECPGprepared_statement(const char *, const char *, int);
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.35 2009/02/04 08:51:09 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.36 2009/05/20 16:13:18 meskes Exp $ */
#include "postgres_fe.h"
return INT_MIN;
}
- if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
+ if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, EuroDates) != 0)
{
errno = PGTYPES_DATE_BAD_DATE;
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.41 2009/02/04 08:51:09 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.42 2009/05/20 16:13:18 meskes Exp $ */
#ifndef DT_H
#define DT_H
int DecodeTimeOnly(char **, int *, int, int *, struct tm *, fsec_t *, int *);
int DecodeInterval(char **, int *, int, int *, struct tm *, fsec_t *);
-int DecodeTime(char *, int, int *, struct tm *, fsec_t *);
+int DecodeTime(char *, int *, struct tm *, fsec_t *);
int EncodeTimeOnly(struct tm *, fsec_t, int *, int, char *);
int EncodeDateTime(struct tm *, fsec_t, int *, char **, int, char *, bool);
int EncodeInterval(struct tm *, fsec_t, int, char *);
bool CheckDateTokenTables(void);
int EncodeDateOnly(struct tm *, int, char *, bool);
int GetEpochTime(struct tm *);
-int ParseDateTime(char *, char *, char **, int *, int, int *, char **);
+int ParseDateTime(char *, char *, char **, int *, int *, char **);
int DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, bool);
void j2date(int, int *, int *, int *);
void GetCurrentDateTime(struct tm *);
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.48 2009/03/22 01:12:32 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.49 2009/05/20 16:13:18 meskes Exp $ */
#include "postgres_fe.h"
*/
static int
DecodeNumberField(int len, char *str, int fmask,
- int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits, bool EuroDates)
+ int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits)
{
char *cp;
*/
if (cp - str > 2)
return DecodeNumberField(flen, str, (fmask | DTK_DATE_M),
- tmask, tm, fsec, is2digits, EuroDates);
+ tmask, tm, fsec, is2digits);
*fsec = strtod(cp, &cp);
if (*cp != '\0')
* can be used to represent time spans.
*/
int
-DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
+DecodeTime(char *str, int *tmask, struct tm * tm, fsec_t *fsec)
{
char *cp;
*/
int
ParseDateTime(char *timestr, char *lowstr,
- char **field, int *ftype, int maxfields, int *numfields, char **endstr)
+ char **field, int *ftype, int *numfields, char **endstr)
{
int nf = 0;
char *lp = lowstr;
* time
*/
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], fmask,
- &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
/*
break;
case DTK_TIME:
- if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
+ if (DecodeTime(field[i], &tmask, tm, fsec) != 0)
return -1;
/*
case DTK_TIME:
/* previous field was "t" for ISO time */
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M),
- &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
if (tmask != DTK_TIME_M)
* Example: 20011223 or 040506
*/
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
}
else if (flen > 4)
{
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
- &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+ &tmask, tm, fsec, &is2digits)) < 0)
return -1;
}
/* otherwise it is a single date/time field... */
int scan_type;
char *pstr,
- *pfmt,
- *tmp;
- int err = 1;
- int j;
+ *pfmt,
+ *tmp;
+ int err = 1;
+ int j;
struct tm tm;
pfmt = fmt;
pfmt++;
scan_type = PGTYPES_TYPE_UINT;
err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
- if (scan_val.uint_val < 0 || scan_val.uint_val > 53)
+ if (scan_val.uint_val > 53)
err = 1;
break;
case 'V':
pfmt++;
scan_type = PGTYPES_TYPE_UINT;
err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
- if (scan_val.uint_val < 0 || scan_val.uint_val > 6)
+ if (scan_val.uint_val > 6)
err = 1;
break;
case 'W':
pfmt++;
scan_type = PGTYPES_TYPE_UINT;
err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
- if (scan_val.uint_val < 0 || scan_val.uint_val > 53)
+ if (scan_val.uint_val > 53)
err = 1;
break;
case 'x':
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.39 2008/11/26 16:47:08 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.40 2009/05/20 16:13:18 meskes Exp $ */
#include "postgres_fe.h"
#include <time.h>
switch (ftype[i])
{
case DTK_TIME:
- dterr = DecodeTime(field[i], fmask, /* range, */
+ dterr = DecodeTime(field[i], /* range, */
&tmask, tm, fsec);
if (dterr)
return dterr;
* and signed year-month values.
*/
if (strchr(field[i] + 1, ':') != NULL &&
- DecodeTime(field[i] + 1, fmask, /* INTERVAL_FULL_RANGE, */
+ DecodeTime(field[i] + 1, /* INTERVAL_FULL_RANGE, */
&tmask, tm, fsec) == 0)
{
if (*field[i] == '-')
return NULL;
}
- if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
+ if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
(DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0 &&
DecodeISO8601Interval(str, &dtype, tm, &fsec) != 0))
{
/*
- * $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.43 2009/02/04 08:51:10 meskes Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.44 2009/05/20 16:13:18 meskes Exp $
*/
#include "postgres_fe.h"
return (noresult);
}
- if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
+ if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, 0) != 0)
{
errno = PGTYPES_TS_BAD_TIMESTAMP;
-int main(int argc, char **argv)
+int main()
{ /* exec sql begin declare section */
return 0;
}
-int main (int argc, char** argv)
+int main ()
{
int i;
#ifdef WIN32
return 0;
}
-int main (int argc, char** argv)
+int main ()
{
#ifdef ENABLE_THREAD_SAFETY
int i;
exec sql include ../regression;
-int main(int argc, char **argv)
+int main()
{ exec sql begin declare section;
int index;
exec sql end declare section;
return 0;
}
-int main (int argc, char** argv)
+int main ()
{
int i;
#ifdef WIN32
return 0;
}
-int main (int argc, char** argv)
+int main ()
{
#ifdef ENABLE_THREAD_SAFETY
int i;