mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.58 2009/05/20 16:49:23 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.59 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -151,7 +151,7 @@ static char *
|
||||
ecpg_strndup(const char *str, size_t len)
|
||||
{
|
||||
int real_len = strlen(str);
|
||||
int use_len = (real_len > len) ? (int)len : real_len;
|
||||
int use_len = (real_len > len) ? (int) len : real_len;
|
||||
|
||||
char *new = malloc(use_len + 1);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.53 2009/01/15 11:52:55 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.54 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -270,7 +270,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
|
||||
struct sqlca_t *sqlca = ECPGget_sqlca();
|
||||
enum COMPAT_MODE compat = c;
|
||||
struct connection *this;
|
||||
int i;
|
||||
int i;
|
||||
char *dbname = name ? ecpg_strdup(name, lineno) : NULL,
|
||||
*host = NULL,
|
||||
*tmp,
|
||||
@ -477,29 +477,31 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
|
||||
options ? "with options " : "", options ? options : "",
|
||||
user ? "for user " : "", user ? user : "");
|
||||
|
||||
connect_string = ecpg_alloc( strlen_or_null(host)
|
||||
+ strlen_or_null(port)
|
||||
+ strlen_or_null(options)
|
||||
+ strlen_or_null(realname)
|
||||
+ strlen_or_null(user)
|
||||
+ strlen_or_null(passwd)
|
||||
+ sizeof(" host = port = dbname = user = password ="), lineno);
|
||||
connect_string = ecpg_alloc(strlen_or_null(host)
|
||||
+ strlen_or_null(port)
|
||||
+ strlen_or_null(options)
|
||||
+ strlen_or_null(realname)
|
||||
+ strlen_or_null(user)
|
||||
+ strlen_or_null(passwd)
|
||||
+ sizeof(" host = port = dbname = user = password ="), lineno);
|
||||
|
||||
if (options) /* replace '&' if tehre are any */
|
||||
if (options) /* replace '&' if tehre are any */
|
||||
for (i = 0; options[i]; i++)
|
||||
if (options[i] == '&')
|
||||
options[i] = ' ';
|
||||
|
||||
sprintf(connect_string,"%s%s %s%s %s%s %s%s %s%s %s",
|
||||
realname ? "dbname=" : "", realname ? realname : "",
|
||||
host ? "host=" : "", host ? host : "",
|
||||
port ? "port=" : "", port ? port : "",
|
||||
user ? "user=" : "", user ? user : "",
|
||||
passwd ? "password=" : "", passwd ? passwd : "",
|
||||
options ? options : "");
|
||||
|
||||
/* this is deprecated
|
||||
* this->connection = PQsetdbLogin(host, port, options, NULL, realname, user, passwd);*/
|
||||
sprintf(connect_string, "%s%s %s%s %s%s %s%s %s%s %s",
|
||||
realname ? "dbname=" : "", realname ? realname : "",
|
||||
host ? "host=" : "", host ? host : "",
|
||||
port ? "port=" : "", port ? port : "",
|
||||
user ? "user=" : "", user ? user : "",
|
||||
passwd ? "password=" : "", passwd ? passwd : "",
|
||||
options ? options : "");
|
||||
|
||||
/*
|
||||
* this is deprecated this->connection = PQsetdbLogin(host, port, options,
|
||||
* NULL, realname, user, passwd);
|
||||
*/
|
||||
this->connection = PQconnectdb(connect_string);
|
||||
|
||||
ecpg_free(connect_string);
|
||||
@ -589,12 +591,14 @@ ECPGdisconnect(int lineno, const char *connection_name)
|
||||
return true;
|
||||
}
|
||||
|
||||
PGconn* ECPGget_PGconn(const char *connection_name)
|
||||
PGconn *
|
||||
ECPGget_PGconn(const char *connection_name)
|
||||
{
|
||||
struct connection * con;
|
||||
struct connection *con;
|
||||
|
||||
con=ecpg_get_connection(connection_name);
|
||||
if (con==NULL) return NULL;
|
||||
con = ecpg_get_connection(connection_name);
|
||||
if (con == NULL)
|
||||
return NULL;
|
||||
|
||||
return con->connection;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* dynamic SQL support routines
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.31 2009/01/15 11:52:55 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.32 2009/06/11 14:49:13 momjian Exp $
|
||||
*/
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
@ -529,7 +529,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
|
||||
for (;;)
|
||||
{
|
||||
enum ECPGdtype itemtype;
|
||||
char *tobeinserted = NULL;
|
||||
char *tobeinserted = NULL;
|
||||
|
||||
itemtype = va_arg(args, enum ECPGdtype);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.22 2009/01/16 09:15:03 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.23 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -21,183 +21,261 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str)
|
||||
{
|
||||
case ECPG_NOT_FOUND:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("no data found on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_OUT_OF_MEMORY:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("out of memory on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_UNSUPPORTED:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("unsupported type \"%s\" on line %d"), str, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("unsupported type \"%s\" on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_TOO_MANY_ARGUMENTS:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("too many arguments on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_TOO_FEW_ARGUMENTS:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("too few arguments on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_INT_FORMAT:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("invalid input syntax for type int: \"%s\", on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_UINT_FORMAT:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("invalid input syntax for type unsigned int: \"%s\", on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_FLOAT_FORMAT:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("invalid input syntax for floating-point type: \"%s\", on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_CONVERT_BOOL:
|
||||
if (str)
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("invalid syntax for type boolean: \"%s\", on line %d"), str, line);
|
||||
else
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("could not convert boolean value: size mismatch, on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_EMPTY:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("empty query on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_MISSING_INDICATOR:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("null value without indicator on line %d"), line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("null value without indicator on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_NO_ARRAY:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("variable does not have an array type on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_DATA_NOT_ARRAY:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("data read from server is not an array on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_ARRAY_INSERT:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("inserting an array of variables is not supported on line %d"), line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("inserting an array of variables is not supported on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_NO_CONN:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("connection \"%s\" does not exist on line %d"), str, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("connection \"%s\" does not exist on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_NOT_CONN:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("not connected to connection \"%s\" on line %d"), str, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("not connected to connection \"%s\" on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_INVALID_STMT:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("invalid statement name \"%s\" on line %d"), str, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("invalid statement name \"%s\" on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_UNKNOWN_DESCRIPTOR:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("descriptor \"%s\" not found on line %d"), str, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("descriptor \"%s\" not found on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_INVALID_DESCRIPTOR_INDEX:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("descriptor index out of range on line %d"), line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("descriptor index out of range on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_UNKNOWN_DESCRIPTOR_ITEM:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("unrecognized descriptor item \"%s\" on line %d"), str, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("unrecognized descriptor item \"%s\" on line %d"), str, line);
|
||||
break;
|
||||
|
||||
case ECPG_VAR_NOT_NUMERIC:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("variable does not have a numeric type on line %d"), line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("variable does not have a numeric type on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_VAR_NOT_CHAR:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("variable does not have a character type on line %d"), line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("variable does not have a character type on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_TRANS:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("error in transaction processing on line %d"), line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("error in transaction processing on line %d"), line);
|
||||
break;
|
||||
|
||||
case ECPG_CONNECT:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("could not connect to database \"%s\" on line %d"), str, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("could not connect to database \"%s\" on line %d"), str, line);
|
||||
break;
|
||||
|
||||
default:
|
||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc),
|
||||
/* translator: this string will be truncated at 149
|
||||
characters expanded. */
|
||||
ecpg_gettext("SQL error %d on line %d"), code, line);
|
||||
|
||||
/*
|
||||
* translator: this string will be truncated at 149 characters
|
||||
* expanded.
|
||||
*/
|
||||
ecpg_gettext("SQL error %d on line %d"), code, line);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.84 2009/05/20 16:49:23 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.85 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
/*
|
||||
* The aim is to get a simpler inteface to the database routines.
|
||||
@ -128,9 +128,9 @@ next_insert(char *text, int pos, bool questionmarks)
|
||||
int i;
|
||||
|
||||
for (i = p + 1; isdigit((unsigned char) text[i]); i++)
|
||||
/* empty loop body */ ;
|
||||
/* empty loop body */ ;
|
||||
if (!isalpha((unsigned char) text[i]) &&
|
||||
isascii((unsigned char) text[i]) && text[i] != '_')
|
||||
isascii((unsigned char) text[i]) &&text[i] != '_')
|
||||
/* not dollar delimited quote */
|
||||
return p;
|
||||
}
|
||||
@ -353,7 +353,7 @@ ecpg_store_result(const PGresult *results, int act_field,
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if (!PQfformat(results, act_field))
|
||||
if (!PQfformat(results, act_field))
|
||||
{
|
||||
switch (var->type)
|
||||
{
|
||||
@ -364,7 +364,7 @@ ecpg_store_result(const PGresult *results, int act_field,
|
||||
/* special mode for handling char**foo=0 */
|
||||
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
|
||||
len += strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
|
||||
len *= var->offset; /* should be 1, but YMNK */
|
||||
len *= var->offset; /* should be 1, but YMNK */
|
||||
len += (ntuples + 1) * sizeof(char *);
|
||||
}
|
||||
else
|
||||
@ -759,7 +759,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
|
||||
case ECPGt_unsigned_char:
|
||||
{
|
||||
/* set slen to string length if type is char * */
|
||||
int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : (unsigned int)var->varcharsize;
|
||||
int slen = (var->varcharsize == 0) ? strlen((char *) var->value) : (unsigned int) var->varcharsize;
|
||||
|
||||
if (!(newcopy = ecpg_alloc(slen + 1, lineno)))
|
||||
return false;
|
||||
@ -1061,7 +1061,7 @@ free_params(const char **paramValues, int nParams, bool print, int lineno)
|
||||
static bool
|
||||
insert_tobeinserted(int position, int ph_len, struct statement * stmt, char *tobeinserted)
|
||||
{
|
||||
char *newcopy;
|
||||
char *newcopy;
|
||||
|
||||
if (!(newcopy = (char *) ecpg_alloc(strlen(stmt->command)
|
||||
+ strlen(tobeinserted)
|
||||
@ -1075,8 +1075,8 @@ insert_tobeinserted(int position, int ph_len, struct statement * stmt, char *tob
|
||||
strcpy(newcopy + position - 1, tobeinserted);
|
||||
|
||||
/*
|
||||
* The strange thing in the second argument is the rest of the
|
||||
* string from the old string
|
||||
* The strange thing in the second argument is the rest of the string from
|
||||
* the old string
|
||||
*/
|
||||
strcat(newcopy,
|
||||
stmt->command
|
||||
@ -1113,7 +1113,7 @@ ecpg_execute(struct statement * stmt)
|
||||
var = stmt->inlist;
|
||||
while (var)
|
||||
{
|
||||
char *tobeinserted;
|
||||
char *tobeinserted;
|
||||
int counter = 1;
|
||||
|
||||
tobeinserted = NULL;
|
||||
@ -1183,24 +1183,24 @@ ecpg_execute(struct statement * stmt)
|
||||
if ((position = next_insert(stmt->command, position, stmt->questionmarks) + 1) == 0)
|
||||
{
|
||||
/*
|
||||
* We have an argument but we dont have the matched up
|
||||
* placeholder in the string
|
||||
* We have an argument but we dont have the matched up placeholder
|
||||
* in the string
|
||||
*/
|
||||
ecpg_raise(stmt->lineno, ECPG_TOO_MANY_ARGUMENTS,
|
||||
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS,
|
||||
ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS,
|
||||
NULL);
|
||||
free_params(paramValues, nParams, false, stmt->lineno);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* if var->type=ECPGt_char_variable we have a dynamic cursor we have
|
||||
* to simulate a dynamic cursor because there is no backend
|
||||
* functionality for it
|
||||
*/
|
||||
if (var->type == ECPGt_char_variable)
|
||||
{
|
||||
int ph_len = (stmt->command[position] == '?') ? strlen("?") : strlen("$1");
|
||||
int ph_len = (stmt->command[position] == '?') ? strlen("?") : strlen("$1");
|
||||
|
||||
if (!insert_tobeinserted(position, ph_len, stmt, tobeinserted))
|
||||
{
|
||||
@ -1209,11 +1209,13 @@ ecpg_execute(struct statement * stmt)
|
||||
}
|
||||
tobeinserted = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the placeholder is '$0' we have to replace it on the client side
|
||||
* this is for places we want to support variables at that are not supported in the backend
|
||||
* this is for places we want to support variables at that are not
|
||||
* supported in the backend
|
||||
*/
|
||||
else if (stmt->command[position] == '0' )
|
||||
else if (stmt->command[position] == '0')
|
||||
{
|
||||
if (!insert_tobeinserted(position, 2, stmt, tobeinserted))
|
||||
{
|
||||
@ -1345,7 +1347,7 @@ ecpg_execute(struct statement * stmt)
|
||||
desc->result = results;
|
||||
clear_result = false;
|
||||
ecpg_log("ecpg_execute on line %d: putting result (%d tuples) into descriptor %s\n",
|
||||
stmt->lineno, PQntuples(results), (const char *) var->pointer);
|
||||
stmt->lineno, PQntuples(results), (const char *) var->pointer);
|
||||
}
|
||||
var = var->next;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.48 2009/01/15 11:52:55 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.49 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -241,10 +241,10 @@ void
|
||||
ecpg_log(const char *format,...)
|
||||
{
|
||||
va_list ap;
|
||||
struct sqlca_t *sqlca = ECPGget_sqlca();
|
||||
struct sqlca_t *sqlca = ECPGget_sqlca();
|
||||
const char *intl_format;
|
||||
int bufsize;
|
||||
char *fmt;
|
||||
char *fmt;
|
||||
|
||||
if (!simple_debug)
|
||||
return;
|
||||
@ -253,8 +253,8 @@ ecpg_log(const char *format,...)
|
||||
intl_format = ecpg_gettext(format);
|
||||
|
||||
/*
|
||||
* Insert PID into the format, unless ecpg_internal_regression_mode is
|
||||
* set (regression tests want unchanging output).
|
||||
* Insert PID into the format, unless ecpg_internal_regression_mode is set
|
||||
* (regression tests want unchanging output).
|
||||
*/
|
||||
bufsize = strlen(intl_format) + 100;
|
||||
fmt = (char *) malloc(bufsize);
|
||||
@ -426,11 +426,11 @@ win32_pthread_mutex(volatile pthread_mutex_t *mutex)
|
||||
{
|
||||
if (mutex->handle == NULL)
|
||||
{
|
||||
while (InterlockedExchange((LONG *) & mutex->initlock, 1) == 1)
|
||||
while (InterlockedExchange((LONG *) &mutex->initlock, 1) == 1)
|
||||
Sleep(0);
|
||||
if (mutex->handle == NULL)
|
||||
mutex->handle = CreateMutex(NULL, FALSE, NULL);
|
||||
InterlockedExchange((LONG *) & mutex->initlock, 0);
|
||||
InterlockedExchange((LONG *) &mutex->initlock, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +451,6 @@ win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void))
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.30 2009/05/20 16:13:18 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.31 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#define POSTGRES_ECPG_INTERNAL
|
||||
#include "postgres_fe.h"
|
||||
@ -382,7 +382,8 @@ ecpg_freeStmtCacheEntry(int lineno, int compat, int entNo) /* entry # to free *
|
||||
{
|
||||
stmtCacheEntry *entry;
|
||||
struct connection *con;
|
||||
struct prepared_statement *this, *prev;
|
||||
struct prepared_statement *this,
|
||||
*prev;
|
||||
|
||||
entry = &stmtCacheEntries[entNo];
|
||||
if (!entry->stmtID[0]) /* return if the entry isn't in use */
|
||||
@ -390,7 +391,7 @@ ecpg_freeStmtCacheEntry(int lineno, int compat, int entNo) /* entry # to free *
|
||||
|
||||
con = ecpg_get_connection(entry->connection);
|
||||
|
||||
/* free the 'prepared_statement' list entry */
|
||||
/* free the 'prepared_statement' list entry */
|
||||
this = find_prepared_statement(entry->stmtID, con, &prev);
|
||||
if (this && !deallocate_one(lineno, compat, con, prev, this))
|
||||
return (-1);
|
||||
@ -415,7 +416,7 @@ static int
|
||||
AddStmtToCache(int lineno, /* line # of statement */
|
||||
char *stmtID, /* statement ID */
|
||||
const char *connection, /* connection */
|
||||
int compat, /* compatibility level */
|
||||
int compat, /* compatibility level */
|
||||
const char *ecpgQuery) /* query */
|
||||
{
|
||||
int ix,
|
||||
|
@ -1,13 +1,14 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/datetime.h,v 1.16 2008/02/17 18:14:29 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/datetime.h,v 1.17 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#ifndef _ECPG_DATETIME_H
|
||||
#define _ECPG_DATETIME_H
|
||||
|
||||
#include <ecpg_informix.h>
|
||||
|
||||
#ifndef _ECPGLIB_H /* source created by ecpg which defines these symbols */
|
||||
#ifndef _ECPGLIB_H /* source created by ecpg which defines these
|
||||
* symbols */
|
||||
typedef timestamp dtime_t;
|
||||
typedef interval intrvl_t;
|
||||
#endif /* ndef _ECPGLIB_H */
|
||||
#endif /* ndef _ECPGLIB_H */
|
||||
|
||||
#endif /* ndef _ECPG_DATETIME_H */
|
||||
|
@ -1,12 +1,13 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/decimal.h,v 1.18 2008/02/17 18:14:29 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/decimal.h,v 1.19 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#ifndef _ECPG_DECIMAL_H
|
||||
#define _ECPG_DECIMAL_H
|
||||
|
||||
#include <ecpg_informix.h>
|
||||
|
||||
#ifndef _ECPGLIB_H /* source created by ecpg which defines this symbol */
|
||||
typedef decimal dec_t;
|
||||
#endif /* ndef _ECPGLIB_H */
|
||||
#ifndef _ECPGLIB_H /* source created by ecpg which defines this
|
||||
* symbol */
|
||||
typedef decimal dec_t;
|
||||
#endif /* ndef _ECPGLIB_H */
|
||||
|
||||
#endif /* ndef _ECPG_DECIMAL_H */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* 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.78 2009/05/20 16:13:18 meskes Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.79 2009/06/11 14:49:13 momjian Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ECPGLIB_H
|
||||
@ -17,7 +17,7 @@ extern char *
|
||||
ecpg_gettext(const char *msgid)
|
||||
__attribute__((format_arg(1)));
|
||||
#else
|
||||
#define ecpg_gettext(x) (x)
|
||||
#define ecpg_gettext(x) (x)
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
@ -57,11 +57,11 @@ bool ECPGdisconnect(int, 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);
|
||||
PGconn *ECPGget_PGconn(const char *);
|
||||
char *ECPGprepared_statement(const char *, const char *, int);
|
||||
PGconn *ECPGget_PGconn(const char *);
|
||||
|
||||
|
||||
char *ECPGerrmsg(void);
|
||||
char *ECPGerrmsg(void);
|
||||
|
||||
/* print an error message */
|
||||
void sqlprint(void);
|
||||
@ -69,7 +69,7 @@ void sqlprint(void);
|
||||
/* define this for simplicity as well as compatibility */
|
||||
|
||||
#define SQLCODE sqlca.sqlcode
|
||||
#define SQLSTATE sqlca.sqlstate
|
||||
#define SQLSTATE sqlca.sqlstate
|
||||
|
||||
/* dynamic SQL */
|
||||
|
||||
@ -77,13 +77,13 @@ bool ECPGdo_descriptor(int, const char *, const char *, const char *);
|
||||
bool ECPGdeallocate_desc(int, const char *);
|
||||
bool ECPGallocate_desc(int, const char *);
|
||||
bool ECPGget_desc_header(int, const char *, int *);
|
||||
bool ECPGget_desc(int, const char *, int, ...);
|
||||
bool ECPGget_desc(int, const char *, int,...);
|
||||
bool ECPGset_desc_header(int, const char *, int);
|
||||
bool ECPGset_desc(int, const char *, int, ...);
|
||||
bool ECPGset_desc(int, const char *, int,...);
|
||||
|
||||
void ECPGset_noind_null(enum ECPGttype, void *);
|
||||
bool ECPGis_noind_null(enum ECPGttype, void *);
|
||||
bool ECPGdescribe(int, bool, const char *, ...);
|
||||
bool ECPGdescribe(int, bool, const char *,...);
|
||||
|
||||
/* dynamic result allocation */
|
||||
void ECPGfree_auto_mem(void);
|
||||
|
@ -1,4 +1,3 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.3 2008/05/17 01:28:25 adunstan Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.8 2008/05/17 01:28:25 adunstan Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
|
||||
*/
|
||||
#ifndef ECPG_SQLTYPES_H
|
||||
#define ECPG_SQLTYPES_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.37 2009/05/20 16:49:23 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.38 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@ -347,7 +347,7 @@ PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
|
||||
char *fmt_ystart,
|
||||
*fmt_mstart,
|
||||
*fmt_dstart;
|
||||
unsigned int i;
|
||||
unsigned int i;
|
||||
int reading_digit;
|
||||
int token_count;
|
||||
char *str_copy;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.43 2009/05/26 01:39:49 tgl Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.44 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#ifndef DT_H
|
||||
#define DT_H
|
||||
@ -25,10 +25,10 @@ typedef double fsec_t;
|
||||
#define USE_SQL_DATES 2
|
||||
#define USE_GERMAN_DATES 3
|
||||
|
||||
#define INTSTYLE_POSTGRES 0
|
||||
#define INTSTYLE_POSTGRES_VERBOSE 1
|
||||
#define INTSTYLE_SQL_STANDARD 2
|
||||
#define INTSTYLE_ISO_8601 3
|
||||
#define INTSTYLE_POSTGRES 0
|
||||
#define INTSTYLE_POSTGRES_VERBOSE 1
|
||||
#define INTSTYLE_SQL_STANDARD 2
|
||||
#define INTSTYLE_ISO_8601 3
|
||||
|
||||
#define INTERVAL_FULL_RANGE (0x7FFF)
|
||||
#define INTERVAL_MASK(b) (1 << (b))
|
||||
@ -188,7 +188,7 @@ typedef double fsec_t;
|
||||
*/
|
||||
/* Copy&pasted these values from src/include/utils/datetime.h */
|
||||
#define DTK_M(t) (0x01 << (t))
|
||||
#define DTK_ALL_SECS_M (DTK_M(SECOND) | DTK_M(MILLISECOND) | DTK_M(MICROSECOND))
|
||||
#define DTK_ALL_SECS_M (DTK_M(SECOND) | DTK_M(MILLISECOND) | DTK_M(MICROSECOND))
|
||||
#define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
|
||||
#define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND))
|
||||
|
||||
@ -340,7 +340,7 @@ int tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
|
||||
int DecodeUnits(int field, char *lowtoken, int *val);
|
||||
bool CheckDateTokenTables(void);
|
||||
int EncodeDateOnly(struct tm *, int, char *, bool);
|
||||
int GetEpochTime(struct tm *);
|
||||
int GetEpochTime(struct tm *);
|
||||
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 *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.50 2009/05/20 16:49:23 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.51 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@ -1132,7 +1132,7 @@ dt2time(double jd, int *hour, int *min, int *sec, fsec_t *fsec)
|
||||
*/
|
||||
static int
|
||||
DecodeNumberField(int len, char *str, int fmask,
|
||||
int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits)
|
||||
int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
@ -1640,7 +1640,7 @@ DecodePosixTimezone(char *str, int *tzp)
|
||||
*/
|
||||
int
|
||||
ParseDateTime(char *timestr, char *lowstr,
|
||||
char **field, int *ftype, int *numfields, char **endstr)
|
||||
char **field, int *ftype, int *numfields, char **endstr)
|
||||
{
|
||||
int nf = 0;
|
||||
char *lp = lowstr;
|
||||
@ -1928,7 +1928,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||
* time
|
||||
*/
|
||||
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], fmask,
|
||||
&tmask, tm, fsec, &is2digits)) < 0)
|
||||
&tmask, tm, fsec, &is2digits)) < 0)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
@ -2116,7 +2116,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||
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)) < 0)
|
||||
&tmask, tm, fsec, &is2digits)) < 0)
|
||||
return -1;
|
||||
|
||||
if (tmask != DTK_TIME_M)
|
||||
@ -2154,13 +2154,13 @@ DecodeDateTime(char **field, int *ftype, int nf,
|
||||
* Example: 20011223 or 040506
|
||||
*/
|
||||
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
|
||||
&tmask, tm, fsec, &is2digits)) < 0)
|
||||
&tmask, tm, fsec, &is2digits)) < 0)
|
||||
return -1;
|
||||
}
|
||||
else if (flen > 4)
|
||||
{
|
||||
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
|
||||
&tmask, tm, fsec, &is2digits)) < 0)
|
||||
&tmask, tm, fsec, &is2digits)) < 0)
|
||||
return -1;
|
||||
}
|
||||
/* otherwise it is a single date/time field... */
|
||||
@ -2580,10 +2580,10 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
|
||||
int scan_type;
|
||||
|
||||
char *pstr,
|
||||
*pfmt,
|
||||
*tmp;
|
||||
int err = 1;
|
||||
unsigned int j;
|
||||
*pfmt,
|
||||
*tmp;
|
||||
int err = 1;
|
||||
unsigned int j;
|
||||
struct tm tm;
|
||||
|
||||
pfmt = fmt;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.40 2009/05/20 16:13:18 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.41 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
#include <time.h>
|
||||
@ -18,7 +18,7 @@
|
||||
static int
|
||||
strtoi(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
long val;
|
||||
long val;
|
||||
|
||||
val = strtol(nptr, endptr, base);
|
||||
#ifdef HAVE_LONG_INT_64
|
||||
@ -28,42 +28,42 @@ strtoi(const char *nptr, char **endptr, int base)
|
||||
return (int) val;
|
||||
}
|
||||
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
* and changesd struct pg_tm to struct tm
|
||||
*/
|
||||
static void
|
||||
AdjustFractSeconds(double frac, struct /*pg_*/tm * tm, fsec_t *fsec, int scale)
|
||||
AdjustFractSeconds(double frac, struct /* pg_ */ tm * tm, fsec_t *fsec, int scale)
|
||||
{
|
||||
int sec;
|
||||
int sec;
|
||||
|
||||
if (frac == 0)
|
||||
return;
|
||||
frac *= scale;
|
||||
sec = (int) frac;
|
||||
frac *= scale;
|
||||
sec = (int) frac;
|
||||
tm->tm_sec += sec;
|
||||
frac -= sec;
|
||||
frac -= sec;
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
*fsec += rint(frac * 1000000);
|
||||
*fsec += rint(frac * 1000000);
|
||||
#else
|
||||
*fsec += frac;
|
||||
*fsec += frac;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
* and changesd struct pg_tm to struct tm
|
||||
*/
|
||||
static void
|
||||
AdjustFractDays(double frac, struct /*pg_*/tm * tm, fsec_t *fsec, int scale)
|
||||
AdjustFractDays(double frac, struct /* pg_ */ tm * tm, fsec_t *fsec, int scale)
|
||||
{
|
||||
int extra_days;
|
||||
int extra_days;
|
||||
|
||||
if (frac == 0)
|
||||
return;
|
||||
frac *= scale;
|
||||
extra_days = (int) frac;
|
||||
frac *= scale;
|
||||
extra_days = (int) frac;
|
||||
tm->tm_mday += extra_days;
|
||||
frac -= extra_days;
|
||||
frac -= extra_days;
|
||||
AdjustFractSeconds(frac, tm, fsec, SECS_PER_DAY);
|
||||
}
|
||||
|
||||
@ -103,33 +103,33 @@ ISO8601IntegerWidth(char *fieldstart)
|
||||
}
|
||||
|
||||
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
* and changesd struct pg_tm to struct tm
|
||||
*/
|
||||
static inline void
|
||||
ClearPgTm(struct /*pg_*/tm *tm, fsec_t *fsec)
|
||||
static inline void
|
||||
ClearPgTm(struct /* pg_ */ tm * tm, fsec_t *fsec)
|
||||
{
|
||||
tm->tm_year = 0;
|
||||
tm->tm_mon = 0;
|
||||
tm->tm_mon = 0;
|
||||
tm->tm_mday = 0;
|
||||
tm->tm_hour = 0;
|
||||
tm->tm_min = 0;
|
||||
tm->tm_sec = 0;
|
||||
*fsec = 0;
|
||||
tm->tm_min = 0;
|
||||
tm->tm_sec = 0;
|
||||
*fsec = 0;
|
||||
}
|
||||
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
*
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
*
|
||||
* * changesd struct pg_tm to struct tm
|
||||
*
|
||||
*
|
||||
* * Made the function static
|
||||
*/
|
||||
static int
|
||||
DecodeISO8601Interval(char *str,
|
||||
int *dtype, struct /*pg_*/tm * tm, fsec_t *fsec)
|
||||
int *dtype, struct /* pg_ */ tm * tm, fsec_t *fsec)
|
||||
{
|
||||
bool datepart = true;
|
||||
bool havefield = false;
|
||||
bool datepart = true;
|
||||
bool havefield = false;
|
||||
|
||||
*dtype = DTK_DELTA;
|
||||
ClearPgTm(tm, fsec);
|
||||
@ -140,13 +140,13 @@ DecodeISO8601Interval(char *str,
|
||||
str++;
|
||||
while (*str)
|
||||
{
|
||||
char *fieldstart;
|
||||
int val;
|
||||
double fval;
|
||||
char unit;
|
||||
int dterr;
|
||||
char *fieldstart;
|
||||
int val;
|
||||
double fval;
|
||||
char unit;
|
||||
int dterr;
|
||||
|
||||
if (*str == 'T') /* T indicates the beginning of the time part */
|
||||
if (*str == 'T') /* T indicates the beginning of the time part */
|
||||
{
|
||||
datepart = false;
|
||||
havefield = false;
|
||||
@ -160,14 +160,14 @@ DecodeISO8601Interval(char *str,
|
||||
return dterr;
|
||||
|
||||
/*
|
||||
* Note: we could step off the end of the string here. Code below
|
||||
* Note: we could step off the end of the string here. Code below
|
||||
* *must* exit the loop if unit == '\0'.
|
||||
*/
|
||||
unit = *str++;
|
||||
|
||||
if (datepart)
|
||||
{
|
||||
switch (unit) /* before T: Y M W D */
|
||||
switch (unit) /* before T: Y M W D */
|
||||
{
|
||||
case 'Y':
|
||||
tm->tm_year += val;
|
||||
@ -185,12 +185,12 @@ DecodeISO8601Interval(char *str,
|
||||
tm->tm_mday += val;
|
||||
AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
|
||||
break;
|
||||
case 'T': /* ISO 8601 4.4.3.3 Alternative Format / Basic */
|
||||
case 'T': /* ISO 8601 4.4.3.3 Alternative Format / Basic */
|
||||
case '\0':
|
||||
if (ISO8601IntegerWidth(fieldstart) == 8 && !havefield)
|
||||
{
|
||||
tm->tm_year += val / 10000;
|
||||
tm->tm_mon += (val / 100) % 100;
|
||||
tm->tm_mon += (val / 100) % 100;
|
||||
tm->tm_mday += val % 100;
|
||||
AdjustFractSeconds(fval, tm, fsec, SECS_PER_DAY);
|
||||
if (unit == '\0')
|
||||
@ -200,12 +200,13 @@ DecodeISO8601Interval(char *str,
|
||||
continue;
|
||||
}
|
||||
/* Else fall through to extended alternative format */
|
||||
case '-': /* ISO 8601 4.4.3.3 Alternative Format, Extended */
|
||||
case '-': /* ISO 8601 4.4.3.3 Alternative Format,
|
||||
* Extended */
|
||||
if (havefield)
|
||||
return DTERR_BAD_FORMAT;
|
||||
|
||||
tm->tm_year += val;
|
||||
tm->tm_mon += (fval * 12);
|
||||
tm->tm_mon += (fval * 12);
|
||||
if (unit == '\0')
|
||||
return 0;
|
||||
if (unit == 'T')
|
||||
@ -218,7 +219,7 @@ DecodeISO8601Interval(char *str,
|
||||
dterr = ParseISO8601Number(str, &str, &val, &fval);
|
||||
if (dterr)
|
||||
return dterr;
|
||||
tm->tm_mon += val;
|
||||
tm->tm_mon += val;
|
||||
AdjustFractDays(fval, tm, fsec, DAYS_PER_MONTH);
|
||||
if (*str == '\0')
|
||||
return 0;
|
||||
@ -231,7 +232,7 @@ DecodeISO8601Interval(char *str,
|
||||
if (*str != '-')
|
||||
return DTERR_BAD_FORMAT;
|
||||
str++;
|
||||
|
||||
|
||||
dterr = ParseISO8601Number(str, &str, &val, &fval);
|
||||
if (dterr)
|
||||
return dterr;
|
||||
@ -253,7 +254,7 @@ DecodeISO8601Interval(char *str,
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (unit) /* after T: H M S */
|
||||
switch (unit) /* after T: H M S */
|
||||
{
|
||||
case 'H':
|
||||
tm->tm_hour += val;
|
||||
@ -267,17 +268,18 @@ DecodeISO8601Interval(char *str,
|
||||
tm->tm_sec += val;
|
||||
AdjustFractSeconds(fval, tm, fsec, 1);
|
||||
break;
|
||||
case '\0': /* ISO 8601 4.4.3.3 Alternative Format */
|
||||
if (ISO8601IntegerWidth(fieldstart) == 6 && !havefield)
|
||||
case '\0': /* ISO 8601 4.4.3.3 Alternative Format */
|
||||
if (ISO8601IntegerWidth(fieldstart) == 6 && !havefield)
|
||||
{
|
||||
tm->tm_hour += val / 10000;
|
||||
tm->tm_min += (val / 100) % 100;
|
||||
tm->tm_sec += val % 100;
|
||||
tm->tm_min += (val / 100) % 100;
|
||||
tm->tm_sec += val % 100;
|
||||
AdjustFractSeconds(fval, tm, fsec, 1);
|
||||
return 0;
|
||||
}
|
||||
/* Else fall through to extended alternative format */
|
||||
case ':': /* ISO 8601 4.4.3.3 Alternative Format, Extended */
|
||||
case ':': /* ISO 8601 4.4.3.3 Alternative Format,
|
||||
* Extended */
|
||||
if (havefield)
|
||||
return DTERR_BAD_FORMAT;
|
||||
|
||||
@ -285,22 +287,22 @@ DecodeISO8601Interval(char *str,
|
||||
AdjustFractSeconds(fval, tm, fsec, SECS_PER_HOUR);
|
||||
if (unit == '\0')
|
||||
return 0;
|
||||
|
||||
|
||||
dterr = ParseISO8601Number(str, &str, &val, &fval);
|
||||
if (dterr)
|
||||
return dterr;
|
||||
tm->tm_min += val;
|
||||
tm->tm_min += val;
|
||||
AdjustFractSeconds(fval, tm, fsec, SECS_PER_MINUTE);
|
||||
if (*str == '\0')
|
||||
return 0;
|
||||
if (*str != ':')
|
||||
return DTERR_BAD_FORMAT;
|
||||
str++;
|
||||
|
||||
|
||||
dterr = ParseISO8601Number(str, &str, &val, &fval);
|
||||
if (dterr)
|
||||
return dterr;
|
||||
tm->tm_sec += val;
|
||||
tm->tm_sec += val;
|
||||
AdjustFractSeconds(fval, tm, fsec, 1);
|
||||
if (*str == '\0')
|
||||
return 0;
|
||||
@ -323,25 +325,25 @@ DecodeISO8601Interval(char *str,
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
* with 3 exceptions
|
||||
*
|
||||
* * changesd struct pg_tm to struct tm
|
||||
* * changesd struct pg_tm to struct tm
|
||||
*
|
||||
* * ECPG code called this without a 'range' parameter
|
||||
* removed 'int range' from the argument list and
|
||||
* places where DecodeTime is called; and added
|
||||
* int range = INTERVAL_FULL_RANGE;
|
||||
* * ECPG code called this without a 'range' parameter
|
||||
* removed 'int range' from the argument list and
|
||||
* places where DecodeTime is called; and added
|
||||
* int range = INTERVAL_FULL_RANGE;
|
||||
*
|
||||
* * ECPG semes not to have a global IntervalStyle
|
||||
* so added
|
||||
* int IntervalStyle = INTSTYLE_POSTGRES;
|
||||
* * ECPG semes not to have a global IntervalStyle
|
||||
* so added
|
||||
* int IntervalStyle = INTSTYLE_POSTGRES;
|
||||
*
|
||||
* * Assert wasn't available so removed it.
|
||||
* * Assert wasn't available so removed it.
|
||||
*/
|
||||
int
|
||||
DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
int *dtype, struct /*pg_*/tm * tm, fsec_t *fsec)
|
||||
DecodeInterval(char **field, int *ftype, int nf, /* int range, */
|
||||
int *dtype, struct /* pg_ */ tm * tm, fsec_t *fsec)
|
||||
{
|
||||
int IntervalStyle = INTSTYLE_POSTGRES_VERBOSE;
|
||||
int range = INTERVAL_FULL_RANGE;
|
||||
int IntervalStyle = INTSTYLE_POSTGRES_VERBOSE;
|
||||
int range = INTERVAL_FULL_RANGE;
|
||||
bool is_before = FALSE;
|
||||
char *cp;
|
||||
int fmask = 0,
|
||||
@ -354,7 +356,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
|
||||
*dtype = DTK_DELTA;
|
||||
type = IGNORE_DTF;
|
||||
ClearPgTm(tm,fsec);
|
||||
ClearPgTm(tm, fsec);
|
||||
|
||||
/* read through list backwards to pick up units before values */
|
||||
for (i = nf - 1; i >= 0; i--)
|
||||
@ -362,7 +364,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
switch (ftype[i])
|
||||
{
|
||||
case DTK_TIME:
|
||||
dterr = DecodeTime(field[i], /* range, */
|
||||
dterr = DecodeTime(field[i], /* range, */
|
||||
&tmask, tm, fsec);
|
||||
if (dterr)
|
||||
return dterr;
|
||||
@ -372,19 +374,19 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
case DTK_TZ:
|
||||
|
||||
/*
|
||||
* Timezone is a token with a leading sign character and
|
||||
* at least one digit; there could be ':', '.', '-'
|
||||
* embedded in it as well.
|
||||
* Timezone is a token with a leading sign character and at
|
||||
* least one digit; there could be ':', '.', '-' embedded in
|
||||
* it as well.
|
||||
*/
|
||||
/* Assert(*field[i] == '-' || *field[i] == '+'); */
|
||||
|
||||
/*
|
||||
* Try for hh:mm or hh:mm:ss. If not, fall through to
|
||||
* DTK_NUMBER case, which can handle signed float numbers
|
||||
* and signed year-month values.
|
||||
* DTK_NUMBER case, which can handle signed float numbers and
|
||||
* signed year-month values.
|
||||
*/
|
||||
if (strchr(field[i] + 1, ':') != NULL &&
|
||||
DecodeTime(field[i] + 1, /* INTERVAL_FULL_RANGE, */
|
||||
DecodeTime(field[i] + 1, /* INTERVAL_FULL_RANGE, */
|
||||
&tmask, tm, fsec) == 0)
|
||||
{
|
||||
if (*field[i] == '-')
|
||||
@ -453,7 +455,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
if (*cp == '-')
|
||||
{
|
||||
/* SQL "years-months" syntax */
|
||||
int val2;
|
||||
int val2;
|
||||
|
||||
val2 = strtoi(cp + 1, &cp, 10);
|
||||
if (errno == ERANGE || val2 < 0 || val2 >= MONTHS_PER_YEAR)
|
||||
@ -642,7 +644,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
|
||||
/*----------
|
||||
* The SQL standard defines the interval literal
|
||||
* '-1 1:00:00'
|
||||
* '-1 1:00:00'
|
||||
* to mean "negative 1 days and negative 1 hours", while Postgres
|
||||
* traditionally treats this as meaning "negative 1 days and positive
|
||||
* 1 hours". In SQL_STANDARD intervalstyle, we apply the leading sign
|
||||
@ -652,14 +654,14 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
* This protects us against misinterpreting postgres-style dump output,
|
||||
* since the postgres-style output code has always put an explicit sign on
|
||||
* all fields following a negative field. But note that SQL-spec output
|
||||
* is ambiguous and can be misinterpreted on load! (So it's best practice
|
||||
* is ambiguous and can be misinterpreted on load! (So it's best practice
|
||||
* to dump in postgres style, not SQL style.)
|
||||
*----------
|
||||
*/
|
||||
if (IntervalStyle == INTSTYLE_SQL_STANDARD && *field[0] == '-')
|
||||
{
|
||||
/* Check for additional explicit signs */
|
||||
bool more_signs = false;
|
||||
bool more_signs = false;
|
||||
|
||||
for (i = 1; i < nf; i++)
|
||||
{
|
||||
@ -673,8 +675,8 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
|
||||
if (!more_signs)
|
||||
{
|
||||
/*
|
||||
* Rather than re-determining which field was field[0], just
|
||||
* force 'em all negative.
|
||||
* Rather than re-determining which field was field[0], just force
|
||||
* 'em all negative.
|
||||
*/
|
||||
if (*fsec > 0)
|
||||
*fsec = -(*fsec);
|
||||
@ -742,9 +744,10 @@ AddPostgresIntPart(char *cp, int value, const char *units,
|
||||
value,
|
||||
units,
|
||||
(value != 1) ? "s" : "");
|
||||
|
||||
/*
|
||||
* Each nonzero field sets is_before for (only) the next one. This is
|
||||
* a tad bizarre but it's how it worked before...
|
||||
* Each nonzero field sets is_before for (only) the next one. This is a
|
||||
* tad bizarre but it's how it worked before...
|
||||
*/
|
||||
*is_before = (value < 0);
|
||||
*is_zero = FALSE;
|
||||
@ -791,21 +794,21 @@ AppendSeconds(char *cp, int sec, fsec_t fsec, int precision, bool fillzeros)
|
||||
|
||||
|
||||
/* copy&pasted from .../src/backend/utils/adt/datetime.c
|
||||
*
|
||||
*
|
||||
* Change pg_tm to tm
|
||||
*/
|
||||
|
||||
int
|
||||
EncodeInterval(struct /*pg_*/tm * tm, fsec_t fsec, int style, char *str)
|
||||
EncodeInterval(struct /* pg_ */ tm * tm, fsec_t fsec, int style, char *str)
|
||||
{
|
||||
|
||||
char *cp = str;
|
||||
int year = tm->tm_year;
|
||||
int mon = tm->tm_mon;
|
||||
int mon = tm->tm_mon;
|
||||
int mday = tm->tm_mday;
|
||||
int hour = tm->tm_hour;
|
||||
int min = tm->tm_min;
|
||||
int sec = tm->tm_sec;
|
||||
int min = tm->tm_min;
|
||||
int sec = tm->tm_sec;
|
||||
bool is_before = FALSE;
|
||||
bool is_zero = TRUE;
|
||||
|
||||
@ -817,21 +820,21 @@ EncodeInterval(struct /*pg_*/tm * tm, fsec_t fsec, int style, char *str)
|
||||
*/
|
||||
switch (style)
|
||||
{
|
||||
/* SQL Standard interval format */
|
||||
/* SQL Standard interval format */
|
||||
case INTSTYLE_SQL_STANDARD:
|
||||
{
|
||||
bool has_negative = year < 0 || mon < 0 ||
|
||||
mday < 0 || hour < 0 ||
|
||||
min < 0 || sec < 0 || fsec < 0;
|
||||
bool has_positive = year > 0 || mon > 0 ||
|
||||
mday > 0 || hour > 0 ||
|
||||
min > 0 || sec > 0 || fsec > 0;
|
||||
bool has_year_month = year != 0 || mon != 0;
|
||||
bool has_day_time = mday != 0 || hour != 0 ||
|
||||
min != 0 || sec != 0 || fsec != 0;
|
||||
bool has_day = mday != 0;
|
||||
bool sql_standard_value = !(has_negative && has_positive) &&
|
||||
!(has_year_month && has_day_time);
|
||||
bool has_negative = year < 0 || mon < 0 ||
|
||||
mday < 0 || hour < 0 ||
|
||||
min < 0 || sec < 0 || fsec < 0;
|
||||
bool has_positive = year > 0 || mon > 0 ||
|
||||
mday > 0 || hour > 0 ||
|
||||
min > 0 || sec > 0 || fsec > 0;
|
||||
bool has_year_month = year != 0 || mon != 0;
|
||||
bool has_day_time = mday != 0 || hour != 0 ||
|
||||
min != 0 || sec != 0 || fsec != 0;
|
||||
bool has_day = mday != 0;
|
||||
bool sql_standard_value = !(has_negative && has_positive) &&
|
||||
!(has_year_month && has_day_time);
|
||||
|
||||
/*
|
||||
* SQL Standard wants only 1 "<sign>" preceding the whole
|
||||
@ -841,11 +844,11 @@ EncodeInterval(struct /*pg_*/tm * tm, fsec_t fsec, int style, char *str)
|
||||
{
|
||||
*cp++ = '-';
|
||||
year = -year;
|
||||
mon = -mon;
|
||||
mon = -mon;
|
||||
mday = -mday;
|
||||
hour = -hour;
|
||||
min = -min;
|
||||
sec = -sec;
|
||||
min = -min;
|
||||
sec = -sec;
|
||||
fsec = -fsec;
|
||||
}
|
||||
|
||||
@ -856,15 +859,14 @@ EncodeInterval(struct /*pg_*/tm * tm, fsec_t fsec, int style, char *str)
|
||||
else if (!sql_standard_value)
|
||||
{
|
||||
/*
|
||||
* For non sql-standard interval values,
|
||||
* force outputting the signs to avoid
|
||||
* ambiguities with intervals with mixed
|
||||
* sign components.
|
||||
* For non sql-standard interval values, force outputting
|
||||
* the signs to avoid ambiguities with intervals with
|
||||
* mixed sign components.
|
||||
*/
|
||||
char year_sign = (year < 0 || mon < 0) ? '-' : '+';
|
||||
char day_sign = (mday < 0) ? '-' : '+';
|
||||
char sec_sign = (hour < 0 || min < 0 ||
|
||||
sec < 0 || fsec < 0) ? '-' : '+';
|
||||
char year_sign = (year < 0 || mon < 0) ? '-' : '+';
|
||||
char day_sign = (mday < 0) ? '-' : '+';
|
||||
char sec_sign = (hour < 0 || min < 0 ||
|
||||
sec < 0 || fsec < 0) ? '-' : '+';
|
||||
|
||||
sprintf(cp, "%c%d-%d %c%d %c%d:%02d:",
|
||||
year_sign, abs(year), abs(mon),
|
||||
@ -892,23 +894,23 @@ EncodeInterval(struct /*pg_*/tm * tm, fsec_t fsec, int style, char *str)
|
||||
}
|
||||
break;
|
||||
|
||||
/* ISO 8601 "time-intervals by duration only" */
|
||||
/* ISO 8601 "time-intervals by duration only" */
|
||||
case INTSTYLE_ISO_8601:
|
||||
/* special-case zero to avoid printing nothing */
|
||||
if (year == 0 && mon == 0 && mday == 0 &&
|
||||
hour == 0 && min == 0 && sec == 0 && fsec == 0)
|
||||
hour == 0 && min == 0 && sec == 0 && fsec == 0)
|
||||
{
|
||||
sprintf(cp, "PT0S");
|
||||
break;
|
||||
}
|
||||
*cp++ = 'P';
|
||||
cp = AddISO8601IntPart(cp, year, 'Y');
|
||||
cp = AddISO8601IntPart(cp, mon , 'M');
|
||||
cp = AddISO8601IntPart(cp, mon, 'M');
|
||||
cp = AddISO8601IntPart(cp, mday, 'D');
|
||||
if (hour != 0 || min != 0 || sec != 0 || fsec != 0)
|
||||
*cp++ = 'T';
|
||||
cp = AddISO8601IntPart(cp, hour, 'H');
|
||||
cp = AddISO8601IntPart(cp, min , 'M');
|
||||
cp = AddISO8601IntPart(cp, min, 'M');
|
||||
if (sec != 0 || fsec != 0)
|
||||
{
|
||||
if (sec < 0 || fsec < 0)
|
||||
@ -920,14 +922,14 @@ EncodeInterval(struct /*pg_*/tm * tm, fsec_t fsec, int style, char *str)
|
||||
}
|
||||
break;
|
||||
|
||||
/* Compatible with postgresql < 8.4 when DateStyle = 'iso' */
|
||||
/* Compatible with postgresql < 8.4 when DateStyle = 'iso' */
|
||||
case INTSTYLE_POSTGRES:
|
||||
cp = AddPostgresIntPart(cp, year, "year", &is_zero, &is_before);
|
||||
cp = AddPostgresIntPart(cp, mon, "mon", &is_zero, &is_before);
|
||||
cp = AddPostgresIntPart(cp, mday, "day", &is_zero, &is_before);
|
||||
if (is_zero || hour != 0 || min != 0 || sec != 0 || fsec != 0)
|
||||
{
|
||||
bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0);
|
||||
bool minus = (hour < 0 || min < 0 || sec < 0 || fsec < 0);
|
||||
|
||||
sprintf(cp, "%s%s%02d:%02d:",
|
||||
is_zero ? "" : " ",
|
||||
@ -938,7 +940,7 @@ EncodeInterval(struct /*pg_*/tm * tm, fsec_t fsec, int style, char *str)
|
||||
}
|
||||
break;
|
||||
|
||||
/* Compatible with postgresql < 8.4 when DateStyle != 'iso' */
|
||||
/* Compatible with postgresql < 8.4 when DateStyle != 'iso' */
|
||||
case INTSTYLE_POSTGRES_VERBOSE:
|
||||
default:
|
||||
strcpy(cp, "@");
|
||||
@ -1133,7 +1135,7 @@ PGTYPESinterval_to_asc(interval * span)
|
||||
*tm = &tt;
|
||||
fsec_t fsec;
|
||||
char buf[MAXDATELEN + 1];
|
||||
int IntervalStyle = INTSTYLE_POSTGRES_VERBOSE;
|
||||
int IntervalStyle = INTSTYLE_POSTGRES_VERBOSE;
|
||||
|
||||
if (interval2tm(*span, tm, &fsec) != 0)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.44 2009/05/20 16:13:18 meskes Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.45 2009/06/11 14:49:13 momjian Exp $
|
||||
*/
|
||||
#include "postgres_fe.h"
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* keywords.c
|
||||
* lexical token lookup for reserved words in postgres embedded SQL
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.22 2008/05/20 23:17:32 meskes Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/c_keywords.c,v 1.23 2009/06/11 14:49:13 momjian Exp $
|
||||
* §
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -22,8 +22,11 @@
|
||||
*/
|
||||
static const ScanKeyword ScanCKeywords[] = {
|
||||
/* name, value, category */
|
||||
/* category is not needed in ecpg, it is only here so we can share
|
||||
* the data structure with the backend */
|
||||
|
||||
/*
|
||||
* category is not needed in ecpg, it is only here so we can share the
|
||||
* data structure with the backend
|
||||
*/
|
||||
{"VARCHAR", VARCHAR, 0},
|
||||
{"auto", S_AUTO, 0},
|
||||
{"bool", SQL_BOOL, 0},
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.109 2009/02/25 13:03:07 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.110 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
|
||||
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
|
||||
@ -36,7 +36,7 @@ help(const char *progname)
|
||||
printf(_("%s is the PostgreSQL embedded SQL preprocessor for C programs.\n\n"),
|
||||
progname);
|
||||
printf(_("Usage:\n"
|
||||
" %s [OPTION]... FILE...\n\n"),
|
||||
" %s [OPTION]... FILE...\n\n"),
|
||||
progname);
|
||||
printf(_("Options:\n"));
|
||||
printf(_(" -c automatically generate C code from embedded SQL code;\n"
|
||||
@ -52,13 +52,13 @@ help(const char *progname)
|
||||
printf(_(" -I DIRECTORY search DIRECTORY for include files\n"));
|
||||
printf(_(" -o OUTFILE write result to OUTFILE\n"));
|
||||
printf(_(" -r OPTION specify run-time behavior; OPTION can be:\n"
|
||||
" \"no_indicator\", \"prepare\", \"questionmarks\"\n"));
|
||||
" \"no_indicator\", \"prepare\", \"questionmarks\"\n"));
|
||||
printf(_(" --regression run in regression testing mode\n"));
|
||||
printf(_(" -t turn on autocommit of transactions\n"));
|
||||
printf(_(" --help show this help, then exit\n"));
|
||||
printf(_(" --version output version information, then exit\n"));
|
||||
printf(_("\nIf no output file is specified, the name is formed by adding .c to the\n"
|
||||
"input file name, after stripping off .pgc if present.\n"));
|
||||
"input file name, after stripping off .pgc if present.\n"));
|
||||
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
|
||||
}
|
||||
|
||||
@ -455,10 +455,9 @@ main(int argc, char *const argv[])
|
||||
/* and parse the source */
|
||||
base_yyparse();
|
||||
|
||||
/*
|
||||
* Check whether all cursors were indeed opened. It
|
||||
* does not really make sense to declare a cursor but
|
||||
* not open it.
|
||||
/*
|
||||
* Check whether all cursors were indeed opened. It does not
|
||||
* really make sense to declare a cursor but not open it.
|
||||
*/
|
||||
for (ptr = cur; ptr != NULL; ptr = ptr->next)
|
||||
if (!(ptr->opened))
|
||||
|
@ -4,7 +4,7 @@
|
||||
* lexical token lookup for reserved words in postgres embedded SQL
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.39 2008/10/21 08:38:16 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg_keywords.c,v 1.40 2009/06/11 14:49:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,8 +24,11 @@
|
||||
*/
|
||||
static const ScanKeyword ScanECPGKeywords[] = {
|
||||
/* name, value, category */
|
||||
/* category is not needed in ecpg, it is only here so we can share
|
||||
* the data structure with the backend */
|
||||
|
||||
/*
|
||||
* category is not needed in ecpg, it is only here so we can share the
|
||||
* data structure with the backend
|
||||
*/
|
||||
{"allocate", SQL_ALLOCATE, 0},
|
||||
{"autocommit", SQL_AUTOCOMMIT, 0},
|
||||
{"bool", SQL_BOOL, 0},
|
||||
@ -60,7 +63,7 @@ static const ScanKeyword ScanECPGKeywords[] = {
|
||||
{"section", SQL_SECTION, 0},
|
||||
{"short", SQL_SHORT, 0},
|
||||
{"signed", SQL_SIGNED, 0},
|
||||
{"sql", SQL_SQL, 0}, /* strange thing, used for into sql descriptor
|
||||
{"sql", SQL_SQL, 0}, /* strange thing, used for into sql descriptor
|
||||
* MYDESC; */
|
||||
{"sqlerror", SQL_SQLERROR, 0},
|
||||
{"sqlprint", SQL_SQLPRINT, 0},
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.72 2009/06/03 20:24:51 tgl Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/extern.h,v 1.73 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#ifndef _ECPG_PREPROC_EXTERN_H
|
||||
#define _ECPG_PREPROC_EXTERN_H
|
||||
@ -74,7 +74,8 @@ extern int base_yylex(void);
|
||||
extern void base_yyerror(const char *);
|
||||
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
|
||||
extern char *mm_strdup(const char *);
|
||||
extern void mmerror(int, enum errortype, const char *, ...)
|
||||
extern void
|
||||
mmerror(int, enum errortype, const char *,...)
|
||||
/* This extension allows gcc to check the format string */
|
||||
__attribute__((format(printf, 3, 4)));
|
||||
extern void output_get_descr_header(char *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.24 2008/03/20 15:56:59 meskes Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/output.c,v 1.25 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@ -194,15 +194,21 @@ output_escaped_str(char *str, bool quoted)
|
||||
fputs("\\\n", yyout);
|
||||
else if (str[i] == '\\')
|
||||
{
|
||||
int j = i;
|
||||
|
||||
/* check whether this is a continuation line
|
||||
* if it is, do not output anything because newlines are escaped anyway */
|
||||
int j = i;
|
||||
|
||||
/*
|
||||
* check whether this is a continuation line if it is, do not
|
||||
* output anything because newlines are escaped anyway
|
||||
*/
|
||||
|
||||
/* accept blanks after the '\' as some other compilers do too */
|
||||
do { j++; } while (str[j] == ' ' || str[j] == '\t');
|
||||
do
|
||||
{
|
||||
j++;
|
||||
} while (str[j] == ' ' || str[j] == '\t');
|
||||
|
||||
if ((str[j] != '\n') && (str[j] != '\r' || str[j + 1] != '\n')) /* not followed by a newline */
|
||||
if ((str[j] != '\n') && (str[j] != '\r' || str[j + 1] != '\n')) /* not followed by a
|
||||
* newline */
|
||||
fputs("\\\\", yyout);
|
||||
}
|
||||
else if (str[i] == '\r' && str[i + 1] == '\n')
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.82 2009/01/23 12:43:32 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.83 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@ -242,7 +242,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
|
||||
switch (type->u.element->type)
|
||||
{
|
||||
case ECPGt_array:
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "nested arrays are not supported (except strings)"); /* array of array */
|
||||
mmerror(PARSE_ERROR, ET_ERROR, "nested arrays are not supported (except strings)"); /* array of array */
|
||||
break;
|
||||
case ECPGt_struct:
|
||||
case ECPGt_union:
|
||||
@ -327,9 +327,10 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
|
||||
fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
|
||||
else
|
||||
{
|
||||
char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
|
||||
char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1 + strlen(varcharsize) + sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var_name, *ptr;
|
||||
char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
|
||||
char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1 + strlen(varcharsize) + sizeof(int) * CHAR_BIT * 10 / 3);
|
||||
char *var_name,
|
||||
*ptr;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@ -354,7 +355,8 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
|
||||
/* remove trailing [] is name is array element */
|
||||
var_name = mm_strdup(name);
|
||||
ptr = strchr(var_name, '[');
|
||||
if (ptr) *ptr = '\0';
|
||||
if (ptr)
|
||||
*ptr = '\0';
|
||||
if (lineno)
|
||||
sprintf(offset, "sizeof(struct varchar_%s_%d)", var_name, lineno);
|
||||
else
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.50 2008/05/20 23:17:32 meskes Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.51 2009/06/11 14:49:13 momjian Exp $
|
||||
*/
|
||||
#ifndef _ECPG_PREPROC_TYPE_H
|
||||
#define _ECPG_PREPROC_TYPE_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.48 2009/03/26 22:26:08 petere Exp $ */
|
||||
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.49 2009/06/11 14:49:13 momjian Exp $ */
|
||||
|
||||
#include "postgres_fe.h"
|
||||
|
||||
@ -497,8 +497,8 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
|
||||
|
||||
if (pointer_len > 2)
|
||||
mmerror(PARSE_ERROR, ET_FATAL, ngettext("multilevel pointers (more than 2 levels) are not supported; found %d level",
|
||||
"multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len),
|
||||
pointer_len);
|
||||
"multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len),
|
||||
pointer_len);
|
||||
|
||||
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char)
|
||||
mmerror(PARSE_ERROR, ET_FATAL, "pointer to pointer is not supported for this data type");
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.141 2009/03/22 18:06:35 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.142 2009/06/11 14:49:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -580,13 +580,14 @@ pg_SSPI_continue(PGconn *conn)
|
||||
}
|
||||
|
||||
/*
|
||||
* If the negotiation is complete, there may be zero bytes to send. The server is
|
||||
* at this point not expecting any more data, so don't send it.
|
||||
* If the negotiation is complete, there may be zero bytes to send.
|
||||
* The server is at this point not expecting any more data, so don't
|
||||
* send it.
|
||||
*/
|
||||
if (outbuf.pBuffers[0].cbBuffer > 0)
|
||||
{
|
||||
if (pqPacketSend(conn, 'p',
|
||||
outbuf.pBuffers[0].pvBuffer, outbuf.pBuffers[0].cbBuffer))
|
||||
outbuf.pBuffers[0].pvBuffer, outbuf.pBuffers[0].cbBuffer))
|
||||
{
|
||||
FreeContextBuffer(outbuf.pBuffers[0].pvBuffer);
|
||||
return STATUS_ERROR;
|
||||
@ -914,7 +915,7 @@ pg_fe_sendauth(AuthRequest areq, PGconn *conn)
|
||||
|
||||
case AUTH_REQ_CRYPT:
|
||||
printfPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("Crypt authentication not supported\n"));
|
||||
libpq_gettext("Crypt authentication not supported\n"));
|
||||
return STATUS_ERROR;
|
||||
|
||||
case AUTH_REQ_MD5:
|
||||
@ -971,12 +972,11 @@ pg_fe_getauthname(PQExpBuffer errorMessage)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some users are using configure
|
||||
* --enable-thread-safety-force, so we might as well do the locking within
|
||||
* our library to protect pqGetpwuid(). In fact, application developers
|
||||
* can use getpwuid() in their application if they use the locking call we
|
||||
* provide, or install their own locking function using
|
||||
* PQregisterThreadLock().
|
||||
* Some users are using configure --enable-thread-safety-force, so we
|
||||
* might as well do the locking within our library to protect
|
||||
* pqGetpwuid(). In fact, application developers can use getpwuid() in
|
||||
* their application if they use the locking call we provide, or install
|
||||
* their own locking function using PQregisterThreadLock().
|
||||
*/
|
||||
pglock_thread();
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.374 2009/05/18 16:15:22 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.375 2009/06/11 14:49:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -176,9 +176,9 @@ static const PQconninfoOption PQconninfoOptions[] = {
|
||||
|
||||
/*
|
||||
* ssl options are allowed even without client SSL support because the
|
||||
* client can still handle SSL modes "disable" and "allow". Other parameters
|
||||
* have no effect on non-SSL connections, so there is no reason to exclude them
|
||||
* since none of them are mandatory.
|
||||
* client can still handle SSL modes "disable" and "allow". Other
|
||||
* parameters have no effect on non-SSL connections, so there is no reason
|
||||
* to exclude them since none of them are mandatory.
|
||||
*/
|
||||
{"sslmode", "PGSSLMODE", DefaultSSLMode, NULL,
|
||||
"SSL-Mode", "", 8}, /* sizeof("disable") == 8 */
|
||||
@ -566,7 +566,7 @@ connectOptions2(PGconn *conn)
|
||||
*
|
||||
* Parse an empty string like PQconnectdb() would do and return the
|
||||
* resulting connection options array, ie, all the default values that are
|
||||
* available from the environment etc. On error (eg out of memory),
|
||||
* available from the environment etc. On error (eg out of memory),
|
||||
* NULL is returned.
|
||||
*
|
||||
* Using this function, an application may determine all possible options
|
||||
@ -949,7 +949,11 @@ connectDBComplete(PGconn *conn)
|
||||
switch (flag)
|
||||
{
|
||||
case PGRES_POLLING_OK:
|
||||
/* Reset stored error messages since we now have a working connection */
|
||||
|
||||
/*
|
||||
* Reset stored error messages since we now have a working
|
||||
* connection
|
||||
*/
|
||||
resetPQExpBuffer(&conn->errorMessage);
|
||||
return 1; /* success! */
|
||||
|
||||
@ -1330,7 +1334,10 @@ keep_going: /* We will come back to here until there is
|
||||
EnvironmentOptions);
|
||||
if (!startpacket)
|
||||
{
|
||||
/* will not appendbuffer here, since it's likely to also run out of memory */
|
||||
/*
|
||||
* will not appendbuffer here, since it's likely to also
|
||||
* run out of memory
|
||||
*/
|
||||
printfPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("out of memory\n"));
|
||||
goto error_return;
|
||||
@ -1407,7 +1414,8 @@ keep_going: /* We will come back to here until there is
|
||||
else if (SSLok == 'N')
|
||||
{
|
||||
if (conn->sslmode[0] == 'r' || /* "require" */
|
||||
conn->sslmode[0] == 'v') /* "verify-ca" or "verify-full" */
|
||||
conn->sslmode[0] == 'v') /* "verify-ca" or
|
||||
* "verify-full" */
|
||||
{
|
||||
/* Require SSL, but server does not want it */
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
@ -1425,7 +1433,8 @@ keep_going: /* We will come back to here until there is
|
||||
if (conn->Pfdebug)
|
||||
fprintf(conn->Pfdebug, "received error from server, attempting fallback to pre-7.0\n");
|
||||
if (conn->sslmode[0] == 'r' || /* "require" */
|
||||
conn->sslmode[0] == 'v') /* "verify-ca" or "verify-full" */
|
||||
conn->sslmode[0] == 'v') /* "verify-ca" or
|
||||
* "verify-full" */
|
||||
{
|
||||
/* Require SSL, but server is too old */
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
@ -2070,7 +2079,7 @@ freePGconn(PGconn *conn)
|
||||
* - properly close a connection to the backend
|
||||
*
|
||||
* This should reset or release all transient state, but NOT the connection
|
||||
* parameters. On exit, the PGconn should be in condition to start a fresh
|
||||
* parameters. On exit, the PGconn should be in condition to start a fresh
|
||||
* connection with the same parameters (see PQreset()).
|
||||
*/
|
||||
static void
|
||||
@ -2206,10 +2215,10 @@ PQreset(PGconn *conn)
|
||||
if (connectDBStart(conn) && connectDBComplete(conn))
|
||||
{
|
||||
/*
|
||||
* Notify event procs of successful reset. We treat an event
|
||||
* proc failure as disabling the connection ... good idea?
|
||||
* Notify event procs of successful reset. We treat an event proc
|
||||
* failure as disabling the connection ... good idea?
|
||||
*/
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < conn->nEvents; i++)
|
||||
{
|
||||
@ -2266,10 +2275,10 @@ PQresetPoll(PGconn *conn)
|
||||
if (status == PGRES_POLLING_OK)
|
||||
{
|
||||
/*
|
||||
* Notify event procs of successful reset. We treat an event
|
||||
* proc failure as disabling the connection ... good idea?
|
||||
* Notify event procs of successful reset. We treat an event proc
|
||||
* failure as disabling the connection ... good idea?
|
||||
*/
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < conn->nEvents; i++)
|
||||
{
|
||||
@ -3139,7 +3148,7 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
|
||||
* PQconninfoParse
|
||||
*
|
||||
* Parse a string like PQconnectdb() would do and return the
|
||||
* resulting connection options array. NULL is returned on failure.
|
||||
* resulting connection options array. NULL is returned on failure.
|
||||
* The result contains only options specified directly in the string,
|
||||
* not any possible default values.
|
||||
*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.202 2009/05/27 14:16:51 meskes Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.203 2009/06/11 14:49:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -64,7 +64,7 @@ static bool PQexecStart(PGconn *conn);
|
||||
static PGresult *PQexecFinish(PGconn *conn);
|
||||
static int PQsendDescribe(PGconn *conn, char desc_type,
|
||||
const char *desc_target);
|
||||
static int check_field_number(const PGresult *res, int field_num);
|
||||
static int check_field_number(const PGresult *res, int field_num);
|
||||
|
||||
|
||||
/* ----------------
|
||||
@ -218,7 +218,7 @@ PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
|
||||
int
|
||||
PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* If attrs already exist, they cannot be overwritten. */
|
||||
if (!res || res->numAttributes > 0)
|
||||
@ -262,29 +262,29 @@ PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
|
||||
* Returns a deep copy of the provided 'src' PGresult, which cannot be NULL.
|
||||
* The 'flags' argument controls which portions of the result will or will
|
||||
* NOT be copied. The created result is always put into the
|
||||
* PGRES_TUPLES_OK status. The source result error message is not copied,
|
||||
* PGRES_TUPLES_OK status. The source result error message is not copied,
|
||||
* although cmdStatus is.
|
||||
*
|
||||
* To set custom attributes, use PQsetResultAttrs. That function requires
|
||||
* To set custom attributes, use PQsetResultAttrs. That function requires
|
||||
* that there are no attrs contained in the result, so to use that
|
||||
* function you cannot use the PG_COPYRES_ATTRS or PG_COPYRES_TUPLES
|
||||
* options with this function.
|
||||
*
|
||||
* Options:
|
||||
* PG_COPYRES_ATTRS - Copy the source result's attributes
|
||||
* PG_COPYRES_ATTRS - Copy the source result's attributes
|
||||
*
|
||||
* PG_COPYRES_TUPLES - Copy the source result's tuples. This implies
|
||||
* copying the attrs, seeeing how the attrs are needed by the tuples.
|
||||
* PG_COPYRES_TUPLES - Copy the source result's tuples. This implies
|
||||
* copying the attrs, seeeing how the attrs are needed by the tuples.
|
||||
*
|
||||
* PG_COPYRES_EVENTS - Copy the source result's events.
|
||||
* PG_COPYRES_EVENTS - Copy the source result's events.
|
||||
*
|
||||
* PG_COPYRES_NOTICEHOOKS - Copy the source result's notice hooks.
|
||||
* PG_COPYRES_NOTICEHOOKS - Copy the source result's notice hooks.
|
||||
*/
|
||||
PGresult *
|
||||
PQcopyResult(const PGresult *src, int flags)
|
||||
{
|
||||
PGresult *dest;
|
||||
int i;
|
||||
PGresult *dest;
|
||||
int i;
|
||||
|
||||
if (!src)
|
||||
return NULL;
|
||||
@ -293,7 +293,7 @@ PQcopyResult(const PGresult *src, int flags)
|
||||
if (!dest)
|
||||
return NULL;
|
||||
|
||||
/* Always copy these over. Is cmdStatus really useful here? */
|
||||
/* Always copy these over. Is cmdStatus really useful here? */
|
||||
dest->client_encoding = src->client_encoding;
|
||||
strcpy(dest->cmdStatus, src->cmdStatus);
|
||||
|
||||
@ -310,7 +310,8 @@ PQcopyResult(const PGresult *src, int flags)
|
||||
/* Wants to copy tuples? */
|
||||
if (flags & PG_COPYRES_TUPLES)
|
||||
{
|
||||
int tup, field;
|
||||
int tup,
|
||||
field;
|
||||
|
||||
for (tup = 0; tup < src->ntups; tup++)
|
||||
{
|
||||
@ -373,8 +374,8 @@ PQcopyResult(const PGresult *src, int flags)
|
||||
static PGEvent *
|
||||
dupEvents(PGEvent *events, int count)
|
||||
{
|
||||
PGEvent *newEvents;
|
||||
int i;
|
||||
PGEvent *newEvents;
|
||||
int i;
|
||||
|
||||
if (!events || count <= 0)
|
||||
return NULL;
|
||||
@ -424,7 +425,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
|
||||
/* need to grow the tuple table? */
|
||||
if (res->ntups >= res->tupArrSize)
|
||||
{
|
||||
int n = res->tupArrSize ? res->tupArrSize * 2 : 128;
|
||||
int n = res->tupArrSize ? res->tupArrSize * 2 : 128;
|
||||
PGresAttValue **tups;
|
||||
|
||||
if (res->tuples)
|
||||
@ -445,7 +446,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
|
||||
if (tup_num == res->ntups && !res->tuples[tup_num])
|
||||
{
|
||||
PGresAttValue *tup;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
tup = (PGresAttValue *)
|
||||
pqResultAlloc(res, res->numAttributes * sizeof(PGresAttValue),
|
||||
@ -661,7 +662,7 @@ void
|
||||
PQclear(PGresult *res)
|
||||
{
|
||||
PGresult_data *block;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!res)
|
||||
return;
|
||||
@ -1600,7 +1601,7 @@ PQgetResult(PGconn *conn)
|
||||
|
||||
if (res)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < res->nEvents; i++)
|
||||
{
|
||||
@ -3115,7 +3116,7 @@ PQescapeByteaInternal(PGconn *conn,
|
||||
{
|
||||
if (*vp < 0x20 || *vp > 0x7e)
|
||||
{
|
||||
int val = *vp;
|
||||
int val = *vp;
|
||||
|
||||
if (!std_strings)
|
||||
*rp++ = '\\';
|
||||
@ -3219,11 +3220,11 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
|
||||
(ISOCTDIGIT(strtext[i + 1])) &&
|
||||
(ISOCTDIGIT(strtext[i + 2])))
|
||||
{
|
||||
int byte;
|
||||
int byte;
|
||||
|
||||
byte = OCTVAL(strtext[i++]);
|
||||
byte = (byte << 3) + OCTVAL(strtext[i++]);
|
||||
byte = (byte << 3) + OCTVAL(strtext[i++]);
|
||||
byte = (byte <<3) +OCTVAL(strtext[i++]);
|
||||
byte = (byte <<3) +OCTVAL(strtext[i++]);
|
||||
buffer[j++] = byte;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.67 2009/01/01 17:24:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.68 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -42,7 +42,7 @@
|
||||
static int lo_initialize(PGconn *conn);
|
||||
|
||||
static Oid
|
||||
lo_import_internal(PGconn *conn, const char *filename, const Oid oid);
|
||||
lo_import_internal(PGconn *conn, const char *filename, const Oid oid);
|
||||
|
||||
/*
|
||||
* lo_open
|
||||
|
@ -23,7 +23,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.139 2009/05/21 12:54:27 meskes Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.140 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -769,10 +769,11 @@ pqSendSome(PGconn *conn, int len)
|
||||
#ifndef WIN32
|
||||
sent = pqsecure_write(conn, ptr, len);
|
||||
#else
|
||||
|
||||
/*
|
||||
* Windows can fail on large sends, per KB article Q201213. The failure-point
|
||||
* appears to be different in different versions of Windows, but 64k should
|
||||
* always be safe.
|
||||
* Windows can fail on large sends, per KB article Q201213. The
|
||||
* failure-point appears to be different in different versions of
|
||||
* Windows, but 64k should always be safe.
|
||||
*/
|
||||
sent = pqsecure_write(conn, ptr, Min(len, 65536));
|
||||
#endif
|
||||
@ -1073,10 +1074,11 @@ pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time)
|
||||
FD_ZERO(&output_mask);
|
||||
FD_ZERO(&except_mask);
|
||||
if (forRead)
|
||||
FD_SET(sock, &input_mask);
|
||||
FD_SET (sock, &input_mask);
|
||||
|
||||
if (forWrite)
|
||||
FD_SET(sock, &output_mask);
|
||||
FD_SET(sock, &except_mask);
|
||||
FD_SET (sock, &output_mask);
|
||||
FD_SET (sock, &except_mask);
|
||||
|
||||
/* Compute appropriate timeout interval */
|
||||
if (end_time == ((time_t) -1))
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.38 2009/01/09 18:50:03 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.39 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -309,7 +309,7 @@ pqParseInput3(PGconn *conn)
|
||||
if (conn->result == NULL)
|
||||
{
|
||||
conn->result = PQmakeEmptyPGresult(conn,
|
||||
PGRES_COMMAND_OK);
|
||||
PGRES_COMMAND_OK);
|
||||
if (!conn->result)
|
||||
return;
|
||||
}
|
||||
@ -1378,7 +1378,7 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
|
||||
for (;;)
|
||||
{
|
||||
/*
|
||||
* Collect the next input message. To make life simpler for async
|
||||
* Collect the next input message. To make life simpler for async
|
||||
* callers, we keep returning 0 until the next message is fully
|
||||
* available, even if it is not Copy Data.
|
||||
*/
|
||||
@ -1387,13 +1387,13 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
|
||||
{
|
||||
/*
|
||||
* On end-of-copy, exit COPY_OUT mode and let caller read status
|
||||
* with PQgetResult(). The normal case is that it's Copy Done,
|
||||
* but we let parseInput read that. If error, we expect the
|
||||
* state was already changed.
|
||||
* with PQgetResult(). The normal case is that it's Copy Done,
|
||||
* but we let parseInput read that. If error, we expect the state
|
||||
* was already changed.
|
||||
*/
|
||||
if (msgLength == -1)
|
||||
conn->asyncStatus = PGASYNC_BUSY;
|
||||
return msgLength; /* end-of-copy or error */
|
||||
return msgLength; /* end-of-copy or error */
|
||||
}
|
||||
if (msgLength == 0)
|
||||
{
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.125 2009/05/03 17:16:58 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.126 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
*
|
||||
@ -111,10 +111,8 @@ static pthread_mutex_t ssl_config_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t ssl_config_mutex = NULL;
|
||||
static long win32_ssl_create_mutex = 0;
|
||||
#endif
|
||||
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
|
||||
#endif /* SSL */
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
#endif /* SSL */
|
||||
|
||||
|
||||
/*
|
||||
@ -141,8 +139,7 @@ static long win32_ssl_create_mutex = 0;
|
||||
|
||||
#define RESTORE_SIGPIPE() \
|
||||
pq_reset_sigpipe(&osigmask, sigpipe_pending, got_epipe)
|
||||
|
||||
#else /* !ENABLE_THREAD_SAFETY */
|
||||
#else /* !ENABLE_THREAD_SAFETY */
|
||||
|
||||
#define DISABLE_SIGPIPE(failaction) \
|
||||
pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN)
|
||||
@ -151,15 +148,13 @@ static long win32_ssl_create_mutex = 0;
|
||||
|
||||
#define RESTORE_SIGPIPE() \
|
||||
pqsignal(SIGPIPE, oldsighandler)
|
||||
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
#else /* WIN32 */
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
#else /* WIN32 */
|
||||
|
||||
#define DISABLE_SIGPIPE(failaction)
|
||||
#define REMEMBER_EPIPE(cond)
|
||||
#define RESTORE_SIGPIPE()
|
||||
|
||||
#endif /* WIN32 */
|
||||
#endif /* WIN32 */
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* Procedures common to all secure sessions */
|
||||
@ -180,14 +175,15 @@ PQinitSSL(int do_init)
|
||||
* Exported function to allow application to tell us it's already
|
||||
* initialized OpenSSL and/or libcrypto.
|
||||
*/
|
||||
void
|
||||
void
|
||||
PQinitOpenSSL(int do_ssl, int do_crypto)
|
||||
{
|
||||
#ifdef USE_SSL
|
||||
#ifdef ENABLE_THREAD_SAFETY
|
||||
|
||||
/*
|
||||
* Disallow changing the flags while we have open connections, else
|
||||
* we'd get completely confused.
|
||||
* Disallow changing the flags while we have open connections, else we'd
|
||||
* get completely confused.
|
||||
*/
|
||||
if (ssl_open_connections != 0)
|
||||
return;
|
||||
@ -473,11 +469,11 @@ verify_cb(int ok, X509_STORE_CTX *ctx)
|
||||
* Check if a wildcard certificate matches the server hostname.
|
||||
*
|
||||
* The rule for this is:
|
||||
* 1. We only match the '*' character as wildcard
|
||||
* 2. We match only wildcards at the start of the string
|
||||
* 3. The '*' character does *not* match '.', meaning that we match only
|
||||
* a single pathname component.
|
||||
* 4. We don't support more than one '*' in a single pattern.
|
||||
* 1. We only match the '*' character as wildcard
|
||||
* 2. We match only wildcards at the start of the string
|
||||
* 3. The '*' character does *not* match '.', meaning that we match only
|
||||
* a single pathname component.
|
||||
* 4. We don't support more than one '*' in a single pattern.
|
||||
*
|
||||
* This is roughly in line with RFC2818, but contrary to what most browsers
|
||||
* appear to be implementing (point 3 being the difference)
|
||||
@ -487,8 +483,8 @@ verify_cb(int ok, X509_STORE_CTX *ctx)
|
||||
static int
|
||||
wildcard_certificate_match(const char *pattern, const char *string)
|
||||
{
|
||||
int lenpat = strlen(pattern);
|
||||
int lenstr = strlen(string);
|
||||
int lenpat = strlen(pattern);
|
||||
int lenstr = strlen(string);
|
||||
|
||||
/* If we don't start with a wildcard, it's not a match (rule 1 & 2) */
|
||||
if (lenpat < 3 ||
|
||||
@ -500,12 +496,20 @@ wildcard_certificate_match(const char *pattern, const char *string)
|
||||
/* If pattern is longer than the string, we can never match */
|
||||
return 0;
|
||||
|
||||
if (pg_strcasecmp(pattern+1, string+lenstr-lenpat+1) != 0)
|
||||
/* If string does not end in pattern (minus the wildcard), we don't match */
|
||||
if (pg_strcasecmp(pattern + 1, string + lenstr - lenpat + 1) != 0)
|
||||
|
||||
/*
|
||||
* If string does not end in pattern (minus the wildcard), we don't
|
||||
* match
|
||||
*/
|
||||
return 0;
|
||||
|
||||
if (strchr(string, '.') < string+lenstr-lenpat)
|
||||
/* If there is a dot left of where the pattern started to match, we don't match (rule 3) */
|
||||
if (strchr(string, '.') < string + lenstr - lenpat)
|
||||
|
||||
/*
|
||||
* If there is a dot left of where the pattern started to match, we
|
||||
* don't match (rule 3)
|
||||
*/
|
||||
return 0;
|
||||
|
||||
/* String ended with pattern, and didn't have a dot before, so we match */
|
||||
@ -520,8 +524,8 @@ static bool
|
||||
verify_peer_name_matches_certificate(PGconn *conn)
|
||||
{
|
||||
/*
|
||||
* If told not to verify the peer name, don't do it. Return
|
||||
* 0 indicating that the verification was successful.
|
||||
* If told not to verify the peer name, don't do it. Return 0 indicating
|
||||
* that the verification was successful.
|
||||
*/
|
||||
if (strcmp(conn->sslmode, "verify-full") != 0)
|
||||
return true;
|
||||
@ -650,10 +654,10 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
||||
BIO_free(bio);
|
||||
|
||||
/*
|
||||
* Read the SSL key. If a key is specified, treat it as an engine:key combination
|
||||
* if there is colon present - we don't support files with colon in the name. The
|
||||
* exception is if the second character is a colon, in which case it can be a Windows
|
||||
* filename with drive specification.
|
||||
* Read the SSL key. If a key is specified, treat it as an engine:key
|
||||
* combination if there is colon present - we don't support files with
|
||||
* colon in the name. The exception is if the second character is a colon,
|
||||
* in which case it can be a Windows filename with drive specification.
|
||||
*/
|
||||
if (conn->sslkey && strlen(conn->sslkey) > 0)
|
||||
{
|
||||
@ -662,15 +666,15 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
||||
#ifdef WIN32
|
||||
&& conn->sslkey[1] != ':'
|
||||
#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
/* Colon, but not in second character, treat as engine:key */
|
||||
ENGINE *engine_ptr;
|
||||
char *engine_str = strdup(conn->sslkey);
|
||||
char *engine_colon = strchr(engine_str, ':');
|
||||
|
||||
*engine_colon = '\0'; /* engine_str now has engine name */
|
||||
engine_colon++; /* engine_colon now has key name */
|
||||
*engine_colon = '\0'; /* engine_str now has engine name */
|
||||
engine_colon++; /* engine_colon now has key name */
|
||||
|
||||
engine_ptr = ENGINE_by_id(engine_str);
|
||||
if (engine_ptr == NULL)
|
||||
@ -678,7 +682,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
||||
char *err = SSLerrmessage();
|
||||
|
||||
printfPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("could not load SSL engine \"%s\": %s\n"),
|
||||
libpq_gettext("could not load SSL engine \"%s\": %s\n"),
|
||||
engine_str, err);
|
||||
SSLerrfree(err);
|
||||
free(engine_str);
|
||||
@ -702,10 +706,11 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
||||
}
|
||||
free(engine_str);
|
||||
|
||||
fnbuf[0] = '\0'; /* indicate we're not going to load from a file */
|
||||
fnbuf[0] = '\0'; /* indicate we're not going to load from a
|
||||
* file */
|
||||
}
|
||||
else
|
||||
#endif /* support for SSL engines */
|
||||
#endif /* support for SSL engines */
|
||||
{
|
||||
/* PGSSLKEY is not an engine, treat it as a filename */
|
||||
strncpy(fnbuf, conn->sslkey, sizeof(fnbuf));
|
||||
@ -733,7 +738,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
|
||||
if (!S_ISREG(buf.st_mode) || buf.st_mode & (S_IRWXG | S_IRWXO))
|
||||
{
|
||||
printfPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("private key file \"%s\" has group or world access; permissions should be u=rw (0600) or less\n"),
|
||||
libpq_gettext("private key file \"%s\" has group or world access; permissions should be u=rw (0600) or less\n"),
|
||||
fnbuf);
|
||||
ERR_pop_to_mark();
|
||||
return 0;
|
||||
@ -869,7 +874,7 @@ init_ssl_system(PGconn *conn)
|
||||
*/
|
||||
if (pq_lockarray == NULL)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
pq_lockarray = malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());
|
||||
if (!pq_lockarray)
|
||||
@ -896,7 +901,7 @@ init_ssl_system(PGconn *conn)
|
||||
CRYPTO_set_locking_callback(pq_lockingcallback);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
#endif /* ENABLE_THREAD_SAFETY */
|
||||
|
||||
if (!SSL_context)
|
||||
{
|
||||
@ -959,12 +964,11 @@ destroy_ssl_system(void)
|
||||
CRYPTO_set_id_callback(NULL);
|
||||
|
||||
/*
|
||||
* We don't free the lock array. If we get another connection
|
||||
* in this process, we will just re-use it with the existing
|
||||
* mutexes.
|
||||
* We don't free the lock array. If we get another connection in this
|
||||
* process, we will just re-use it with the existing mutexes.
|
||||
*
|
||||
* This means we leak a little memory on repeated load/unload
|
||||
* of the library.
|
||||
* This means we leak a little memory on repeated load/unload of the
|
||||
* library.
|
||||
*/
|
||||
}
|
||||
|
||||
@ -991,15 +995,16 @@ initialize_SSL(PGconn *conn)
|
||||
* verification. If set to "verify-full" we will also do further
|
||||
* verification after the connection has been completed.
|
||||
*
|
||||
* If we are going to look for either root certificate or CRL in the home directory,
|
||||
* we need pqGetHomeDirectory() to succeed. In other cases, we don't need to
|
||||
* get the home directory explicitly.
|
||||
* If we are going to look for either root certificate or CRL in the home
|
||||
* directory, we need pqGetHomeDirectory() to succeed. In other cases, we
|
||||
* don't need to get the home directory explicitly.
|
||||
*/
|
||||
if (!conn->sslrootcert || !conn->sslcrl)
|
||||
{
|
||||
if (!pqGetHomeDirectory(homedir, sizeof(homedir)))
|
||||
{
|
||||
if (conn->sslmode[0] == 'v') /* "verify-ca" or "verify-full" */
|
||||
if (conn->sslmode[0] == 'v') /* "verify-ca" or
|
||||
* "verify-full" */
|
||||
{
|
||||
printfPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("could not get home directory to locate root certificate file"));
|
||||
@ -1044,7 +1049,7 @@ initialize_SSL(PGconn *conn)
|
||||
/* OpenSSL 0.96 does not support X509_V_FLAG_CRL_CHECK */
|
||||
#ifdef X509_V_FLAG_CRL_CHECK
|
||||
X509_STORE_set_flags(cvstore,
|
||||
X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
|
||||
X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL);
|
||||
/* if not found, silently ignore; we do not require CRL */
|
||||
#else
|
||||
{
|
||||
@ -1064,10 +1069,10 @@ initialize_SSL(PGconn *conn)
|
||||
else
|
||||
{
|
||||
/* stat() failed; assume cert file doesn't exist */
|
||||
if (conn->sslmode[0] == 'v') /* "verify-ca" or "verify-full" */
|
||||
if (conn->sslmode[0] == 'v') /* "verify-ca" or "verify-full" */
|
||||
{
|
||||
printfPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("root certificate file \"%s\" does not exist\n"
|
||||
libpq_gettext("root certificate file \"%s\" does not exist\n"
|
||||
"Either provide the file or change sslmode to disable server certificate verification.\n"), fnbuf);
|
||||
return -1;
|
||||
}
|
||||
@ -1153,8 +1158,8 @@ open_client_SSL(PGconn *conn)
|
||||
}
|
||||
|
||||
/*
|
||||
* We already checked the server certificate in initialize_SSL()
|
||||
* using SSL_CTX_set_verify() if root.crt exists.
|
||||
* We already checked the server certificate in initialize_SSL() using
|
||||
* SSL_CTX_set_verify() if root.crt exists.
|
||||
*/
|
||||
|
||||
/* pull out server distinguished and common names */
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.c,v 1.4 2009/01/01 17:24:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.c,v 1.5 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -40,7 +40,7 @@ int
|
||||
PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
const char *name, void *passThrough)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
PGEventRegister regevt;
|
||||
|
||||
if (!proc || !conn || !name || !*name)
|
||||
@ -54,8 +54,8 @@ PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
|
||||
if (conn->nEvents >= conn->eventArraySize)
|
||||
{
|
||||
PGEvent *e;
|
||||
int newSize;
|
||||
PGEvent *e;
|
||||
int newSize;
|
||||
|
||||
newSize = conn->eventArraySize ? conn->eventArraySize * 2 : 8;
|
||||
if (conn->events)
|
||||
@ -97,7 +97,7 @@ PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
int
|
||||
PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!conn || !proc)
|
||||
return FALSE;
|
||||
@ -120,7 +120,7 @@ PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data)
|
||||
void *
|
||||
PQinstanceData(const PGconn *conn, PGEventProc proc)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!conn || !proc)
|
||||
return NULL;
|
||||
@ -141,7 +141,7 @@ PQinstanceData(const PGconn *conn, PGEventProc proc)
|
||||
int
|
||||
PQresultSetInstanceData(PGresult *result, PGEventProc proc, void *data)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!result || !proc)
|
||||
return FALSE;
|
||||
@ -164,7 +164,7 @@ PQresultSetInstanceData(PGresult *result, PGEventProc proc, void *data)
|
||||
void *
|
||||
PQresultInstanceData(const PGresult *result, PGEventProc proc)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!result || !proc)
|
||||
return NULL;
|
||||
@ -184,7 +184,7 @@ PQresultInstanceData(const PGresult *result, PGEventProc proc)
|
||||
int
|
||||
PQfireResultCreateEvents(PGconn *conn, PGresult *res)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!res)
|
||||
return FALSE;
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.h,v 1.3 2009/01/01 17:24:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.h,v 1.4 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,7 +24,7 @@ extern "C"
|
||||
#endif
|
||||
|
||||
/* Callback Event Ids */
|
||||
typedef enum
|
||||
typedef enum
|
||||
{
|
||||
PGEVT_REGISTER,
|
||||
PGEVT_CONNRESET,
|
||||
@ -36,41 +36,41 @@ typedef enum
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PGconn *conn;
|
||||
PGconn *conn;
|
||||
} PGEventRegister;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PGconn *conn;
|
||||
PGconn *conn;
|
||||
} PGEventConnReset;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PGconn *conn;
|
||||
PGconn *conn;
|
||||
} PGEventConnDestroy;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PGconn *conn;
|
||||
PGresult *result;
|
||||
PGconn *conn;
|
||||
PGresult *result;
|
||||
} PGEventResultCreate;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const PGresult *src;
|
||||
PGresult *dest;
|
||||
PGresult *dest;
|
||||
} PGEventResultCopy;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PGresult *result;
|
||||
PGresult *result;
|
||||
} PGEventResultDestroy;
|
||||
|
||||
typedef int (*PGEventProc) (PGEventId evtId, void *evtInfo, void *passThrough);
|
||||
|
||||
/* Registers an event proc with the given PGconn. */
|
||||
extern int PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
const char *name, void *passThrough);
|
||||
extern int PQregisterEventProc(PGconn *conn, PGEventProc proc,
|
||||
const char *name, void *passThrough);
|
||||
|
||||
/* Sets the PGconn instance data for the provided proc to data. */
|
||||
extern int PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data);
|
||||
@ -91,4 +91,4 @@ extern int PQfireResultCreateEvents(PGconn *conn, PGresult *res);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBPQ_EVENTS_H */
|
||||
#endif /* LIBPQ_EVENTS_H */
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.146 2009/03/31 01:41:27 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.147 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -31,10 +31,10 @@ extern "C"
|
||||
/*
|
||||
* Option flags for PQcopyResult
|
||||
*/
|
||||
#define PG_COPYRES_ATTRS 0x01
|
||||
#define PG_COPYRES_TUPLES 0x02 /* Implies PG_COPYRES_ATTRS */
|
||||
#define PG_COPYRES_EVENTS 0x04
|
||||
#define PG_COPYRES_NOTICEHOOKS 0x08
|
||||
#define PG_COPYRES_ATTRS 0x01
|
||||
#define PG_COPYRES_TUPLES 0x02 /* Implies PG_COPYRES_ATTRS */
|
||||
#define PG_COPYRES_EVENTS 0x04
|
||||
#define PG_COPYRES_NOTICEHOOKS 0x08
|
||||
|
||||
/* Application-visible enum types */
|
||||
|
||||
@ -463,9 +463,9 @@ extern void PQfreemem(void *ptr);
|
||||
/* Create and manipulate PGresults */
|
||||
extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
|
||||
extern PGresult *PQcopyResult(const PGresult *src, int flags);
|
||||
extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
|
||||
extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
|
||||
extern void *PQresultAlloc(PGresult *res, size_t nBytes);
|
||||
extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
|
||||
extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
|
||||
|
||||
/* Quoting strings before inclusion in queries. */
|
||||
extern size_t PQescapeStringConn(PGconn *conn,
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.141 2009/04/24 09:43:10 mha Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.142 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -69,7 +69,7 @@ typedef struct
|
||||
{
|
||||
void *value;
|
||||
int length;
|
||||
} gss_buffer_desc;
|
||||
} gss_buffer_desc;
|
||||
#endif
|
||||
#endif /* ENABLE_SSPI */
|
||||
|
||||
@ -155,11 +155,11 @@ typedef struct
|
||||
|
||||
typedef struct PGEvent
|
||||
{
|
||||
PGEventProc proc; /* the function to call on events */
|
||||
PGEventProc proc; /* the function to call on events */
|
||||
char *name; /* used only for error messages */
|
||||
void *passThrough; /* pointer supplied at registration time */
|
||||
void *data; /* optional state (instance) data */
|
||||
bool resultInitialized; /* T if RESULTCREATE/COPY succeeded */
|
||||
bool resultInitialized; /* T if RESULTCREATE/COPY succeeded */
|
||||
} PGEvent;
|
||||
|
||||
struct pg_result
|
||||
@ -182,7 +182,7 @@ struct pg_result
|
||||
* on the PGresult don't have to reference the PGconn.
|
||||
*/
|
||||
PGNoticeHooks noticeHooks;
|
||||
PGEvent *events;
|
||||
PGEvent *events;
|
||||
int nEvents;
|
||||
int client_encoding; /* encoding id */
|
||||
|
||||
@ -310,9 +310,9 @@ struct pg_conn
|
||||
PGNoticeHooks noticeHooks;
|
||||
|
||||
/* Event procs registered via PQregisterEventProc */
|
||||
PGEvent *events; /* expandable array of event data */
|
||||
PGEvent *events; /* expandable array of event data */
|
||||
int nEvents; /* number of active events */
|
||||
int eventArraySize; /* allocated array size */
|
||||
int eventArraySize; /* allocated array size */
|
||||
|
||||
/* Status indicators */
|
||||
ConnStatusType status;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.26 2009/01/01 17:24:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.27 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -47,11 +47,12 @@ markPQExpBufferBroken(PQExpBuffer str)
|
||||
{
|
||||
if (str->data != oom_buffer)
|
||||
free(str->data);
|
||||
|
||||
/*
|
||||
* Casting away const here is a bit ugly, but it seems preferable to
|
||||
* not marking oom_buffer const. We want to do that to encourage the
|
||||
* compiler to put oom_buffer in read-only storage, so that anyone who
|
||||
* tries to scribble on a broken PQExpBuffer will get a failure.
|
||||
* Casting away const here is a bit ugly, but it seems preferable to not
|
||||
* marking oom_buffer const. We want to do that to encourage the compiler
|
||||
* to put oom_buffer in read-only storage, so that anyone who tries to
|
||||
* scribble on a broken PQExpBuffer will get a failure.
|
||||
*/
|
||||
str->data = (char *) oom_buffer;
|
||||
str->len = 0;
|
||||
@ -126,7 +127,7 @@ termPQExpBuffer(PQExpBuffer str)
|
||||
if (str->data != oom_buffer)
|
||||
free(str->data);
|
||||
/* just for luck, make the buffer validly empty. */
|
||||
str->data = (char *) oom_buffer; /* see comment above */
|
||||
str->data = (char *) oom_buffer; /* see comment above */
|
||||
str->maxlen = 0;
|
||||
str->len = 0;
|
||||
}
|
||||
@ -160,7 +161,7 @@ resetPQExpBuffer(PQExpBuffer str)
|
||||
* Make sure there is enough space for 'needed' more bytes in the buffer
|
||||
* ('needed' does not include the terminating null).
|
||||
*
|
||||
* Returns 1 if OK, 0 if failed to enlarge buffer. (In the latter case
|
||||
* Returns 1 if OK, 0 if failed to enlarge buffer. (In the latter case
|
||||
* the buffer is left in "broken" state.)
|
||||
*/
|
||||
int
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.h,v 1.22 2009/01/01 17:24:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.h,v 1.23 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -37,7 +37,7 @@
|
||||
* more space. We must always have maxlen > len.
|
||||
*
|
||||
* An exception occurs if we failed to allocate enough memory for the string
|
||||
* buffer. In that case data points to a statically allocated empty string,
|
||||
* buffer. In that case data points to a statically allocated empty string,
|
||||
* and len = maxlen = 0.
|
||||
*-------------------------
|
||||
*/
|
||||
@ -56,7 +56,7 @@ typedef PQExpBufferData *PQExpBuffer;
|
||||
* are no-ops.
|
||||
*------------------------
|
||||
*/
|
||||
#define PQExpBufferBroken(str) \
|
||||
#define PQExpBufferBroken(str) \
|
||||
((str) == NULL || (str)->maxlen == 0)
|
||||
|
||||
/*------------------------
|
||||
@ -126,7 +126,7 @@ extern void resetPQExpBuffer(PQExpBuffer str);
|
||||
* Make sure there is enough space for 'needed' more bytes in the buffer
|
||||
* ('needed' does not include the terminating null).
|
||||
*
|
||||
* Returns 1 if OK, 0 if failed to enlarge buffer. (In the latter case
|
||||
* Returns 1 if OK, 0 if failed to enlarge buffer. (In the latter case
|
||||
* the buffer is left in "broken" state.)
|
||||
*/
|
||||
extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed);
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Copyright (c) 2004-2009, PostgreSQL Global Development Group
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.18 2009/01/01 17:24:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/pthread-win32.c,v 1.19 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -35,7 +35,7 @@ pthread_getspecific(pthread_key_t key)
|
||||
int
|
||||
pthread_mutex_init(pthread_mutex_t *mp, void *attr)
|
||||
{
|
||||
*mp = (CRITICAL_SECTION *)malloc(sizeof(CRITICAL_SECTION));
|
||||
*mp = (CRITICAL_SECTION *) malloc(sizeof(CRITICAL_SECTION));
|
||||
if (!*mp)
|
||||
return 1;
|
||||
InitializeCriticalSection(*mp);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/win32.c,v 1.25 2009/01/01 17:24:03 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/win32.c,v 1.26 2009/06/11 14:49:14 momjian Exp $
|
||||
*
|
||||
*
|
||||
* FILE
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/win32.h,v 1.29 2008/05/17 01:28:25 adunstan Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/win32.h,v 1.30 2009/06/11 14:49:14 momjian Exp $
|
||||
*/
|
||||
#ifndef __win32_h_included
|
||||
#define __win32_h_included
|
||||
|
Reference in New Issue
Block a user