Commit 089003fb authored by Bruce Momjian's avatar Bruce Momjian

pgindent run.

parent 63354a02
...@@ -23,4 +23,3 @@ typedef struct rix ...@@ -23,4 +23,3 @@ typedef struct rix
extern GIST_SPLITVEC *btree_picksplit(bytea *entryvec, GIST_SPLITVEC *v, extern GIST_SPLITVEC *btree_picksplit(bytea *entryvec, GIST_SPLITVEC *v,
BINARY_UNION bu, CMPFUNC cmp); BINARY_UNION bu, CMPFUNC cmp);
...@@ -131,7 +131,8 @@ cube_out(NDBOX * cube) ...@@ -131,7 +131,8 @@ cube_out(NDBOX * cube)
* Get the number of digits to display. * Get the number of digits to display.
*/ */
ndig = DBL_DIG + extra_float_digits; ndig = DBL_DIG + extra_float_digits;
if (ndig < 1) ndig = 1; if (ndig < 1)
ndig = 1;
/* /*
* while printing the first (LL) corner, check if it is equal to the * while printing the first (LL) corner, check if it is equal to the
...@@ -1192,7 +1193,8 @@ cube_enlarge(NDBOX * a, double *r, int4 n) ...@@ -1192,7 +1193,8 @@ cube_enlarge(NDBOX * a, double *r, int4 n)
j, j,
k; k;
if (n > CUBE_MAX_DIM) n = CUBE_MAX_DIM; if (n > CUBE_MAX_DIM)
n = CUBE_MAX_DIM;
if (*r > 0 && n > 0) if (*r > 0 && n > 0)
dim = n; dim = n;
if (a->dim > dim) if (a->dim > dim)
...@@ -1235,6 +1237,7 @@ cube_f8(double *x1) ...@@ -1235,6 +1237,7 @@ cube_f8(double *x1)
{ {
NDBOX *result; NDBOX *result;
int size; int size;
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2; size = offsetof(NDBOX, x[0]) + sizeof(double) * 2;
result = (NDBOX *) palloc(size); result = (NDBOX *) palloc(size);
memset(result, 0, size); memset(result, 0, size);
...@@ -1251,6 +1254,7 @@ cube_f8_f8(double *x1, double *x2) ...@@ -1251,6 +1254,7 @@ cube_f8_f8(double *x1, double *x2)
{ {
NDBOX *result; NDBOX *result;
int size; int size;
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2; size = offsetof(NDBOX, x[0]) + sizeof(double) * 2;
result = (NDBOX *) palloc(size); result = (NDBOX *) palloc(size);
memset(result, 0, size); memset(result, 0, size);
...@@ -1264,17 +1268,19 @@ cube_f8_f8(double *x1, double *x2) ...@@ -1264,17 +1268,19 @@ cube_f8_f8(double *x1, double *x2)
/* Add a dimension to an existing cube with the same values for the new /* Add a dimension to an existing cube with the same values for the new
coordinate */ coordinate */
NDBOX * NDBOX *
cube_c_f8(NDBOX *c, double *x1) cube_c_f8(NDBOX * c, double *x1)
{ {
NDBOX *result; NDBOX *result;
int size; int size;
int i; int i;
size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) * 2;
size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2;
result = (NDBOX *) palloc(size); result = (NDBOX *) palloc(size);
memset(result, 0, size); memset(result, 0, size);
result->size = size; result->size = size;
result->dim = c->dim + 1; result->dim = c->dim + 1;
for (i = 0; i < c->dim; i++) { for (i = 0; i < c->dim; i++)
{
result->x[i] = c->x[i]; result->x[i] = c->x[i];
result->x[result->dim + i] = c->x[c->dim + i]; result->x[result->dim + i] = c->x[c->dim + i];
} }
...@@ -1285,17 +1291,19 @@ cube_c_f8(NDBOX *c, double *x1) ...@@ -1285,17 +1291,19 @@ cube_c_f8(NDBOX *c, double *x1)
/* Add a dimension to an existing cube */ /* Add a dimension to an existing cube */
NDBOX * NDBOX *
cube_c_f8_f8(NDBOX *c, double *x1, double *x2) cube_c_f8_f8(NDBOX * c, double *x1, double *x2)
{ {
NDBOX *result; NDBOX *result;
int size; int size;
int i; int i;
size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) * 2;
size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2;
result = (NDBOX *) palloc(size); result = (NDBOX *) palloc(size);
memset(result, 0, size); memset(result, 0, size);
result->size = size; result->size = size;
result->dim = c->dim + 1; result->dim = c->dim + 1;
for (i = 0; i < c->dim; i++) { for (i = 0; i < c->dim; i++)
{
result->x[i] = c->x[i]; result->x[i] = c->x[i];
result->x[result->dim + i] = c->x[c->dim + i]; result->x[result->dim + i] = c->x[c->dim + i];
} }
......
...@@ -446,14 +446,12 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh) ...@@ -446,14 +446,12 @@ do_inserts(PGconn *conn, char *table, dbhead * dbh)
j = 0; /* counter for fields in the output */ j = 0; /* counter for fields in the output */
for (h = 0; h < dbh->db_nfields; h++) for (h = 0; h < dbh->db_nfields; h++)
{ {
if (!strlen(fields[h].db_name)) /* When the new fieldname is empty, the field is skipped */ if (!strlen(fields[h].db_name)) /* When the new fieldname
{ * is empty, the field is
* skipped */
continue; continue;
}
else else
{
j++; j++;
}
if (j > 1) /* not for the first field! */ if (j > 1) /* not for the first field! */
strcat(query, "\t"); /* COPY statement field strcat(query, "\t"); /* COPY statement field
......
...@@ -63,7 +63,7 @@ typedef struct remoteConn ...@@ -63,7 +63,7 @@ typedef struct remoteConn
{ {
PGconn *con; /* Hold the remote connection */ PGconn *con; /* Hold the remote connection */
bool remoteTrFlag; /* Indicates whether or not a transaction bool remoteTrFlag; /* Indicates whether or not a transaction
* on remote database is in progress*/ * on remote database is in progress */
} remoteConn; } remoteConn;
/* /*
...@@ -71,7 +71,7 @@ typedef struct remoteConn ...@@ -71,7 +71,7 @@ typedef struct remoteConn
*/ */
static remoteConn *getConnectionByName(const char *name); static remoteConn *getConnectionByName(const char *name);
static HTAB *createConnHash(void); static HTAB *createConnHash(void);
static void createNewConnection(const char *name,remoteConn *con); static void createNewConnection(const char *name, remoteConn * con);
static void deleteConnection(const char *name); static void deleteConnection(const char *name);
static char **get_pkey_attnames(Oid relid, int16 *numatts); static char **get_pkey_attnames(Oid relid, int16 *numatts);
static char *get_sql_insert(Oid relid, int16 *pkattnums, int16 pknumatts, char **src_pkattvals, char **tgt_pkattvals); static char *get_sql_insert(Oid relid, int16 *pkattnums, int16 pknumatts, char **src_pkattvals, char **tgt_pkattvals);
...@@ -89,7 +89,7 @@ static char *generate_relation_name(Oid relid); ...@@ -89,7 +89,7 @@ static char *generate_relation_name(Oid relid);
List *res_id = NIL; List *res_id = NIL;
int res_id_index = 0; int res_id_index = 0;
PGconn *persistent_conn = NULL; PGconn *persistent_conn = NULL;
static HTAB *remoteConnHash=NULL; static HTAB *remoteConnHash = NULL;
/* /*
Following is list that holds multiple remote connections. Following is list that holds multiple remote connections.
...@@ -186,18 +186,18 @@ dblink_connect(PG_FUNCTION_ARGS) ...@@ -186,18 +186,18 @@ dblink_connect(PG_FUNCTION_ARGS)
PGconn *conn = NULL; PGconn *conn = NULL;
remoteConn *rcon = NULL; remoteConn *rcon = NULL;
if(PG_NARGS()==2) if (PG_NARGS() == 2)
{ {
connstr = GET_STR(PG_GETARG_TEXT_P(1)); connstr = GET_STR(PG_GETARG_TEXT_P(1));
connname = GET_STR(PG_GETARG_TEXT_P(0)); connname = GET_STR(PG_GETARG_TEXT_P(0));
} }
else if(PG_NARGS()==1) else if (PG_NARGS() == 1)
connstr = GET_STR(PG_GETARG_TEXT_P(0)); connstr = GET_STR(PG_GETARG_TEXT_P(0));
oldcontext = MemoryContextSwitchTo(TopMemoryContext); oldcontext = MemoryContextSwitchTo(TopMemoryContext);
if(connname) if (connname)
rcon=(remoteConn *) palloc(sizeof(remoteConn)); rcon = (remoteConn *) palloc(sizeof(remoteConn));
conn = PQconnectdb(connstr); conn = PQconnectdb(connstr);
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
...@@ -206,7 +206,7 @@ dblink_connect(PG_FUNCTION_ARGS) ...@@ -206,7 +206,7 @@ dblink_connect(PG_FUNCTION_ARGS)
{ {
msg = pstrdup(PQerrorMessage(conn)); msg = pstrdup(PQerrorMessage(conn));
PQfinish(conn); PQfinish(conn);
if(rcon) if (rcon)
pfree(rcon); pfree(rcon);
ereport(ERROR, ereport(ERROR,
...@@ -215,7 +215,7 @@ dblink_connect(PG_FUNCTION_ARGS) ...@@ -215,7 +215,7 @@ dblink_connect(PG_FUNCTION_ARGS)
errdetail("%s", msg))); errdetail("%s", msg)));
} }
if(connname) if (connname)
{ {
rcon->con = conn; rcon->con = conn;
createNewConnection(connname, rcon); createNewConnection(connname, rcon);
...@@ -237,7 +237,7 @@ dblink_disconnect(PG_FUNCTION_ARGS) ...@@ -237,7 +237,7 @@ dblink_disconnect(PG_FUNCTION_ARGS)
remoteConn *rcon = NULL; remoteConn *rcon = NULL;
PGconn *conn = NULL; PGconn *conn = NULL;
if (PG_NARGS() ==1 ) if (PG_NARGS() == 1)
{ {
conname = GET_STR(PG_GETARG_TEXT_P(0)); conname = GET_STR(PG_GETARG_TEXT_P(0));
rcon = getConnectionByName(conname); rcon = getConnectionByName(conname);
...@@ -276,13 +276,13 @@ dblink_open(PG_FUNCTION_ARGS) ...@@ -276,13 +276,13 @@ dblink_open(PG_FUNCTION_ARGS)
StringInfo str = makeStringInfo(); StringInfo str = makeStringInfo();
remoteConn *rcon = NULL; remoteConn *rcon = NULL;
if(PG_NARGS() == 2) if (PG_NARGS() == 2)
{ {
curname = GET_STR(PG_GETARG_TEXT_P(0)); curname = GET_STR(PG_GETARG_TEXT_P(0));
sql = GET_STR(PG_GETARG_TEXT_P(1)); sql = GET_STR(PG_GETARG_TEXT_P(1));
conn = persistent_conn; conn = persistent_conn;
} }
else if(PG_NARGS() == 3) else if (PG_NARGS() == 3)
{ {
conname = GET_STR(PG_GETARG_TEXT_P(0)); conname = GET_STR(PG_GETARG_TEXT_P(0));
curname = GET_STR(PG_GETARG_TEXT_P(1)); curname = GET_STR(PG_GETARG_TEXT_P(1));
...@@ -333,12 +333,12 @@ dblink_close(PG_FUNCTION_ARGS) ...@@ -333,12 +333,12 @@ dblink_close(PG_FUNCTION_ARGS)
curname = GET_STR(PG_GETARG_TEXT_P(0)); curname = GET_STR(PG_GETARG_TEXT_P(0));
conn = persistent_conn; conn = persistent_conn;
} }
else if (PG_NARGS()==2) else if (PG_NARGS() == 2)
{ {
conname = GET_STR(PG_GETARG_TEXT_P(0)); conname = GET_STR(PG_GETARG_TEXT_P(0));
curname = GET_STR(PG_GETARG_TEXT_P(1)); curname = GET_STR(PG_GETARG_TEXT_P(1));
rcon = getConnectionByName(conname); rcon = getConnectionByName(conname);
if(rcon) if (rcon)
conn = rcon->con; conn = rcon->con;
} }
...@@ -381,7 +381,7 @@ dblink_fetch(PG_FUNCTION_ARGS) ...@@ -381,7 +381,7 @@ dblink_fetch(PG_FUNCTION_ARGS)
PGresult *res = NULL; PGresult *res = NULL;
MemoryContext oldcontext; MemoryContext oldcontext;
char *conname = NULL; char *conname = NULL;
remoteConn *rcon=NULL; remoteConn *rcon = NULL;
/* stuff done only on the first call of the function */ /* stuff done only on the first call of the function */
if (SRF_IS_FIRSTCALL()) if (SRF_IS_FIRSTCALL())
...@@ -401,7 +401,7 @@ dblink_fetch(PG_FUNCTION_ARGS) ...@@ -401,7 +401,7 @@ dblink_fetch(PG_FUNCTION_ARGS)
howmany = PG_GETARG_INT32(2); howmany = PG_GETARG_INT32(2);
rcon = getConnectionByName(conname); rcon = getConnectionByName(conname);
if(rcon) if (rcon)
conn = rcon->con; conn = rcon->con;
} }
else if (PG_NARGS() == 2) else if (PG_NARGS() == 2)
...@@ -411,7 +411,7 @@ dblink_fetch(PG_FUNCTION_ARGS) ...@@ -411,7 +411,7 @@ dblink_fetch(PG_FUNCTION_ARGS)
conn = persistent_conn; conn = persistent_conn;
} }
if(!conn) if (!conn)
DBLINK_CONN_NOT_AVAIL; DBLINK_CONN_NOT_AVAIL;
/* create a function context for cross-call persistence */ /* create a function context for cross-call persistence */
...@@ -429,9 +429,7 @@ dblink_fetch(PG_FUNCTION_ARGS) ...@@ -429,9 +429,7 @@ dblink_fetch(PG_FUNCTION_ARGS)
if (!res || if (!res ||
(PQresultStatus(res) != PGRES_COMMAND_OK && (PQresultStatus(res) != PGRES_COMMAND_OK &&
PQresultStatus(res) != PGRES_TUPLES_OK)) PQresultStatus(res) != PGRES_TUPLES_OK))
{
DBLINK_RES_ERROR("sql error"); DBLINK_RES_ERROR("sql error");
}
else if (PQresultStatus(res) == PGRES_COMMAND_OK) else if (PQresultStatus(res) == PGRES_COMMAND_OK)
{ {
/* cursor does not exist - closed already or bad name */ /* cursor does not exist - closed already or bad name */
...@@ -549,7 +547,7 @@ dblink_record(PG_FUNCTION_ARGS) ...@@ -549,7 +547,7 @@ dblink_record(PG_FUNCTION_ARGS)
char *connstr = NULL; char *connstr = NULL;
char *sql = NULL; char *sql = NULL;
char *conname = NULL; char *conname = NULL;
remoteConn *rcon=NULL; remoteConn *rcon = NULL;
/* create a function context for cross-call persistence */ /* create a function context for cross-call persistence */
funcctx = SRF_FIRSTCALL_INIT(); funcctx = SRF_FIRSTCALL_INIT();
...@@ -574,7 +572,7 @@ dblink_record(PG_FUNCTION_ARGS) ...@@ -574,7 +572,7 @@ dblink_record(PG_FUNCTION_ARGS)
/* shouldn't happen */ /* shouldn't happen */
elog(ERROR, "wrong number of arguments"); elog(ERROR, "wrong number of arguments");
if(!conn) if (!conn)
DBLINK_CONN_NOT_AVAIL; DBLINK_CONN_NOT_AVAIL;
res = PQexec(conn, sql); res = PQexec(conn, sql);
...@@ -591,8 +589,8 @@ dblink_record(PG_FUNCTION_ARGS) ...@@ -591,8 +589,8 @@ dblink_record(PG_FUNCTION_ARGS)
TEXTOID, -1, 0, false); TEXTOID, -1, 0, false);
/* /*
* and save a copy of the command status string to return * and save a copy of the command status string to return as
* as our result tuple * our result tuple
*/ */
sql_cmd_status = PQcmdStatus(res); sql_cmd_status = PQcmdStatus(res);
funcctx->max_calls = 1; funcctx->max_calls = 1;
...@@ -707,7 +705,7 @@ dblink_exec(PG_FUNCTION_ARGS) ...@@ -707,7 +705,7 @@ dblink_exec(PG_FUNCTION_ARGS)
char *connstr = NULL; char *connstr = NULL;
char *sql = NULL; char *sql = NULL;
char *conname = NULL; char *conname = NULL;
remoteConn *rcon=NULL; remoteConn *rcon = NULL;
bool freeconn = true; bool freeconn = true;
if (PG_NARGS() == 2) if (PG_NARGS() == 2)
...@@ -724,7 +722,7 @@ dblink_exec(PG_FUNCTION_ARGS) ...@@ -724,7 +722,7 @@ dblink_exec(PG_FUNCTION_ARGS)
/* shouldn't happen */ /* shouldn't happen */
elog(ERROR, "wrong number of arguments"); elog(ERROR, "wrong number of arguments");
if(!conn) if (!conn)
DBLINK_CONN_NOT_AVAIL; DBLINK_CONN_NOT_AVAIL;
res = PQexec(conn, sql); res = PQexec(conn, sql);
...@@ -741,8 +739,8 @@ dblink_exec(PG_FUNCTION_ARGS) ...@@ -741,8 +739,8 @@ dblink_exec(PG_FUNCTION_ARGS)
TEXTOID, -1, 0, false); TEXTOID, -1, 0, false);
/* /*
* and save a copy of the command status string to return as * and save a copy of the command status string to return as our
* our result tuple * result tuple
*/ */
sql_cmd_status = GET_TEXT(PQcmdStatus(res)); sql_cmd_status = GET_TEXT(PQcmdStatus(res));
} }
...@@ -802,6 +800,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS) ...@@ -802,6 +800,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_TABLE), (errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation \"%s\" does not exist", errmsg("relation \"%s\" does not exist",
GET_STR(PG_GETARG_TEXT_P(0))))); GET_STR(PG_GETARG_TEXT_P(0)))));
/* /*
* need a tuple descriptor representing one INT and one TEXT * need a tuple descriptor representing one INT and one TEXT
* column * column
...@@ -1896,18 +1895,18 @@ getConnectionByName(const char *name) ...@@ -1896,18 +1895,18 @@ getConnectionByName(const char *name)
remoteConnHashEnt *hentry; remoteConnHashEnt *hentry;
char key[NAMEDATALEN]; char key[NAMEDATALEN];
if(!remoteConnHash) if (!remoteConnHash)
remoteConnHash=createConnHash(); remoteConnHash = createConnHash();
MemSet(key, 0, NAMEDATALEN); MemSet(key, 0, NAMEDATALEN);
snprintf(key, NAMEDATALEN - 1, "%s", name); snprintf(key, NAMEDATALEN - 1, "%s", name);
hentry = (remoteConnHashEnt*) hash_search(remoteConnHash, hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
key, HASH_FIND, NULL); key, HASH_FIND, NULL);
if(hentry) if (hentry)
return(hentry->rcon); return (hentry->rcon);
return(NULL); return (NULL);
} }
static HTAB * static HTAB *
...@@ -1919,24 +1918,24 @@ createConnHash(void) ...@@ -1919,24 +1918,24 @@ createConnHash(void)
ctl.keysize = NAMEDATALEN; ctl.keysize = NAMEDATALEN;
ctl.entrysize = sizeof(remoteConnHashEnt); ctl.entrysize = sizeof(remoteConnHashEnt);
ptr=hash_create("Remote Con hash", NUMCONN, &ctl, HASH_ELEM); ptr = hash_create("Remote Con hash", NUMCONN, &ctl, HASH_ELEM);
if(!ptr) if (!ptr)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
return(ptr); return (ptr);
} }
static void static void
createNewConnection(const char *name, remoteConn *con) createNewConnection(const char *name, remoteConn * con)
{ {
remoteConnHashEnt *hentry; remoteConnHashEnt *hentry;
bool found; bool found;
char key[NAMEDATALEN]; char key[NAMEDATALEN];
if(!remoteConnHash) if (!remoteConnHash)
remoteConnHash = createConnHash(); remoteConnHash = createConnHash();
MemSet(key, 0, NAMEDATALEN); MemSet(key, 0, NAMEDATALEN);
...@@ -1944,12 +1943,12 @@ createNewConnection(const char *name, remoteConn *con) ...@@ -1944,12 +1943,12 @@ createNewConnection(const char *name, remoteConn *con)
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key, hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, key,
HASH_ENTER, &found); HASH_ENTER, &found);
if(!hentry) if (!hentry)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
if(found) if (found)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT), (errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("duplicate connection name"))); errmsg("duplicate connection name")));
...@@ -1965,8 +1964,8 @@ deleteConnection(const char *name) ...@@ -1965,8 +1964,8 @@ deleteConnection(const char *name)
bool found; bool found;
char key[NAMEDATALEN]; char key[NAMEDATALEN];
if(!remoteConnHash) if (!remoteConnHash)
remoteConnHash=createConnHash(); remoteConnHash = createConnHash();
MemSet(key, 0, NAMEDATALEN); MemSet(key, 0, NAMEDATALEN);
snprintf(key, NAMEDATALEN - 1, "%s", name); snprintf(key, NAMEDATALEN - 1, "%s", name);
...@@ -1974,7 +1973,7 @@ deleteConnection(const char *name) ...@@ -1974,7 +1973,7 @@ deleteConnection(const char *name)
hentry = (remoteConnHashEnt *) hash_search(remoteConnHash, hentry = (remoteConnHashEnt *) hash_search(remoteConnHash,
key, HASH_REMOVE, &found); key, HASH_REMOVE, &found);
if(!hentry) if (!hentry)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT), (errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("undefined connection name"))); errmsg("undefined connection name")));
......
/**************************************************************************** /****************************************************************************
* pending.c * pending.c
* $Id: pending.c,v 1.12 2003/07/24 17:52:20 tgl Exp $ * $Id: pending.c,v 1.13 2003/08/04 00:43:10 momjian Exp $
* *
* This file contains a trigger for Postgresql-7.x to record changes to tables * This file contains a trigger for Postgresql-7.x to record changes to tables
* to a pending table for mirroring. * to a pending table for mirroring.
...@@ -81,6 +81,7 @@ recordchange(PG_FUNCTION_ARGS) ...@@ -81,6 +81,7 @@ recordchange(PG_FUNCTION_ARGS)
char op = 0; char op = 0;
char *schemaname; char *schemaname;
char *fullyqualtblname; char *fullyqualtblname;
if (fcinfo->context != NULL) if (fcinfo->context != NULL)
{ {
...@@ -96,11 +97,11 @@ recordchange(PG_FUNCTION_ARGS) ...@@ -96,11 +97,11 @@ recordchange(PG_FUNCTION_ARGS)
schemaname = get_namespace_name(RelationGetNamespace(trigdata->tg_relation)); schemaname = get_namespace_name(RelationGetNamespace(trigdata->tg_relation));
fullyqualtblname = SPI_palloc(strlen(tblname) + fullyqualtblname = SPI_palloc(strlen(tblname) +
strlen(schemaname) + 6); strlen(schemaname) + 6);
sprintf(fullyqualtblname,"\"%s\".\"%s\"", sprintf(fullyqualtblname, "\"%s\".\"%s\"",
schemaname,tblname); schemaname, tblname);
#else #else
fullyqualtblname = SPI_palloc(strlen(tblname) + 3); fullyqualtblname = SPI_palloc(strlen(tblname) + 3);
sprintf(fullyqualtblname,"\"%s\"",tblname); sprintf(fullyqualtblname, "\"%s\"", tblname);
#endif #endif
tupdesc = trigdata->tg_relation->rd_att; tupdesc = trigdata->tg_relation->rd_att;
if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
...@@ -166,7 +167,7 @@ storePending(char *cpTableName, HeapTuple tBeforeTuple, ...@@ -166,7 +167,7 @@ storePending(char *cpTableName, HeapTuple tBeforeTuple,
int iResult = 0; int iResult = 0;
HeapTuple tCurTuple; HeapTuple tCurTuple;
//Points the current tuple(before or after) /* Points the current tuple(before or after) */
Datum saPlanData[4]; Datum saPlanData[4];
Oid taPlanArgTypes[3] = {NAMEOID, CHAROID, INT4OID}; Oid taPlanArgTypes[3] = {NAMEOID, CHAROID, INT4OID};
void *vpPlan; void *vpPlan;
...@@ -460,7 +461,7 @@ packageData(HeapTuple tTupleData, TupleDesc tTupleDesc, ...@@ -460,7 +461,7 @@ packageData(HeapTuple tTupleData, TupleDesc tTupleDesc,
} }
else else
{ {
sprintf(cpFormatedPtr," "); sprintf(cpFormatedPtr, " ");
iUsedDataBlock++; iUsedDataBlock++;
cpFormatedPtr++; cpFormatedPtr++;
continue; continue;
...@@ -508,7 +509,7 @@ packageData(HeapTuple tTupleData, TupleDesc tTupleDesc, ...@@ -508,7 +509,7 @@ packageData(HeapTuple tTupleData, TupleDesc tTupleDesc,
if (tpPKeys != NULL) if (tpPKeys != NULL)
SPI_pfree(tpPKeys); SPI_pfree(tpPKeys);
#if defined DEBUG_OUTPUT #if defined DEBUG_OUTPUT
elog(NOTICE, "returning DataBlockSize:%d iUsedDataBlock:%d",iDataBlockSize, elog(NOTICE, "returning DataBlockSize:%d iUsedDataBlock:%d", iDataBlockSize,
iUsedDataBlock); iUsedDataBlock);
#endif #endif
memset(cpDataBlock + iUsedDataBlock, 0, iDataBlockSize - iUsedDataBlock); memset(cpDataBlock + iUsedDataBlock, 0, iDataBlockSize - iUsedDataBlock);
......
...@@ -66,9 +66,10 @@ geo_distance(Point *pt1, Point *pt2) ...@@ -66,9 +66,10 @@ geo_distance(Point *pt1, Point *pt2)
if (longdiff > M_PI) if (longdiff > M_PI)
longdiff = TWO_PI - longdiff; longdiff = TWO_PI - longdiff;
sino = sqrt(sin(fabs(lat1-lat2)/2.)*sin(fabs(lat1-lat2)/2.) + sino = sqrt(sin(fabs(lat1 - lat2) / 2.) * sin(fabs(lat1 - lat2) / 2.) +
cos(lat1) * cos(lat2) * sin(longdiff/2.)*sin(longdiff/2.)); cos(lat1) * cos(lat2) * sin(longdiff / 2.) * sin(longdiff / 2.));
if (sino > 1.) sino = 1.; if (sino > 1.)
sino = 1.;
*resultp = 2. * EARTH_RADIUS * asin(sino); *resultp = 2. * EARTH_RADIUS * asin(sino);
return resultp; return resultp;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2002 by PostgreSQL Global Development Group * Copyright 2002 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/contrib/findoidjoins/Attic/findoidjoins.c,v 1.20 2003/05/14 03:25:56 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/findoidjoins/Attic/findoidjoins.c,v 1.21 2003/08/04 00:43:10 momjian Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -24,7 +24,8 @@ main(int argc, char **argv) ...@@ -24,7 +24,8 @@ main(int argc, char **argv)
char *fk_attname; char *fk_attname;
char *pk_relname; char *pk_relname;
char *pk_nspname; char *pk_nspname;
int fk, pk; /* loop counters */ int fk,
pk; /* loop counters */
if (argc != 2) if (argc != 2)
{ {
...@@ -95,8 +96,8 @@ main(int argc, char **argv) ...@@ -95,8 +96,8 @@ main(int argc, char **argv)
fkrel_res = res; fkrel_res = res;
/* /*
* For each column and each relation-having-OIDs, look to see if * For each column and each relation-having-OIDs, look to see if the
* the column contains any values matching entries in the relation. * column contains any values matching entries in the relation.
*/ */
for (fk = 0; fk < PQntuples(fkrel_res); fk++) for (fk = 0; fk < PQntuples(fkrel_res); fk++)
......
...@@ -132,9 +132,9 @@ ShrinkPGArray(PGARRAY * p) ...@@ -132,9 +132,9 @@ ShrinkPGArray(PGARRAY * p)
/* use current transaction context */ /* use current transaction context */
pnew = palloc(cb); pnew = palloc(cb);
/* /*
* Fix up the fields in the new structure, so Postgres * Fix up the fields in the new structure, so Postgres understands
* understands
*/ */
memcpy(pnew, p, cb); memcpy(pnew, p, cb);
pnew->a.size = cb; pnew->a.size = cb;
......
...@@ -126,8 +126,8 @@ ArrayType *intarray_concat_arrays(ArrayType *a, ArrayType *b); ...@@ -126,8 +126,8 @@ ArrayType *intarray_concat_arrays(ArrayType *a, ArrayType *b);
ArrayType *int_to_intset(int32 elem); ArrayType *int_to_intset(int32 elem);
bool inner_int_overlap(ArrayType *a, ArrayType *b); bool inner_int_overlap(ArrayType *a, ArrayType *b);
bool inner_int_contains(ArrayType *a, ArrayType *b); bool inner_int_contains(ArrayType *a, ArrayType *b);
ArrayType * inner_int_union(ArrayType *a, ArrayType *b); ArrayType *inner_int_union(ArrayType *a, ArrayType *b);
ArrayType * inner_int_inter(ArrayType *a, ArrayType *b); ArrayType *inner_int_inter(ArrayType *a, ArrayType *b);
void rt__int_size(ArrayType *a, float *size); void rt__int_size(ArrayType *a, float *size);
void gensign(BITVEC sign, int *a, int len); void gensign(BITVEC sign, int *a, int len);
...@@ -173,5 +173,3 @@ int compDESC(const void *a, const void *b); ...@@ -173,5 +173,3 @@ int compDESC(const void *a, const void *b);
if (ARRNELEMS(a) > 1) \ if (ARRNELEMS(a) > 1) \
qsort((void*)ARRPTR(a), ARRNELEMS(a),sizeof(int4), \ qsort((void*)ARRPTR(a), ARRNELEMS(a),sizeof(int4), \
(direction) ? compASC : compDESC ) (direction) ? compASC : compDESC )
...@@ -743,4 +743,3 @@ querytree(PG_FUNCTION_ARGS) ...@@ -743,4 +743,3 @@ querytree(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(res); PG_RETURN_POINTER(res);
} }
...@@ -85,26 +85,30 @@ g_int_consistent(PG_FUNCTION_ARGS) ...@@ -85,26 +85,30 @@ g_int_consistent(PG_FUNCTION_ARGS)
} }
Datum Datum
g_int_union(PG_FUNCTION_ARGS) { g_int_union(PG_FUNCTION_ARGS)
{
bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); bytea *entryvec = (bytea *) PG_GETARG_POINTER(0);
int *size = (int *) PG_GETARG_POINTER(1); int *size = (int *) PG_GETARG_POINTER(1);
int4 i,len = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY); int4 i,
len = (VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY);
ArrayType *res; ArrayType *res;
int totlen=0,*ptr; int totlen = 0,
*ptr;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
totlen+=ARRNELEMS( GETENTRY(entryvec,i) ); totlen += ARRNELEMS(GETENTRY(entryvec, i));
res=new_intArrayType(totlen); res = new_intArrayType(totlen);
ptr=ARRPTR(res); ptr = ARRPTR(res);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++)
memcpy(ptr, ARRPTR( GETENTRY(entryvec,i) ), ARRNELEMS( GETENTRY(entryvec,i) )*sizeof(int4) ); {
ptr+=ARRNELEMS( GETENTRY(entryvec,i) ); memcpy(ptr, ARRPTR(GETENTRY(entryvec, i)), ARRNELEMS(GETENTRY(entryvec, i)) * sizeof(int4));
ptr += ARRNELEMS(GETENTRY(entryvec, i));
} }
QSORT(res,1); QSORT(res, 1);
res=_int_unique(res); res = _int_unique(res);
*size = VARSIZE(res); *size = VARSIZE(res);
PG_RETURN_POINTER(res); PG_RETURN_POINTER(res);
} }
...@@ -239,7 +243,8 @@ g_int_decompress(PG_FUNCTION_ARGS) ...@@ -239,7 +243,8 @@ g_int_decompress(PG_FUNCTION_ARGS)
** The GiST Penalty method for _intments ** The GiST Penalty method for _intments
*/ */
Datum Datum
g_int_penalty(PG_FUNCTION_ARGS) { g_int_penalty(PG_FUNCTION_ARGS)
{
GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0); GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1); GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
float *result = (float *) PG_GETARG_POINTER(2); float *result = (float *) PG_GETARG_POINTER(2);
...@@ -254,7 +259,7 @@ g_int_penalty(PG_FUNCTION_ARGS) { ...@@ -254,7 +259,7 @@ g_int_penalty(PG_FUNCTION_ARGS) {
*result = tmp1 - tmp2; *result = tmp1 - tmp2;
pfree(ud); pfree(ud);
PG_RETURN_POINTER (result); PG_RETURN_POINTER(result);
} }
...@@ -311,7 +316,8 @@ comparecost(const void *a, const void *b) ...@@ -311,7 +316,8 @@ comparecost(const void *a, const void *b)
** We use Guttman's poly time split algorithm ** We use Guttman's poly time split algorithm
*/ */
Datum Datum
g_int_picksplit(PG_FUNCTION_ARGS) { g_int_picksplit(PG_FUNCTION_ARGS)
{
bytea *entryvec = (bytea *) PG_GETARG_POINTER(0); bytea *entryvec = (bytea *) PG_GETARG_POINTER(0);
GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1); GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
OffsetNumber i, OffsetNumber i,
...@@ -501,4 +507,3 @@ g_int_picksplit(PG_FUNCTION_ARGS) { ...@@ -501,4 +507,3 @@ g_int_picksplit(PG_FUNCTION_ARGS) {
PG_RETURN_POINTER(v); PG_RETURN_POINTER(v);
} }
...@@ -270,7 +270,7 @@ _int_unique(ArrayType *r) ...@@ -270,7 +270,7 @@ _int_unique(ArrayType *r)
*data; *data;
int num = ARRNELEMS(r); int num = ARRNELEMS(r);
if ( num<2 ) if (num < 2)
return r; return r;
data = tmp = dr = ARRPTR(r); data = tmp = dr = ARRPTR(r);
...@@ -367,4 +367,3 @@ compDESC(const void *a, const void *b) ...@@ -367,4 +367,3 @@ compDESC(const void *a, const void *b)
return 0; return 0;
return (*(int4 *) a < *(int4 *) b) ? 1 : -1; return (*(int4 *) a < *(int4 *) b) ? 1 : -1;
} }
...@@ -144,13 +144,15 @@ _lt_q_regex(PG_FUNCTION_ARGS) ...@@ -144,13 +144,15 @@ _lt_q_regex(PG_FUNCTION_ARGS)
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("array must be one-dimensional"))); errmsg("array must be one-dimensional")));
while (num > 0) { while (num > 0)
if ( array_iterator(_tree, ltq_regex, (void*)query, NULL) ) { {
if (array_iterator(_tree, ltq_regex, (void *) query, NULL))
{
res = true; res = true;
break; break;
} }
num--; num--;
query = (lquery*)NEXTVAL(query); query = (lquery *) NEXTVAL(query);
} }
PG_FREE_IF_COPY(_tree, 0); PG_FREE_IF_COPY(_tree, 0);
......
...@@ -45,7 +45,7 @@ getlexem(char *start, char *end, int *len) ...@@ -45,7 +45,7 @@ getlexem(char *start, char *end, int *len)
} }
bool bool
compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend) compare_subnode(ltree_level * t, char *qn, int len, int (*cmpptr) (const char *, const char *, size_t), bool anyend)
{ {
char *endt = t->name + t->len; char *endt = t->name + t->len;
char *endq = qn + len; char *endq = qn + len;
...@@ -123,10 +123,15 @@ printFieldNot(FieldNot *fn ) { ...@@ -123,10 +123,15 @@ printFieldNot(FieldNot *fn ) {
} }
*/ */
static struct { static struct
{
bool muse; bool muse;
uint32 high_pos; uint32 high_pos;
} SomeStack = {false,0,}; } SomeStack =
{
false, 0,
};
static bool static bool
checkCond(lquery_level * curq, int query_numlevel, ltree_level * curt, int tree_numlevel, FieldNot * ptr) checkCond(lquery_level * curq, int query_numlevel, ltree_level * curt, int tree_numlevel, FieldNot * ptr)
...@@ -140,7 +145,8 @@ checkCond(lquery_level * curq, int query_numlevel, ltree_level * curt, int tree_ ...@@ -140,7 +145,8 @@ checkCond(lquery_level * curq, int query_numlevel, ltree_level * curt, int tree_
lquery_level *prevq = NULL; lquery_level *prevq = NULL;
ltree_level *prevt = NULL; ltree_level *prevt = NULL;
if ( SomeStack.muse ) { if (SomeStack.muse)
{
high_pos = SomeStack.high_pos; high_pos = SomeStack.high_pos;
qlen--; qlen--;
prevq = curq; prevq = curq;
...@@ -200,13 +206,15 @@ checkCond(lquery_level * curq, int query_numlevel, ltree_level * curt, int tree_ ...@@ -200,13 +206,15 @@ checkCond(lquery_level * curq, int query_numlevel, ltree_level * curt, int tree_
curt = LEVEL_NEXT(curt); curt = LEVEL_NEXT(curt);
tlen--; tlen--;
cur_tpos++; cur_tpos++;
if ( isok && prevq && prevq->numvar==0 && tlen>0 && cur_tpos <= high_pos ) { if (isok && prevq && prevq->numvar == 0 && tlen > 0 && cur_tpos <= high_pos)
{
FieldNot tmpptr; FieldNot tmpptr;
if ( ptr )
memcpy(&tmpptr,ptr,sizeof(FieldNot)); if (ptr)
SomeStack.high_pos = high_pos-cur_tpos; memcpy(&tmpptr, ptr, sizeof(FieldNot));
SomeStack.high_pos = high_pos - cur_tpos;
SomeStack.muse = true; SomeStack.muse = true;
if ( checkCond(prevq, qlen+1, curt, tlen, (ptr) ? &tmpptr : NULL) ) if (checkCond(prevq, qlen + 1, curt, tlen, (ptr) ? &tmpptr : NULL))
return true; return true;
} }
if (!isok && ptr) if (!isok && ptr)
...@@ -321,9 +329,11 @@ lt_q_regex(PG_FUNCTION_ARGS) ...@@ -321,9 +329,11 @@ lt_q_regex(PG_FUNCTION_ARGS)
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR), (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("array must be one-dimensional"))); errmsg("array must be one-dimensional")));
while (num > 0) { while (num > 0)
{
if (DatumGetBool(DirectFunctionCall2(ltq_regex, if (DatumGetBool(DirectFunctionCall2(ltq_regex,
PointerGetDatum(tree), PointerGetDatum(query)))) { PointerGetDatum(tree), PointerGetDatum(query))))
{
res = true; res = true;
break; break;
...@@ -345,5 +355,3 @@ lt_q_rregex(PG_FUNCTION_ARGS) ...@@ -345,5 +355,3 @@ lt_q_rregex(PG_FUNCTION_ARGS)
PG_GETARG_DATUM(0) PG_GETARG_DATUM(0)
)); ));
} }
...@@ -331,46 +331,55 @@ ltree_index(PG_FUNCTION_ARGS) ...@@ -331,46 +331,55 @@ ltree_index(PG_FUNCTION_ARGS)
{ {
ltree *a = PG_GETARG_LTREE(0); ltree *a = PG_GETARG_LTREE(0);
ltree *b = PG_GETARG_LTREE(1); ltree *b = PG_GETARG_LTREE(1);
int start=(fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0; int start = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int i,j; int i,
ltree_level *startptr, *aptr, *bptr; j;
bool found=false; ltree_level *startptr,
*aptr,
if ( start < 0 ) { *bptr;
if ( -start >= a->numlevel ) bool found = false;
start=0;
if (start < 0)
{
if (-start >= a->numlevel)
start = 0;
else else
start = (int)(a->numlevel)+start; start = (int) (a->numlevel) + start;
} }
if ( a->numlevel - start < b->numlevel || a->numlevel==0 || b->numlevel==0 ) { if (a->numlevel - start < b->numlevel || a->numlevel == 0 || b->numlevel == 0)
{
PG_FREE_IF_COPY(a, 0); PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1); PG_FREE_IF_COPY(b, 1);
PG_RETURN_INT32(-1); PG_RETURN_INT32(-1);
} }
startptr=LTREE_FIRST(a); startptr = LTREE_FIRST(a);
for(i=0; i<=a->numlevel-b->numlevel; i++) { for (i = 0; i <= a->numlevel - b->numlevel; i++)
if ( i>=start ) { {
aptr=startptr; if (i >= start)
bptr=LTREE_FIRST(b); {
for(j=0;j<b->numlevel;j++) { aptr = startptr;
if ( !(aptr->len==bptr->len && strncmp(aptr->name,bptr->name, aptr->len)==0) ) bptr = LTREE_FIRST(b);
for (j = 0; j < b->numlevel; j++)
{
if (!(aptr->len == bptr->len && strncmp(aptr->name, bptr->name, aptr->len) == 0))
break; break;
aptr=LEVEL_NEXT(aptr); aptr = LEVEL_NEXT(aptr);
bptr=LEVEL_NEXT(bptr); bptr = LEVEL_NEXT(bptr);
} }
if ( j==b->numlevel ) { if (j == b->numlevel)
found=true; {
found = true;
break; break;
} }
} }
startptr=LEVEL_NEXT(startptr); startptr = LEVEL_NEXT(startptr);
} }
if ( !found ) if (!found)
i=-1; i = -1;
PG_FREE_IF_COPY(a, 0); PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1); PG_FREE_IF_COPY(b, 1);
...@@ -507,7 +516,7 @@ text2ltree(PG_FUNCTION_ARGS) ...@@ -507,7 +516,7 @@ text2ltree(PG_FUNCTION_ARGS)
PointerGetDatum(s) PointerGetDatum(s)
)); ));
pfree(s); pfree(s);
PG_FREE_IF_COPY(in,0); PG_FREE_IF_COPY(in, 0);
PG_RETURN_POINTER(out); PG_RETURN_POINTER(out);
} }
...@@ -521,11 +530,13 @@ ltree2text(PG_FUNCTION_ARGS) ...@@ -521,11 +530,13 @@ ltree2text(PG_FUNCTION_ARGS)
ltree_level *curlevel; ltree_level *curlevel;
text *out; text *out;
out=(text*)palloc(in->len+VARHDRSZ); out = (text *) palloc(in->len + VARHDRSZ);
ptr = VARDATA(out); ptr = VARDATA(out);
curlevel = LTREE_FIRST(in); curlevel = LTREE_FIRST(in);
for (i = 0; i < in->numlevel; i++) { for (i = 0; i < in->numlevel; i++)
if (i != 0) { {
if (i != 0)
{
*ptr = '.'; *ptr = '.';
ptr++; ptr++;
} }
...@@ -534,12 +545,8 @@ ltree2text(PG_FUNCTION_ARGS) ...@@ -534,12 +545,8 @@ ltree2text(PG_FUNCTION_ARGS)
curlevel = LEVEL_NEXT(curlevel); curlevel = LEVEL_NEXT(curlevel);
} }
VARATT_SIZEP(out) = VARHDRSZ + (ptr-VARDATA(out)); VARATT_SIZEP(out) = VARHDRSZ + (ptr - VARDATA(out));
PG_FREE_IF_COPY(in, 0); PG_FREE_IF_COPY(in, 0);
PG_RETURN_POINTER(out); PG_RETURN_POINTER(out);
} }
This diff is collapsed.
...@@ -44,9 +44,19 @@ ...@@ -44,9 +44,19 @@
/* define cmd_args stucture */ /* define cmd_args stucture */
struct cmdargs struct cmdargs
{ {
int vacuum_base_threshold, analyze_base_threshold, sleep_base_value, debug, daemonize; int vacuum_base_threshold,
float vacuum_scaling_factor, analyze_scaling_factor, sleep_scaling_factor; analyze_base_threshold,
char *user, *password, *host, *logfile, *port; sleep_base_value,
debug,
daemonize;
float vacuum_scaling_factor,
analyze_scaling_factor,
sleep_scaling_factor;
char *user,
*password,
*host,
*logfile,
*port;
}; };
typedef struct cmdargs cmd_args; typedef struct cmdargs cmd_args;
...@@ -57,58 +67,73 @@ cmd_args *args; ...@@ -57,58 +67,73 @@ cmd_args *args;
I think we need to guarantee this happens approx every 1Million TX's */ I think we need to guarantee this happens approx every 1Million TX's */
struct dbinfo struct dbinfo
{ {
int oid, age; int oid,
int analyze_threshold, vacuum_threshold; /* Use these as defaults for table thresholds */ age;
int analyze_threshold,
vacuum_threshold; /* Use these as defaults for table
* thresholds */
PGconn *conn; PGconn *conn;
char *dbname, *username, *password; char *dbname,
*username,
*password;
Dllist *table_list; Dllist *table_list;
}; };
typedef struct dbinfo db_info; typedef struct dbinfo db_info;
struct tableinfo struct tableinfo
{ {
char *schema_name, *table_name; char *schema_name,
int relfilenode, reltuples, relpages; *table_name;
long analyze_threshold, vacuum_threshold; int relfilenode,
long CountAtLastAnalyze; /* equal to: inserts + updates as of the last analyze or initial values at startup */ reltuples,
long CountAtLastVacuum; /* equal to: deletes + updates as of the last vacuum or initial values at startup */ relpages;
long curr_analyze_count, curr_vacuum_count; /* Latest values from stats system */ long analyze_threshold,
db_info *dbi; /* pointer to the database that this table belongs to */ vacuum_threshold;
long CountAtLastAnalyze; /* equal to: inserts + updates as
* of the last analyze or initial
* values at startup */
long CountAtLastVacuum; /* equal to: deletes + updates as
* of the last vacuum or initial
* values at startup */
long curr_analyze_count,
curr_vacuum_count; /* Latest values from stats system */
db_info *dbi; /* pointer to the database that this table
* belongs to */
}; };
typedef struct tableinfo tbl_info; typedef struct tableinfo tbl_info;
/* Functions for dealing with command line arguements */ /* Functions for dealing with command line arguements */
static cmd_args *get_cmd_args (int argc, char *argv[]); static cmd_args *get_cmd_args(int argc, char *argv[]);
static void print_cmd_args (void); static void print_cmd_args(void);
static void free_cmd_args (void); static void free_cmd_args(void);
static void usage (void); static void usage(void);
/* Functions for managing database lists */ /* Functions for managing database lists */
static Dllist *init_db_list (void); static Dllist *init_db_list(void);
static db_info *init_dbinfo (char *dbname, int oid, int age); static db_info *init_dbinfo(char *dbname, int oid, int age);
static void update_db_list (Dllist * db_list); static void update_db_list(Dllist *db_list);
static void remove_db_from_list (Dlelem * db_to_remove); static void remove_db_from_list(Dlelem *db_to_remove);
static void print_db_info (db_info * dbi, int print_table_list); static void print_db_info(db_info * dbi, int print_table_list);
static void print_db_list (Dllist * db_list, int print_table_lists); static void print_db_list(Dllist *db_list, int print_table_lists);
static int xid_wraparound_check (db_info * dbi); static int xid_wraparound_check(db_info * dbi);
static void free_db_list (Dllist * db_list); static void free_db_list(Dllist *db_list);
/* Functions for managing table lists */ /* Functions for managing table lists */
static tbl_info *init_table_info (PGresult * conn, int row, db_info *dbi); static tbl_info *init_table_info(PGresult *conn, int row, db_info * dbi);
static void update_table_list (db_info * dbi); static void update_table_list(db_info * dbi);
static void remove_table_from_list (Dlelem * tbl_to_remove); static void remove_table_from_list(Dlelem *tbl_to_remove);
static void print_table_list (Dllist * tbl_node); static void print_table_list(Dllist *tbl_node);
static void print_table_info (tbl_info * tbl); static void print_table_info(tbl_info * tbl);
static void update_table_thresholds (db_info * dbi, tbl_info * tbl, int vacuum_type); static void update_table_thresholds(db_info * dbi, tbl_info * tbl, int vacuum_type);
static void free_tbl_list (Dllist * tbl_list); static void free_tbl_list(Dllist *tbl_list);
/* A few database helper functions */ /* A few database helper functions */
static int check_stats_enabled (db_info * dbi); static int check_stats_enabled(db_info * dbi);
static PGconn *db_connect (db_info * dbi); static PGconn *db_connect(db_info * dbi);
static void db_disconnect (db_info * dbi); static void db_disconnect(db_info * dbi);
static PGresult *send_query (const char *query, db_info * dbi); static PGresult *send_query(const char *query, db_info * dbi);
static char *query_table_stats (db_info * dbi); static char *query_table_stats(db_info * dbi);
/* Other Generally needed Functions */ /* Other Generally needed Functions */
static void daemonize(void); static void daemonize(void);
static void log_entry (const char *logentry); static void log_entry(const char *logentry);
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* pg_dumplo * pg_dumplo
* *
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.16 2003/05/14 03:25:56 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.17 2003/08/04 00:43:11 momjian Exp $
* *
* Karel Zak 1999-2000 * Karel Zak 1999-2000
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
......
/* /*
* $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.25 2003/08/01 02:21:17 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.26 2003/08/04 00:43:11 momjian Exp $
* *
* pgbench: a simple TPC-B like benchmark program for PostgreSQL * pgbench: a simple TPC-B like benchmark program for PostgreSQL
* written by Tatsuo Ishii * written by Tatsuo Ishii
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: openssl.c,v 1.11 2002/11/15 02:54:44 momjian Exp $ * $Id: openssl.c,v 1.12 2003/08/04 00:43:11 momjian Exp $
*/ */
#include <postgres.h> #include <postgres.h>
...@@ -134,7 +134,8 @@ px_find_digest(const char *name, PX_MD ** res) ...@@ -134,7 +134,8 @@ px_find_digest(const char *name, PX_MD ** res)
* So need to manage ciphers ourselves. * So need to manage ciphers ourselves.
*/ */
struct ossl_cipher { struct ossl_cipher
{
int (*init) (PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv); int (*init) (PX_Cipher * c, const uint8 *key, unsigned klen, const uint8 *iv);
int (*encrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res); int (*encrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res);
int (*decrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res); int (*decrypt) (PX_Cipher * c, const uint8 *data, unsigned dlen, uint8 *res);
...@@ -311,8 +312,8 @@ ossl_des_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, ...@@ -311,8 +312,8 @@ ossl_des_ecb_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen,
ossldata *od = c->ptr; ossldata *od = c->ptr;
for (i = 0; i < dlen / bs; i++) for (i = 0; i < dlen / bs; i++)
des_ecb_encrypt((des_cblock*)(data + i * bs), des_ecb_encrypt((des_cblock *) (data + i * bs),
(des_cblock*)(res + i * bs), (des_cblock *) (res + i * bs),
od->u.des.key_schedule, 1); od->u.des.key_schedule, 1);
return 0; return 0;
} }
...@@ -326,8 +327,8 @@ ossl_des_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, ...@@ -326,8 +327,8 @@ ossl_des_ecb_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen,
ossldata *od = c->ptr; ossldata *od = c->ptr;
for (i = 0; i < dlen / bs; i++) for (i = 0; i < dlen / bs; i++)
des_ecb_encrypt((des_cblock*)(data + i * bs), des_ecb_encrypt((des_cblock *) (data + i * bs),
(des_cblock*)(res + i * bs), (des_cblock *) (res + i * bs),
od->u.des.key_schedule, 0); od->u.des.key_schedule, 0);
return 0; return 0;
} }
...@@ -339,7 +340,7 @@ ossl_des_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, ...@@ -339,7 +340,7 @@ ossl_des_cbc_encrypt(PX_Cipher * c, const uint8 *data, unsigned dlen,
ossldata *od = c->ptr; ossldata *od = c->ptr;
des_ncbc_encrypt(data, res, dlen, od->u.des.key_schedule, des_ncbc_encrypt(data, res, dlen, od->u.des.key_schedule,
(des_cblock*)od->iv, 1); (des_cblock *) od->iv, 1);
return 0; return 0;
} }
...@@ -350,7 +351,7 @@ ossl_des_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen, ...@@ -350,7 +351,7 @@ ossl_des_cbc_decrypt(PX_Cipher * c, const uint8 *data, unsigned dlen,
ossldata *od = c->ptr; ossldata *od = c->ptr;
des_ncbc_encrypt(data, res, dlen, od->u.des.key_schedule, des_ncbc_encrypt(data, res, dlen, od->u.des.key_schedule,
(des_cblock*)od->iv, 0); (des_cblock *) od->iv, 0);
return 0; return 0;
} }
...@@ -429,37 +430,37 @@ static PX_Alias ossl_aliases[] = { ...@@ -429,37 +430,37 @@ static PX_Alias ossl_aliases[] = {
static const struct ossl_cipher ossl_bf_cbc = { static const struct ossl_cipher ossl_bf_cbc = {
bf_init, bf_cbc_encrypt, bf_cbc_decrypt, bf_init, bf_cbc_encrypt, bf_cbc_decrypt,
64/8, 448/8, 0 64 / 8, 448 / 8, 0
}; };
static const struct ossl_cipher ossl_bf_ecb = { static const struct ossl_cipher ossl_bf_ecb = {
bf_init, bf_ecb_encrypt, bf_ecb_decrypt, bf_init, bf_ecb_encrypt, bf_ecb_decrypt,
64/8, 448/8, 0 64 / 8, 448 / 8, 0
}; };
static const struct ossl_cipher ossl_bf_cfb = { static const struct ossl_cipher ossl_bf_cfb = {
bf_init, bf_cfb64_encrypt, bf_cfb64_decrypt, bf_init, bf_cfb64_encrypt, bf_cfb64_decrypt,
64/8, 448/8, 1 64 / 8, 448 / 8, 1
}; };
static const struct ossl_cipher ossl_des_ecb = { static const struct ossl_cipher ossl_des_ecb = {
ossl_des_init, ossl_des_ecb_encrypt, ossl_des_ecb_decrypt, ossl_des_init, ossl_des_ecb_encrypt, ossl_des_ecb_decrypt,
64/8, 64/8, 0 64 / 8, 64 / 8, 0
}; };
static const struct ossl_cipher ossl_des_cbc = { static const struct ossl_cipher ossl_des_cbc = {
ossl_des_init, ossl_des_cbc_encrypt, ossl_des_cbc_decrypt, ossl_des_init, ossl_des_cbc_encrypt, ossl_des_cbc_decrypt,
64/8, 64/8, 0 64 / 8, 64 / 8, 0
}; };
static const struct ossl_cipher ossl_cast_ecb = { static const struct ossl_cipher ossl_cast_ecb = {
ossl_cast_init, ossl_cast_ecb_encrypt, ossl_cast_ecb_decrypt, ossl_cast_init, ossl_cast_ecb_encrypt, ossl_cast_ecb_decrypt,
64/8, 128/8, 0 64 / 8, 128 / 8, 0
}; };
static const struct ossl_cipher ossl_cast_cbc = { static const struct ossl_cipher ossl_cast_cbc = {
ossl_cast_init, ossl_cast_cbc_encrypt, ossl_cast_cbc_decrypt, ossl_cast_init, ossl_cast_cbc_encrypt, ossl_cast_cbc_decrypt,
64/8, 128/8, 0 64 / 8, 128 / 8, 0
}; };
/* /*
...@@ -510,8 +511,10 @@ px_find_cipher(const char *name, PX_Cipher ** res) ...@@ -510,8 +511,10 @@ px_find_cipher(const char *name, PX_Cipher ** res)
const struct ossl_cipher *ossl_ciph = NULL; const struct ossl_cipher *ossl_ciph = NULL;
name = px_resolve_alias(ossl_aliases, name); name = px_resolve_alias(ossl_aliases, name);
for (i = 0; ossl_cipher_types[i].name; i++) { for (i = 0; ossl_cipher_types[i].name; i++)
if (!strcmp(ossl_cipher_types[i].name, name)) { {
if (!strcmp(ossl_cipher_types[i].name, name))
{
ossl_ciph = ossl_cipher_types[i].ciph; ossl_ciph = ossl_cipher_types[i].ciph;
break; break;
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: pgcrypto.c,v 1.13 2003/07/24 17:52:33 tgl Exp $ * $Id: pgcrypto.c,v 1.14 2003/08/04 00:43:11 momjian Exp $
*/ */
#include <postgres.h> #include <postgres.h>
......
/* /*
* $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.11 2003/08/01 02:21:17 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.12 2003/08/04 00:43:11 momjian Exp $
* *
* Copyright (c) 2001,2002 Tatsuo Ishii * Copyright (c) 2001,2002 Tatsuo Ishii
* *
...@@ -221,5 +221,5 @@ pgstattuple_real(Relation rel) ...@@ -221,5 +221,5 @@ pgstattuple_real(Relation rel)
pfree(values[i]); pfree(values[i]);
pfree(values); pfree(values);
return(result); return (result);
} }
This diff is collapsed.
...@@ -729,9 +729,9 @@ crosstab_hash(PG_FUNCTION_ARGS) ...@@ -729,9 +729,9 @@ crosstab_hash(PG_FUNCTION_ARGS)
/* /*
* Check to make sure we have a reasonable tuple descriptor * Check to make sure we have a reasonable tuple descriptor
* *
* Note we will attempt to coerce the values into whatever * Note we will attempt to coerce the values into whatever the return
* the return attribute type is and depend on the "in" * attribute type is and depend on the "in" function to complain if
* function to complain if needed. * needed.
*/ */
if (tupdesc->natts < 2) if (tupdesc->natts < 2)
ereport(ERROR, ereport(ERROR,
...@@ -781,8 +781,8 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx) ...@@ -781,8 +781,8 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx)
ctl.entrysize = sizeof(crosstab_HashEnt); ctl.entrysize = sizeof(crosstab_HashEnt);
/* /*
* use INIT_CATS, defined above as a guess of how * use INIT_CATS, defined above as a guess of how many hash table
* many hash table entries to create, initially * entries to create, initially
*/ */
crosstab_HashTable = hash_create("crosstab hash", INIT_CATS, &ctl, HASH_ELEM); crosstab_HashTable = hash_create("crosstab hash", INIT_CATS, &ctl, HASH_ELEM);
...@@ -803,8 +803,8 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx) ...@@ -803,8 +803,8 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx)
int i; int i;
/* /*
* The provided categories SQL query must always return one column: * The provided categories SQL query must always return one
* category - the label or identifier for each column * column: category - the label or identifier for each column
*/ */
if (spi_tupdesc->natts != 1) if (spi_tupdesc->natts != 1)
ereport(ERROR, ereport(ERROR,
...@@ -890,21 +890,24 @@ get_crosstab_tuplestore(char *sql, ...@@ -890,21 +890,24 @@ get_crosstab_tuplestore(char *sql,
int ncols = spi_tupdesc->natts; int ncols = spi_tupdesc->natts;
char *rowid; char *rowid;
char *lastrowid = NULL; char *lastrowid = NULL;
int i, j; int i,
j;
int result_ncols; int result_ncols;
/* /*
* The provided SQL query must always return at least three columns: * The provided SQL query must always return at least three
* columns:
* *
* 1. rowname the label for each row - column 1 in the final result * 1. rowname the label for each row - column 1 in the final result
* 2. category the label for each value-column in the final result * 2. category the label for each value-column in the final
* 3. value the values used to populate the value-columns * result 3. value the values used to populate the
* value-columns
* *
* If there are more than three columns, the last two are taken as * If there are more than three columns, the last two are taken as
* "category" and "values". The first column is taken as "rowname". * "category" and "values". The first column is taken as
* Additional columns (2 thru N-2) are assumed the same for the same * "rowname". Additional columns (2 thru N-2) are assumed the same
* "rowname", and are copied into the result tuple from the first * for the same "rowname", and are copied into the result tuple
* time we encounter a particular rowname. * from the first time we encounter a particular rowname.
*/ */
if (ncols < 3) if (ncols < 3)
ereport(ERROR, ereport(ERROR,
...@@ -958,7 +961,10 @@ get_crosstab_tuplestore(char *sql, ...@@ -958,7 +961,10 @@ get_crosstab_tuplestore(char *sql,
*/ */
if (lastrowid != NULL) if (lastrowid != NULL)
{ {
/* switch to appropriate context while storing the tuple */ /*
* switch to appropriate context while storing the
* tuple
*/
SPIcontext = MemoryContextSwitchTo(per_query_ctx); SPIcontext = MemoryContextSwitchTo(per_query_ctx);
/* rowid changed, flush the previous output row */ /* rowid changed, flush the previous output row */
...@@ -1309,7 +1315,7 @@ build_tuplestore_recursively(char *key_fld, ...@@ -1309,7 +1315,7 @@ build_tuplestore_recursively(char *key_fld,
parent_key_fld, parent_key_fld,
start_with, start_with,
key_fld); key_fld);
serial_column=0; serial_column = 0;
} }
else else
{ {
...@@ -1321,7 +1327,7 @@ build_tuplestore_recursively(char *key_fld, ...@@ -1321,7 +1327,7 @@ build_tuplestore_recursively(char *key_fld,
start_with, start_with,
key_fld, key_fld,
orderby_fld); orderby_fld);
serial_column=1; serial_column = 1;
} }
/* Retrieve the desired rows */ /* Retrieve the desired rows */
...@@ -1508,10 +1514,10 @@ build_tuplestore_recursively(char *key_fld, ...@@ -1508,10 +1514,10 @@ build_tuplestore_recursively(char *key_fld,
static void static void
validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool show_serial) validateConnectbyTupleDesc(TupleDesc tupdesc, bool show_branch, bool show_serial)
{ {
int serial_column=0; int serial_column = 0;
if (show_serial) if (show_serial)
serial_column=1; serial_column = 1;
/* are there the correct number of columns */ /* are there the correct number of columns */
if (show_branch) if (show_branch)
......
...@@ -51,7 +51,8 @@ DICT dicts[] = { ...@@ -51,7 +51,8 @@ DICT dicts[] = {
#undef DICT_TABLE #undef DICT_TABLE
/* array for storing dictionary's objects (if needed) */ /* array for storing dictionary's objects (if needed) */
void *dictobjs[lengthof(dicts)]; void *dictobjs[
lengthof(dicts)];
#define STOPLEXEM -2 #define STOPLEXEM -2
#define BYLOCALE -1 #define BYLOCALE -1
......
...@@ -4,54 +4,72 @@ ...@@ -4,54 +4,72 @@
#include "ts_cfg.h" #include "ts_cfg.h"
#include "dict.h" #include "dict.h"
text* text *
char2text(char* in) { char2text(char *in)
{
return charl2text(in, strlen(in)); return charl2text(in, strlen(in));
} }
text* charl2text(char* in, int len) { text *
text *out=(text*)palloc(len+VARHDRSZ); charl2text(char *in, int len)
{
text *out = (text *) palloc(len + VARHDRSZ);
memcpy(VARDATA(out), in, len); memcpy(VARDATA(out), in, len);
VARATT_SIZEP(out) = len+VARHDRSZ; VARATT_SIZEP(out) = len + VARHDRSZ;
return out; return out;
} }
char char
*text2char(text* in) { *
char *out=palloc( VARSIZE(in) ); text2char(text *in)
memcpy(out, VARDATA(in), VARSIZE(in)-VARHDRSZ); {
out[ VARSIZE(in)-VARHDRSZ ] ='\0'; char *out = palloc(VARSIZE(in));
memcpy(out, VARDATA(in), VARSIZE(in) - VARHDRSZ);
out[VARSIZE(in) - VARHDRSZ] = '\0';
return out; return out;
} }
char char
*pnstrdup(char* in, int len) { *
char *out=palloc( len+1 ); pnstrdup(char *in, int len)
{
char *out = palloc(len + 1);
memcpy(out, in, len); memcpy(out, in, len);
out[len]='\0'; out[len] = '\0';
return out; return out;
} }
text text
*ptextdup(text* in) { *
text *out=(text*)palloc( VARSIZE(in) ); ptextdup(text *in)
memcpy(out,in,VARSIZE(in)); {
text *out = (text *) palloc(VARSIZE(in));
memcpy(out, in, VARSIZE(in));
return out; return out;
} }
text text
*mtextdup(text* in) { *
text *out=(text*)malloc( VARSIZE(in) ); mtextdup(text *in)
if ( !out ) {
text *out = (text *) malloc(VARSIZE(in));
if (!out)
ts_error(ERROR, "No memory"); ts_error(ERROR, "No memory");
memcpy(out,in,VARSIZE(in)); memcpy(out, in, VARSIZE(in));
return out; return out;
} }
void void
ts_error(int state, const char *format, ...) { ts_error(int state, const char *format,...)
{
va_list args; va_list args;
int tlen = 128, len=0; int tlen = 128,
len = 0;
char *buf; char *buf;
reset_cfg(); reset_cfg();
...@@ -60,11 +78,12 @@ ts_error(int state, const char *format, ...) { ...@@ -60,11 +78,12 @@ ts_error(int state, const char *format, ...) {
va_start(args, format); va_start(args, format);
buf = palloc(tlen); buf = palloc(tlen);
len = vsnprintf(buf, tlen-1, format, args); len = vsnprintf(buf, tlen - 1, format, args);
if ( len >= tlen ) { if (len >= tlen)
tlen=len+1; {
buf = repalloc( buf, tlen ); tlen = len + 1;
vsnprintf(buf, tlen-1, format, args); buf = repalloc(buf, tlen);
vsnprintf(buf, tlen - 1, format, args);
} }
va_end(args); va_end(args);
...@@ -74,10 +93,10 @@ ts_error(int state, const char *format, ...) { ...@@ -74,10 +93,10 @@ ts_error(int state, const char *format, ...) {
} }
int int
text_cmp(text *a, text *b) { text_cmp(text *a, text *b)
if ( VARSIZE(a) == VARSIZE(b) ) {
return strncmp( VARDATA(a), VARDATA(b), VARSIZE(a)-VARHDRSZ ); if (VARSIZE(a) == VARSIZE(b))
return (int)VARSIZE(a) - (int)VARSIZE(b); return strncmp(VARDATA(a), VARDATA(b), VARSIZE(a) - VARHDRSZ);
return (int) VARSIZE(a) - (int) VARSIZE(b);
} }
...@@ -7,18 +7,18 @@ ...@@ -7,18 +7,18 @@
#define PG_NARGS() (fcinfo->nargs) #define PG_NARGS() (fcinfo->nargs)
#endif #endif
text* char2text(char* in); text *char2text(char *in);
text* charl2text(char* in, int len); text *charl2text(char *in, int len);
char *text2char(text* in); char *text2char(text *in);
char *pnstrdup(char* in, int len); char *pnstrdup(char *in, int len);
text *ptextdup(text* in); text *ptextdup(text *in);
text *mtextdup(text* in); text *mtextdup(text *in);
int text_cmp(text *a, text *b); int text_cmp(text *a, text *b);
#define NEXTVAL(x) ( (text*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) ) #define NEXTVAL(x) ( (text*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x)) #define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
void ts_error(int state, const char *format, ...); void ts_error(int state, const char *format,...);
#endif #endif
...@@ -19,45 +19,52 @@ ...@@ -19,45 +19,52 @@
/*********top interface**********/ /*********top interface**********/
static void *plan_getdict=NULL; static void *plan_getdict = NULL;
void void
init_dict(Oid id, DictInfo *dict) { init_dict(Oid id, DictInfo * dict)
Oid arg[1]={ OIDOID }; {
Oid arg[1] = {OIDOID};
bool isnull; bool isnull;
Datum pars[1]={ ObjectIdGetDatum(id) }; Datum pars[1] = {ObjectIdGetDatum(id)};
int stat; int stat;
memset(dict,0,sizeof(DictInfo)); memset(dict, 0, sizeof(DictInfo));
SPI_connect(); SPI_connect();
if ( !plan_getdict ) { if (!plan_getdict)
plan_getdict = SPI_saveplan( SPI_prepare( "select dict_init, dict_initoption, dict_lexize from pg_ts_dict where oid = $1" , 1, arg ) ); {
if ( !plan_getdict ) plan_getdict = SPI_saveplan(SPI_prepare("select dict_init, dict_initoption, dict_lexize from pg_ts_dict where oid = $1", 1, arg));
if (!plan_getdict)
ts_error(ERROR, "SPI_prepare() failed"); ts_error(ERROR, "SPI_prepare() failed");
} }
stat = SPI_execp(plan_getdict, pars, " ", 1); stat = SPI_execp(plan_getdict, pars, " ", 1);
if ( stat < 0 ) if (stat < 0)
ts_error (ERROR, "SPI_execp return %d", stat); ts_error(ERROR, "SPI_execp return %d", stat);
if ( SPI_processed > 0 ) { if (SPI_processed > 0)
{
Datum opt; Datum opt;
Oid oid=InvalidOid; Oid oid = InvalidOid;
oid=DatumGetObjectId( SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull) );
if ( !(isnull || oid==InvalidOid) ) { oid = DatumGetObjectId(SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull));
opt=SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 2, &isnull); if (!(isnull || oid == InvalidOid))
dict->dictionary=(void*)DatumGetPointer(OidFunctionCall1(oid, opt)); {
opt = SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 2, &isnull);
dict->dictionary = (void *) DatumGetPointer(OidFunctionCall1(oid, opt));
} }
oid=DatumGetObjectId( SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 3, &isnull) ); oid = DatumGetObjectId(SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 3, &isnull));
if ( isnull || oid==InvalidOid ) if (isnull || oid == InvalidOid)
ts_error(ERROR, "Null dict_lexize for dictonary %d", id); ts_error(ERROR, "Null dict_lexize for dictonary %d", id);
fmgr_info_cxt(oid, &(dict->lexize_info), TopMemoryContext); fmgr_info_cxt(oid, &(dict->lexize_info), TopMemoryContext);
dict->dict_id=id; dict->dict_id = id;
} else }
else
ts_error(ERROR, "No dictionary with id %d", id); ts_error(ERROR, "No dictionary with id %d", id);
SPI_finish(); SPI_finish();
} }
typedef struct { typedef struct
{
DictInfo *last_dict; DictInfo *last_dict;
int len; int len;
int reallen; int reallen;
...@@ -65,86 +72,95 @@ typedef struct { ...@@ -65,86 +72,95 @@ typedef struct {
SNMap name2id_map; SNMap name2id_map;
} DictList; } DictList;
static DictList DList = {NULL,0,0,NULL,{0,0,NULL}}; static DictList DList = {NULL, 0, 0, NULL, {0, 0, NULL}};
void void
reset_dict(void) { reset_dict(void)
freeSNMap( &(DList.name2id_map) ); {
freeSNMap(&(DList.name2id_map));
/* XXX need to free DList.list[*].dictionary */ /* XXX need to free DList.list[*].dictionary */
if ( DList.list ) if (DList.list)
free(DList.list); free(DList.list);
memset(&DList,0,sizeof(DictList)); memset(&DList, 0, sizeof(DictList));
} }
static int static int
comparedict(const void *a, const void *b) { comparedict(const void *a, const void *b)
return ((DictInfo*)a)->dict_id - ((DictInfo*)b)->dict_id; {
return ((DictInfo *) a)->dict_id - ((DictInfo *) b)->dict_id;
} }
DictInfo * DictInfo *
finddict(Oid id) { finddict(Oid id)
{
/* last used dict */ /* last used dict */
if ( DList.last_dict && DList.last_dict->dict_id==id ) if (DList.last_dict && DList.last_dict->dict_id == id)
return DList.last_dict; return DList.last_dict;
/* already used dict */ /* already used dict */
if ( DList.len != 0 ) { if (DList.len != 0)
{
DictInfo key; DictInfo key;
key.dict_id=id;
key.dict_id = id;
DList.last_dict = bsearch(&key, DList.list, DList.len, sizeof(DictInfo), comparedict); DList.last_dict = bsearch(&key, DList.list, DList.len, sizeof(DictInfo), comparedict);
if ( DList.last_dict != NULL ) if (DList.last_dict != NULL)
return DList.last_dict; return DList.last_dict;
} }
/* last chance */ /* last chance */
if ( DList.len==DList.reallen ) { if (DList.len == DList.reallen)
{
DictInfo *tmp; DictInfo *tmp;
int reallen = ( DList.reallen ) ? 2*DList.reallen : 16; int reallen = (DList.reallen) ? 2 * DList.reallen : 16;
tmp=(DictInfo*)realloc(DList.list,sizeof(DictInfo)*reallen);
if ( !tmp ) tmp = (DictInfo *) realloc(DList.list, sizeof(DictInfo) * reallen);
ts_error(ERROR,"No memory"); if (!tmp)
DList.reallen=reallen; ts_error(ERROR, "No memory");
DList.list=tmp; DList.reallen = reallen;
DList.list = tmp;
} }
DList.last_dict=&(DList.list[DList.len]); DList.last_dict = &(DList.list[DList.len]);
init_dict(id, DList.last_dict); init_dict(id, DList.last_dict);
DList.len++; DList.len++;
qsort(DList.list, DList.len, sizeof(DictInfo), comparedict); qsort(DList.list, DList.len, sizeof(DictInfo), comparedict);
return finddict(id); /* qsort changed order!! */; return finddict(id); /* qsort changed order!! */ ;
} }
static void *plan_name2id=NULL; static void *plan_name2id = NULL;
Oid Oid
name2id_dict(text *name) { name2id_dict(text *name)
Oid arg[1]={ TEXTOID }; {
Oid arg[1] = {TEXTOID};
bool isnull; bool isnull;
Datum pars[1]={ PointerGetDatum(name) }; Datum pars[1] = {PointerGetDatum(name)};
int stat; int stat;
Oid id=findSNMap_t( &(DList.name2id_map), name ); Oid id = findSNMap_t(&(DList.name2id_map), name);
if ( id ) if (id)
return id; return id;
SPI_connect(); SPI_connect();
if ( !plan_name2id ) { if (!plan_name2id)
plan_name2id = SPI_saveplan( SPI_prepare( "select oid from pg_ts_dict where dict_name = $1" , 1, arg ) ); {
if ( !plan_name2id ) plan_name2id = SPI_saveplan(SPI_prepare("select oid from pg_ts_dict where dict_name = $1", 1, arg));
if (!plan_name2id)
ts_error(ERROR, "SPI_prepare() failed"); ts_error(ERROR, "SPI_prepare() failed");
} }
stat = SPI_execp(plan_name2id, pars, " ", 1); stat = SPI_execp(plan_name2id, pars, " ", 1);
if ( stat < 0 ) if (stat < 0)
ts_error (ERROR, "SPI_execp return %d", stat); ts_error(ERROR, "SPI_execp return %d", stat);
if ( SPI_processed > 0 ) if (SPI_processed > 0)
id=DatumGetObjectId( SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull) ); id = DatumGetObjectId(SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, &isnull));
else else
ts_error(ERROR, "No dictionary with name '%s'", text2char(name)); ts_error(ERROR, "No dictionary with name '%s'", text2char(name));
SPI_finish(); SPI_finish();
addSNMap_t( &(DList.name2id_map), name, id ); addSNMap_t(&(DList.name2id_map), name, id);
return id; return id;
} }
...@@ -154,50 +170,56 @@ PG_FUNCTION_INFO_V1(lexize); ...@@ -154,50 +170,56 @@ PG_FUNCTION_INFO_V1(lexize);
Datum lexize(PG_FUNCTION_ARGS); Datum lexize(PG_FUNCTION_ARGS);
Datum Datum
lexize(PG_FUNCTION_ARGS) { lexize(PG_FUNCTION_ARGS)
text *in=PG_GETARG_TEXT_P(1); {
DictInfo *dict = finddict( PG_GETARG_OID(0) ); text *in = PG_GETARG_TEXT_P(1);
char **res, **ptr; DictInfo *dict = finddict(PG_GETARG_OID(0));
char **res,
**ptr;
Datum *da; Datum *da;
ArrayType *a; ArrayType *a;
ptr = res = (char**)DatumGetPointer( ptr = res = (char **) DatumGetPointer(
FunctionCall3(&(dict->lexize_info), FunctionCall3(&(dict->lexize_info),
PointerGetDatum(dict->dictionary), PointerGetDatum(dict->dictionary),
PointerGetDatum(VARDATA(in)), PointerGetDatum(VARDATA(in)),
Int32GetDatum(VARSIZE(in)-VARHDRSZ) Int32GetDatum(VARSIZE(in) - VARHDRSZ)
) )
); );
PG_FREE_IF_COPY(in, 1); PG_FREE_IF_COPY(in, 1);
if ( !res ) { if (!res)
{
if (PG_NARGS() > 2) if (PG_NARGS() > 2)
PG_RETURN_POINTER(NULL); PG_RETURN_POINTER(NULL);
else else
PG_RETURN_NULL(); PG_RETURN_NULL();
} }
while(*ptr) ptr++; while (*ptr)
da = (Datum*)palloc(sizeof(Datum)*(ptr-res+1)); ptr++;
ptr=res; da = (Datum *) palloc(sizeof(Datum) * (ptr - res + 1));
while(*ptr) { ptr = res;
da[ ptr-res ] = PointerGetDatum( char2text(*ptr) ); while (*ptr)
{
da[ptr - res] = PointerGetDatum(char2text(*ptr));
ptr++; ptr++;
} }
a = construct_array( a = construct_array(
da, da,
ptr-res, ptr - res,
TEXTOID, TEXTOID,
-1, -1,
false, false,
'i' 'i'
); );
ptr=res; ptr = res;
while(*ptr) { while (*ptr)
pfree( DatumGetPointer(da[ ptr-res ]) ); {
pfree( *ptr ); pfree(DatumGetPointer(da[ptr - res]));
pfree(*ptr);
ptr++; ptr++;
} }
pfree(res); pfree(res);
...@@ -209,16 +231,17 @@ lexize(PG_FUNCTION_ARGS) { ...@@ -209,16 +231,17 @@ lexize(PG_FUNCTION_ARGS) {
PG_FUNCTION_INFO_V1(lexize_byname); PG_FUNCTION_INFO_V1(lexize_byname);
Datum lexize_byname(PG_FUNCTION_ARGS); Datum lexize_byname(PG_FUNCTION_ARGS);
Datum Datum
lexize_byname(PG_FUNCTION_ARGS) { lexize_byname(PG_FUNCTION_ARGS)
text *dictname=PG_GETARG_TEXT_P(0); {
text *dictname = PG_GETARG_TEXT_P(0);
Datum res; Datum res;
strdup("simple"); strdup("simple");
res=DirectFunctionCall3( res = DirectFunctionCall3(
lexize, lexize,
ObjectIdGetDatum(name2id_dict(dictname)), ObjectIdGetDatum(name2id_dict(dictname)),
PG_GETARG_DATUM(1), PG_GETARG_DATUM(1),
(Datum)0 (Datum) 0
); );
PG_FREE_IF_COPY(dictname, 0); PG_FREE_IF_COPY(dictname, 0);
if (res) if (res)
...@@ -227,26 +250,28 @@ lexize_byname(PG_FUNCTION_ARGS) { ...@@ -227,26 +250,28 @@ lexize_byname(PG_FUNCTION_ARGS) {
PG_RETURN_NULL(); PG_RETURN_NULL();
} }
static Oid currect_dictionary_id=0; static Oid currect_dictionary_id = 0;
PG_FUNCTION_INFO_V1(set_curdict); PG_FUNCTION_INFO_V1(set_curdict);
Datum set_curdict(PG_FUNCTION_ARGS); Datum set_curdict(PG_FUNCTION_ARGS);
Datum Datum
set_curdict(PG_FUNCTION_ARGS) { set_curdict(PG_FUNCTION_ARGS)
{
finddict(PG_GETARG_OID(0)); finddict(PG_GETARG_OID(0));
currect_dictionary_id=PG_GETARG_OID(0); currect_dictionary_id = PG_GETARG_OID(0);
PG_RETURN_VOID(); PG_RETURN_VOID();
} }
PG_FUNCTION_INFO_V1(set_curdict_byname); PG_FUNCTION_INFO_V1(set_curdict_byname);
Datum set_curdict_byname(PG_FUNCTION_ARGS); Datum set_curdict_byname(PG_FUNCTION_ARGS);
Datum Datum
set_curdict_byname(PG_FUNCTION_ARGS) { set_curdict_byname(PG_FUNCTION_ARGS)
text *dictname=PG_GETARG_TEXT_P(0); {
text *dictname = PG_GETARG_TEXT_P(0);
DirectFunctionCall1( DirectFunctionCall1(
set_curdict, set_curdict,
ObjectIdGetDatum( name2id_dict(dictname) ) ObjectIdGetDatum(name2id_dict(dictname))
); );
PG_FREE_IF_COPY(dictname, 0); PG_FREE_IF_COPY(dictname, 0);
PG_RETURN_VOID(); PG_RETURN_VOID();
...@@ -255,9 +280,11 @@ set_curdict_byname(PG_FUNCTION_ARGS) { ...@@ -255,9 +280,11 @@ set_curdict_byname(PG_FUNCTION_ARGS) {
PG_FUNCTION_INFO_V1(lexize_bycurrent); PG_FUNCTION_INFO_V1(lexize_bycurrent);
Datum lexize_bycurrent(PG_FUNCTION_ARGS); Datum lexize_bycurrent(PG_FUNCTION_ARGS);
Datum Datum
lexize_bycurrent(PG_FUNCTION_ARGS) { lexize_bycurrent(PG_FUNCTION_ARGS)
{
Datum res; Datum res;
if ( currect_dictionary_id == 0 )
if (currect_dictionary_id == 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("no currect dictionary"), errmsg("no currect dictionary"),
...@@ -267,12 +294,10 @@ lexize_bycurrent(PG_FUNCTION_ARGS) { ...@@ -267,12 +294,10 @@ lexize_bycurrent(PG_FUNCTION_ARGS) {
lexize, lexize,
ObjectIdGetDatum(currect_dictionary_id), ObjectIdGetDatum(currect_dictionary_id),
PG_GETARG_DATUM(0), PG_GETARG_DATUM(0),
(Datum)0 (Datum) 0
); );
if (res) if (res)
PG_RETURN_DATUM(res); PG_RETURN_DATUM(res);
else else
PG_RETURN_NULL(); PG_RETURN_NULL();
} }
...@@ -3,36 +3,39 @@ ...@@ -3,36 +3,39 @@
#include "postgres.h" #include "postgres.h"
#include "fmgr.h" #include "fmgr.h"
typedef struct { typedef struct
{
int len; int len;
char **stop; char **stop;
char* (*wordop)(char*); char *(*wordop) (char *);
} StopList; } StopList;
void sortstoplist(StopList *s); void sortstoplist(StopList * s);
void freestoplist(StopList *s); void freestoplist(StopList * s);
void readstoplist(text *in, StopList *s); void readstoplist(text *in, StopList * s);
bool searchstoplist(StopList *s, char *key); bool searchstoplist(StopList * s, char *key);
char* lowerstr(char *str); char *lowerstr(char *str);
typedef struct { typedef struct
{
Oid dict_id; Oid dict_id;
FmgrInfo lexize_info; FmgrInfo lexize_info;
void *dictionary; void *dictionary;
} DictInfo; } DictInfo;
void init_dict(Oid id, DictInfo *dict); void init_dict(Oid id, DictInfo * dict);
DictInfo* finddict(Oid id); DictInfo *finddict(Oid id);
Oid name2id_dict(text *name); Oid name2id_dict(text *name);
void reset_dict(void); void reset_dict(void);
/* simple parser of cfg string */ /* simple parser of cfg string */
typedef struct { typedef struct
{
char *key; char *key;
char *value; char *value;
} Map; } Map;
void parse_cfgdict(text *in, Map **m); void parse_cfgdict(text *in, Map ** m);
#endif #endif
...@@ -11,30 +11,35 @@ ...@@ -11,30 +11,35 @@
#include "dict.h" #include "dict.h"
#include "common.h" #include "common.h"
typedef struct { typedef struct
{
StopList stoplist; StopList stoplist;
} DictExample; } DictExample;
PG_FUNCTION_INFO_V1(dex_init); PG_FUNCTION_INFO_V1(dex_init);
Datum dex_init(PG_FUNCTION_ARGS); Datum dex_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(dex_lexize); PG_FUNCTION_INFO_V1(dex_lexize);
Datum dex_lexize(PG_FUNCTION_ARGS); Datum dex_lexize(PG_FUNCTION_ARGS);
Datum Datum
dex_init(PG_FUNCTION_ARGS) { dex_init(PG_FUNCTION_ARGS)
DictExample *d = (DictExample*)malloc( sizeof(DictExample) ); {
DictExample *d = (DictExample *) malloc(sizeof(DictExample));
if ( !d ) if (!d)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
memset(d,0,sizeof(DictExample)); memset(d, 0, sizeof(DictExample));
d->stoplist.wordop=lowerstr; d->stoplist.wordop = lowerstr;
if ( !PG_ARGISNULL(0) && PG_GETARG_POINTER(0)!=NULL ) { if (!PG_ARGISNULL(0) && PG_GETARG_POINTER(0) != NULL)
{
text *in = PG_GETARG_TEXT_P(0); text *in = PG_GETARG_TEXT_P(0);
readstoplist(in, &(d->stoplist)); readstoplist(in, &(d->stoplist));
sortstoplist(&(d->stoplist)); sortstoplist(&(d->stoplist));
PG_FREE_IF_COPY(in, 0); PG_FREE_IF_COPY(in, 0);
...@@ -44,18 +49,21 @@ dex_init(PG_FUNCTION_ARGS) { ...@@ -44,18 +49,21 @@ dex_init(PG_FUNCTION_ARGS) {
} }
Datum Datum
dex_lexize(PG_FUNCTION_ARGS) { dex_lexize(PG_FUNCTION_ARGS)
DictExample *d = (DictExample*)PG_GETARG_POINTER(0); {
char *in = (char*)PG_GETARG_POINTER(1); DictExample *d = (DictExample *) PG_GETARG_POINTER(0);
char *in = (char *) PG_GETARG_POINTER(1);
char *txt = pnstrdup(in, PG_GETARG_INT32(2)); char *txt = pnstrdup(in, PG_GETARG_INT32(2));
char **res=palloc(sizeof(char*)*2); char **res = palloc(sizeof(char *) * 2);
if ( *txt=='\0' || searchstoplist(&(d->stoplist),txt) ) { if (*txt == '\0' || searchstoplist(&(d->stoplist), txt))
{
pfree(txt); pfree(txt);
res[0]=NULL; res[0] = NULL;
} else }
res[0]=txt; else
res[1]=NULL; res[0] = txt;
res[1] = NULL;
PG_RETURN_POINTER(res); PG_RETURN_POINTER(res);
} }
...@@ -12,81 +12,100 @@ ...@@ -12,81 +12,100 @@
#include "common.h" #include "common.h"
#include "ispell/spell.h" #include "ispell/spell.h"
typedef struct { typedef struct
{
StopList stoplist; StopList stoplist;
IspellDict obj; IspellDict obj;
} DictISpell; } DictISpell;
PG_FUNCTION_INFO_V1(spell_init); PG_FUNCTION_INFO_V1(spell_init);
Datum spell_init(PG_FUNCTION_ARGS); Datum spell_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(spell_lexize); PG_FUNCTION_INFO_V1(spell_lexize);
Datum spell_lexize(PG_FUNCTION_ARGS); Datum spell_lexize(PG_FUNCTION_ARGS);
static void static void
freeDictISpell(DictISpell *d) { freeDictISpell(DictISpell * d)
{
FreeIspell(&(d->obj)); FreeIspell(&(d->obj));
freestoplist(&(d->stoplist)); freestoplist(&(d->stoplist));
free(d); free(d);
} }
Datum Datum
spell_init(PG_FUNCTION_ARGS) { spell_init(PG_FUNCTION_ARGS)
{
DictISpell *d; DictISpell *d;
Map *cfg, *pcfg; Map *cfg,
*pcfg;
text *in; text *in;
bool affloaded=false, dictloaded=false, stoploaded=false; bool affloaded = false,
dictloaded = false,
stoploaded = false;
if ( PG_ARGISNULL(0) || PG_GETARG_POINTER(0)==NULL ) if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CONFIG_FILE_ERROR), (errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("ISpell confguration error"))); errmsg("ISpell confguration error")));
d = (DictISpell*)malloc( sizeof(DictISpell) ); d = (DictISpell *) malloc(sizeof(DictISpell));
if ( !d ) if (!d)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
memset(d,0,sizeof(DictISpell)); memset(d, 0, sizeof(DictISpell));
d->stoplist.wordop=lowerstr; d->stoplist.wordop = lowerstr;
in = PG_GETARG_TEXT_P(0); in = PG_GETARG_TEXT_P(0);
parse_cfgdict(in,&cfg); parse_cfgdict(in, &cfg);
PG_FREE_IF_COPY(in, 0); PG_FREE_IF_COPY(in, 0);
pcfg=cfg; pcfg = cfg;
while(pcfg->key) { while (pcfg->key)
if ( strcasecmp("DictFile", pcfg->key) == 0 ) { {
if ( dictloaded ) { if (strcasecmp("DictFile", pcfg->key) == 0)
{
if (dictloaded)
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("dictionary already loaded"))); errmsg("dictionary already loaded")));
} }
if ( ImportDictionary(&(d->obj), pcfg->value) ) { if (ImportDictionary(&(d->obj), pcfg->value))
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CONFIG_FILE_ERROR), (errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("could not load dictionary file \"%s\"", errmsg("could not load dictionary file \"%s\"",
pcfg->value))); pcfg->value)));
} }
dictloaded=true; dictloaded = true;
} else if ( strcasecmp("AffFile", pcfg->key) == 0 ) { }
if ( affloaded ) { else if (strcasecmp("AffFile", pcfg->key) == 0)
{
if (affloaded)
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("affixes already loaded"))); errmsg("affixes already loaded")));
} }
if ( ImportAffixes(&(d->obj), pcfg->value) ) { if (ImportAffixes(&(d->obj), pcfg->value))
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CONFIG_FILE_ERROR), (errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("could not load affix file \"%s\"", errmsg("could not load affix file \"%s\"",
pcfg->value))); pcfg->value)));
} }
affloaded=true; affloaded = true;
} else if ( strcasecmp("StopFile", pcfg->key) == 0 ) { }
text *tmp=char2text(pcfg->value); else if (strcasecmp("StopFile", pcfg->key) == 0)
if ( stoploaded ) { {
text *tmp = char2text(pcfg->value);
if (stoploaded)
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
...@@ -95,8 +114,10 @@ spell_init(PG_FUNCTION_ARGS) { ...@@ -95,8 +114,10 @@ spell_init(PG_FUNCTION_ARGS) {
readstoplist(tmp, &(d->stoplist)); readstoplist(tmp, &(d->stoplist));
sortstoplist(&(d->stoplist)); sortstoplist(&(d->stoplist));
pfree(tmp); pfree(tmp);
stoploaded=true; stoploaded = true;
} else { }
else
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
...@@ -109,15 +130,20 @@ spell_init(PG_FUNCTION_ARGS) { ...@@ -109,15 +130,20 @@ spell_init(PG_FUNCTION_ARGS) {
} }
pfree(cfg); pfree(cfg);
if ( affloaded && dictloaded ) { if (affloaded && dictloaded)
{
SortDictionary(&(d->obj)); SortDictionary(&(d->obj));
SortAffixes(&(d->obj)); SortAffixes(&(d->obj));
} else if ( !affloaded ) { }
else if (!affloaded)
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("no affixes"))); errmsg("no affixes")));
} else { }
else
{
freeDictISpell(d); freeDictISpell(d);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
...@@ -128,37 +154,43 @@ spell_init(PG_FUNCTION_ARGS) { ...@@ -128,37 +154,43 @@ spell_init(PG_FUNCTION_ARGS) {
} }
Datum Datum
spell_lexize(PG_FUNCTION_ARGS) { spell_lexize(PG_FUNCTION_ARGS)
DictISpell *d = (DictISpell*)PG_GETARG_POINTER(0); {
char *in = (char*)PG_GETARG_POINTER(1); DictISpell *d = (DictISpell *) PG_GETARG_POINTER(0);
char *in = (char *) PG_GETARG_POINTER(1);
char *txt; char *txt;
char **res; char **res;
char **ptr, **cptr; char **ptr,
**cptr;
if ( !PG_GETARG_INT32(2) ) if (!PG_GETARG_INT32(2))
PG_RETURN_POINTER(NULL); PG_RETURN_POINTER(NULL);
res=palloc(sizeof(char*)*2); res = palloc(sizeof(char *) * 2);
txt = pnstrdup(in, PG_GETARG_INT32(2)); txt = pnstrdup(in, PG_GETARG_INT32(2));
res=NormalizeWord(&(d->obj), txt); res = NormalizeWord(&(d->obj), txt);
pfree(txt); pfree(txt);
if ( res==NULL ) if (res == NULL)
PG_RETURN_POINTER(NULL); PG_RETURN_POINTER(NULL);
ptr=cptr=res; ptr = cptr = res;
while(*ptr) { while (*ptr)
if ( searchstoplist(&(d->stoplist),*ptr) ) { {
if (searchstoplist(&(d->stoplist), *ptr))
{
pfree(*ptr); pfree(*ptr);
*ptr=NULL; *ptr = NULL;
ptr++; ptr++;
} else {
*cptr=*ptr;
cptr++; ptr++;
} }
else
{
*cptr = *ptr;
cptr++;
ptr++;
} }
*cptr=NULL; }
*cptr = NULL;
PG_RETURN_POINTER(res); PG_RETURN_POINTER(res);
} }
...@@ -14,103 +14,118 @@ ...@@ -14,103 +14,118 @@
#include "snowball/english_stem.h" #include "snowball/english_stem.h"
#include "snowball/russian_stem.h" #include "snowball/russian_stem.h"
typedef struct { typedef struct
{
struct SN_env *z; struct SN_env *z;
StopList stoplist; StopList stoplist;
int (*stem)(struct SN_env * z); int (*stem) (struct SN_env * z);
} DictSnowball; } DictSnowball;
PG_FUNCTION_INFO_V1(snb_en_init); PG_FUNCTION_INFO_V1(snb_en_init);
Datum snb_en_init(PG_FUNCTION_ARGS); Datum snb_en_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(snb_ru_init); PG_FUNCTION_INFO_V1(snb_ru_init);
Datum snb_ru_init(PG_FUNCTION_ARGS); Datum snb_ru_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(snb_lexize); PG_FUNCTION_INFO_V1(snb_lexize);
Datum snb_lexize(PG_FUNCTION_ARGS); Datum snb_lexize(PG_FUNCTION_ARGS);
Datum Datum
snb_en_init(PG_FUNCTION_ARGS) { snb_en_init(PG_FUNCTION_ARGS)
DictSnowball *d = (DictSnowball*)malloc( sizeof(DictSnowball) ); {
DictSnowball *d = (DictSnowball *) malloc(sizeof(DictSnowball));
if ( !d ) if (!d)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
memset(d,0,sizeof(DictSnowball)); memset(d, 0, sizeof(DictSnowball));
d->stoplist.wordop=lowerstr; d->stoplist.wordop = lowerstr;
if ( !PG_ARGISNULL(0) && PG_GETARG_POINTER(0)!=NULL ) { if (!PG_ARGISNULL(0) && PG_GETARG_POINTER(0) != NULL)
{
text *in = PG_GETARG_TEXT_P(0); text *in = PG_GETARG_TEXT_P(0);
readstoplist(in, &(d->stoplist)); readstoplist(in, &(d->stoplist));
sortstoplist(&(d->stoplist)); sortstoplist(&(d->stoplist));
PG_FREE_IF_COPY(in, 0); PG_FREE_IF_COPY(in, 0);
} }
d->z = english_create_env(); d->z = english_create_env();
if (!d->z) { if (!d->z)
{
freestoplist(&(d->stoplist)); freestoplist(&(d->stoplist));
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
} }
d->stem=english_stem; d->stem = english_stem;
PG_RETURN_POINTER(d); PG_RETURN_POINTER(d);
} }
Datum Datum
snb_ru_init(PG_FUNCTION_ARGS) { snb_ru_init(PG_FUNCTION_ARGS)
DictSnowball *d = (DictSnowball*)malloc( sizeof(DictSnowball) ); {
DictSnowball *d = (DictSnowball *) malloc(sizeof(DictSnowball));
if ( !d ) if (!d)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
memset(d,0,sizeof(DictSnowball)); memset(d, 0, sizeof(DictSnowball));
d->stoplist.wordop=lowerstr; d->stoplist.wordop = lowerstr;
if ( !PG_ARGISNULL(0) && PG_GETARG_POINTER(0)!=NULL ) { if (!PG_ARGISNULL(0) && PG_GETARG_POINTER(0) != NULL)
{
text *in = PG_GETARG_TEXT_P(0); text *in = PG_GETARG_TEXT_P(0);
readstoplist(in, &(d->stoplist)); readstoplist(in, &(d->stoplist));
sortstoplist(&(d->stoplist)); sortstoplist(&(d->stoplist));
PG_FREE_IF_COPY(in, 0); PG_FREE_IF_COPY(in, 0);
} }
d->z = russian_create_env(); d->z = russian_create_env();
if (!d->z) { if (!d->z)
{
freestoplist(&(d->stoplist)); freestoplist(&(d->stoplist));
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
} }
d->stem=russian_stem; d->stem = russian_stem;
PG_RETURN_POINTER(d); PG_RETURN_POINTER(d);
} }
Datum Datum
snb_lexize(PG_FUNCTION_ARGS) { snb_lexize(PG_FUNCTION_ARGS)
DictSnowball *d = (DictSnowball*)PG_GETARG_POINTER(0); {
char *in = (char*)PG_GETARG_POINTER(1); DictSnowball *d = (DictSnowball *) PG_GETARG_POINTER(0);
char *in = (char *) PG_GETARG_POINTER(1);
char *txt = pnstrdup(in, PG_GETARG_INT32(2)); char *txt = pnstrdup(in, PG_GETARG_INT32(2));
char **res=palloc(sizeof(char*)*2); char **res = palloc(sizeof(char *) * 2);
if ( *txt=='\0' || searchstoplist(&(d->stoplist),txt) ) { if (*txt == '\0' || searchstoplist(&(d->stoplist), txt))
{
pfree(txt); pfree(txt);
res[0]=NULL; res[0] = NULL;
} else { }
else
{
SN_set_current(d->z, strlen(txt), txt); SN_set_current(d->z, strlen(txt), txt);
(d->stem)(d->z); (d->stem) (d->z);
if ( d->z->p && d->z->l ) { if (d->z->p && d->z->l)
txt=repalloc(txt, d->z->l+1); {
memcpy( txt, d->z->p, d->z->l); txt = repalloc(txt, d->z->l + 1);
txt[d->z->l]='\0'; memcpy(txt, d->z->p, d->z->l);
txt[d->z->l] = '\0';
} }
res[0]=txt; res[0] = txt;
} }
res[1]=NULL; res[1] = NULL;
PG_RETURN_POINTER(res); PG_RETURN_POINTER(res);
} }
...@@ -13,93 +13,106 @@ ...@@ -13,93 +13,106 @@
#include "common.h" #include "common.h"
#define SYNBUFLEN 4096 #define SYNBUFLEN 4096
typedef struct { typedef struct
{
char *in; char *in;
char *out; char *out;
} Syn; } Syn;
typedef struct { typedef struct
{
int len; int len;
Syn *syn; Syn *syn;
} DictSyn; } DictSyn;
PG_FUNCTION_INFO_V1(syn_init); PG_FUNCTION_INFO_V1(syn_init);
Datum syn_init(PG_FUNCTION_ARGS); Datum syn_init(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(syn_lexize); PG_FUNCTION_INFO_V1(syn_lexize);
Datum syn_lexize(PG_FUNCTION_ARGS); Datum syn_lexize(PG_FUNCTION_ARGS);
static char * static char *
findwrd(char *in, char **end) { findwrd(char *in, char **end)
{
char *start; char *start;
*end=NULL; *end = NULL;
while(*in && isspace(*in)) while (*in && isspace(*in))
in++; in++;
if ( !in ) if (!in)
return NULL; return NULL;
start=in; start = in;
while(*in && !isspace(*in)) while (*in && !isspace(*in))
in++; in++;
*end=in; *end = in;
return start; return start;
} }
static int static int
compareSyn(const void *a, const void *b) { compareSyn(const void *a, const void *b)
return strcmp( ((Syn*)a)->in, ((Syn*)b)->in ); {
return strcmp(((Syn *) a)->in, ((Syn *) b)->in);
} }
Datum Datum
syn_init(PG_FUNCTION_ARGS) { syn_init(PG_FUNCTION_ARGS)
{
text *in; text *in;
DictSyn *d; DictSyn *d;
int cur=0; int cur = 0;
FILE *fin; FILE *fin;
char *filename; char *filename;
char buf[SYNBUFLEN]; char buf[SYNBUFLEN];
char *starti,*starto,*end=NULL; char *starti,
*starto,
*end = NULL;
int slen; int slen;
if ( PG_ARGISNULL(0) || PG_GETARG_POINTER(0)==NULL ) if (PG_ARGISNULL(0) || PG_GETARG_POINTER(0) == NULL)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("NULL config"))); errmsg("NULL config")));
in = PG_GETARG_TEXT_P(0); in = PG_GETARG_TEXT_P(0);
if ( VARSIZE(in) - VARHDRSZ == 0 ) if (VARSIZE(in) - VARHDRSZ == 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("VOID config"))); errmsg("VOID config")));
filename=text2char(in); filename = text2char(in);
PG_FREE_IF_COPY(in, 0); PG_FREE_IF_COPY(in, 0);
if ( (fin=fopen(filename,"r")) == NULL ) if ((fin = fopen(filename, "r")) == NULL)
ereport(ERROR, ereport(ERROR,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not open file \"%s\": %m", errmsg("could not open file \"%s\": %m",
filename))); filename)));
d = (DictSyn*)malloc( sizeof(DictSyn) ); d = (DictSyn *) malloc(sizeof(DictSyn));
if ( !d ) { if (!d)
{
fclose(fin); fclose(fin);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
} }
memset(d,0,sizeof(DictSyn)); memset(d, 0, sizeof(DictSyn));
while( fgets(buf,SYNBUFLEN,fin) ) { while (fgets(buf, SYNBUFLEN, fin))
slen = strlen(buf)-1; {
slen = strlen(buf) - 1;
buf[slen] = '\0'; buf[slen] = '\0';
if ( *buf=='\0' ) continue; if (*buf == '\0')
if (cur==d->len) { continue;
d->len = (d->len) ? 2*d->len : 16; if (cur == d->len)
d->syn=(Syn*)realloc( d->syn, sizeof(Syn)*d->len ); {
if ( !d->syn ) { d->len = (d->len) ? 2 * d->len : 16;
d->syn = (Syn *) realloc(d->syn, sizeof(Syn) * d->len);
if (!d->syn)
{
fclose(fin); fclose(fin);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
...@@ -107,21 +120,22 @@ syn_init(PG_FUNCTION_ARGS) { ...@@ -107,21 +120,22 @@ syn_init(PG_FUNCTION_ARGS) {
} }
} }
starti=findwrd(buf,&end); starti = findwrd(buf, &end);
if ( !starti ) if (!starti)
continue; continue;
*end='\0'; *end = '\0';
if ( end >= buf+slen ) if (end >= buf + slen)
continue; continue;
starto= findwrd(end+1, &end); starto = findwrd(end + 1, &end);
if ( !starto ) if (!starto)
continue; continue;
*end='\0'; *end = '\0';
d->syn[cur].in=strdup(lowerstr(starti)); d->syn[cur].in = strdup(lowerstr(starti));
d->syn[cur].out=strdup(lowerstr(starto)); d->syn[cur].out = strdup(lowerstr(starto));
if ( !(d->syn[cur].in && d->syn[cur].out) ) { if (!(d->syn[cur].in && d->syn[cur].out))
{
fclose(fin); fclose(fin);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
...@@ -133,8 +147,8 @@ syn_init(PG_FUNCTION_ARGS) { ...@@ -133,8 +147,8 @@ syn_init(PG_FUNCTION_ARGS) {
fclose(fin); fclose(fin);
d->len=cur; d->len = cur;
if ( cur>1 ) if (cur > 1)
qsort(d->syn, d->len, sizeof(Syn), compareSyn); qsort(d->syn, d->len, sizeof(Syn), compareSyn);
pfree(filename); pfree(filename);
...@@ -142,29 +156,30 @@ syn_init(PG_FUNCTION_ARGS) { ...@@ -142,29 +156,30 @@ syn_init(PG_FUNCTION_ARGS) {
} }
Datum Datum
syn_lexize(PG_FUNCTION_ARGS) { syn_lexize(PG_FUNCTION_ARGS)
DictSyn *d = (DictSyn*)PG_GETARG_POINTER(0); {
char *in = (char*)PG_GETARG_POINTER(1); DictSyn *d = (DictSyn *) PG_GETARG_POINTER(0);
Syn key,*found; char *in = (char *) PG_GETARG_POINTER(1);
char **res=NULL; Syn key,
*found;
if ( !PG_GETARG_INT32(2) ) char **res = NULL;
if (!PG_GETARG_INT32(2))
PG_RETURN_POINTER(NULL); PG_RETURN_POINTER(NULL);
key.out=NULL; key.out = NULL;
key.in=lowerstr(pnstrdup(in, PG_GETARG_INT32(2))); key.in = lowerstr(pnstrdup(in, PG_GETARG_INT32(2)));
found=(Syn*)bsearch(&key, d->syn, d->len, sizeof(Syn), compareSyn); found = (Syn *) bsearch(&key, d->syn, d->len, sizeof(Syn), compareSyn);
pfree(key.in); pfree(key.in);
if ( !found ) if (!found)
PG_RETURN_POINTER(NULL); PG_RETURN_POINTER(NULL);
res=palloc(sizeof(char*)*2); res = palloc(sizeof(char *) * 2);
res[0]=pstrdup(found->out); res[0] = pstrdup(found->out);
res[1]=NULL; res[1] = NULL;
PG_RETURN_POINTER(res); PG_RETURN_POINTER(res);
} }
This diff is collapsed.
...@@ -4,12 +4,14 @@ ...@@ -4,12 +4,14 @@
#include <sys/types.h> #include <sys/types.h>
#include <regex.h> #include <regex.h>
typedef struct spell_struct { typedef struct spell_struct
char * word; {
char *word;
char flag[10]; char flag[10];
} SPELL; } SPELL;
typedef struct aff_struct { typedef struct aff_struct
{
char flag; char flag;
char type; char type;
char mask[33]; char mask[33];
...@@ -20,14 +22,17 @@ typedef struct aff_struct { ...@@ -20,14 +22,17 @@ typedef struct aff_struct {
char compile; char compile;
} AFFIX; } AFFIX;
typedef struct Tree_struct { typedef struct Tree_struct
int Left[256], Right[256]; {
int Left[256],
Right[256];
} Tree_struct; } Tree_struct;
typedef struct { typedef struct
{
int maffixes; int maffixes;
int naffixes; int naffixes;
AFFIX * Affix; AFFIX *Affix;
int nspell; int nspell;
int mspell; int mspell;
...@@ -38,14 +43,14 @@ typedef struct { ...@@ -38,14 +43,14 @@ typedef struct {
} IspellDict; } IspellDict;
char ** NormalizeWord(IspellDict * Conf,char *word); char **NormalizeWord(IspellDict * Conf, char *word);
int ImportAffixes(IspellDict * Conf, const char *filename); int ImportAffixes(IspellDict * Conf, const char *filename);
int ImportDictionary(IspellDict * Conf,const char *filename); int ImportDictionary(IspellDict * Conf, const char *filename);
int AddSpell(IspellDict * Conf,const char * word,const char *flag); int AddSpell(IspellDict * Conf, const char *word, const char *flag);
int AddAffix(IspellDict * Conf,int flag,const char *mask,const char *find,const char *repl,int type); int AddAffix(IspellDict * Conf, int flag, const char *mask, const char *find, const char *repl, int type);
void SortDictionary(IspellDict * Conf); void SortDictionary(IspellDict * Conf);
void SortAffixes(IspellDict * Conf); void SortAffixes(IspellDict * Conf);
void FreeIspell (IspellDict *Conf); void FreeIspell(IspellDict * Conf);
#endif #endif
...@@ -22,120 +22,158 @@ ...@@ -22,120 +22,158 @@
#define CS_IN2ESC 8 #define CS_IN2ESC 8
static char * static char *
nstrdup(char *ptr, int len) { nstrdup(char *ptr, int len)
char *res=palloc(len+1), *cptr; {
memcpy(res,ptr,len); char *res = palloc(len + 1),
res[len]='\0'; *cptr;
memcpy(res, ptr, len);
res[len] = '\0';
cptr = ptr = res; cptr = ptr = res;
while(*ptr) { while (*ptr)
if ( *ptr == '\\' ) {
if (*ptr == '\\')
ptr++;
*cptr = *ptr;
ptr++; ptr++;
*cptr=*ptr; ptr++; cptr++; cptr++;
} }
*cptr='\0'; *cptr = '\0';
return res; return res;
} }
void void
parse_cfgdict(text *in, Map **m) { parse_cfgdict(text *in, Map ** m)
{
Map *mptr; Map *mptr;
char *ptr=VARDATA(in), *begin=NULL; char *ptr = VARDATA(in),
char num=0; *begin = NULL;
int state=CS_WAITKEY; char num = 0;
int state = CS_WAITKEY;
while( ptr-VARDATA(in) < VARSIZE(in) - VARHDRSZ ) { while (ptr - VARDATA(in) < VARSIZE(in) - VARHDRSZ)
if ( *ptr==',' ) num++; {
if (*ptr == ',')
num++;
ptr++; ptr++;
} }
*m=mptr=(Map*)palloc( sizeof(Map)*(num+2) ); *m = mptr = (Map *) palloc(sizeof(Map) * (num + 2));
memset(mptr, 0, sizeof(Map)*(num+2) ); memset(mptr, 0, sizeof(Map) * (num + 2));
ptr=VARDATA(in); ptr = VARDATA(in);
while( ptr-VARDATA(in) < VARSIZE(in) - VARHDRSZ ) { while (ptr - VARDATA(in) < VARSIZE(in) - VARHDRSZ)
if (state==CS_WAITKEY) { {
if (isalpha(*ptr)) { if (state == CS_WAITKEY)
begin=ptr; {
state=CS_INKEY; if (isalpha(*ptr))
} else if ( !isspace(*ptr) ) {
begin = ptr;
state = CS_INKEY;
}
else if (!isspace(*ptr))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error"), errmsg("syntax error"),
errdetail("Syntax error in position %d near \"%c\"", errdetail("Syntax error in position %d near \"%c\"",
(int) (ptr-VARDATA(in)), *ptr))); (int) (ptr - VARDATA(in)), *ptr)));
} else if (state==CS_INKEY) { }
if ( isspace(*ptr) ) { else if (state == CS_INKEY)
mptr->key=nstrdup(begin, ptr-begin); {
state=CS_WAITEQ; if (isspace(*ptr))
} else if ( *ptr=='=' ) { {
mptr->key=nstrdup(begin, ptr-begin); mptr->key = nstrdup(begin, ptr - begin);
state=CS_WAITVALUE; state = CS_WAITEQ;
} else if ( !isalpha(*ptr) ) }
else if (*ptr == '=')
{
mptr->key = nstrdup(begin, ptr - begin);
state = CS_WAITVALUE;
}
else if (!isalpha(*ptr))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error"), errmsg("syntax error"),
errdetail("Syntax error in position %d near \"%c\"", errdetail("Syntax error in position %d near \"%c\"",
(int) (ptr-VARDATA(in)), *ptr))); (int) (ptr - VARDATA(in)), *ptr)));
} else if ( state==CS_WAITEQ ) { }
if ( *ptr=='=' ) else if (state == CS_WAITEQ)
state=CS_WAITVALUE; {
else if ( !isspace(*ptr) ) if (*ptr == '=')
state = CS_WAITVALUE;
else if (!isspace(*ptr))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error"), errmsg("syntax error"),
errdetail("Syntax error in position %d near \"%c\"", errdetail("Syntax error in position %d near \"%c\"",
(int) (ptr-VARDATA(in)), *ptr))); (int) (ptr - VARDATA(in)), *ptr)));
} else if ( state==CS_WAITVALUE ) { }
if ( *ptr=='"' ) { else if (state == CS_WAITVALUE)
begin=ptr+1; {
state=CS_INVALUE; if (*ptr == '"')
} else if ( !isspace(*ptr) ) { {
begin=ptr; begin = ptr + 1;
state=CS_IN2VALUE; state = CS_INVALUE;
} }
} else if ( state==CS_INVALUE ) { else if (!isspace(*ptr))
if ( *ptr=='"' ) { {
mptr->value = nstrdup(begin, ptr-begin); begin = ptr;
state = CS_IN2VALUE;
}
}
else if (state == CS_INVALUE)
{
if (*ptr == '"')
{
mptr->value = nstrdup(begin, ptr - begin);
mptr++; mptr++;
state=CS_WAITDELIM; state = CS_WAITDELIM;
} else if ( *ptr=='\\' ) }
state=CS_INESC; else if (*ptr == '\\')
} else if ( state==CS_IN2VALUE ) { state = CS_INESC;
if ( isspace(*ptr) || *ptr==',' ) { }
mptr->value = nstrdup(begin, ptr-begin); else if (state == CS_IN2VALUE)
{
if (isspace(*ptr) || *ptr == ',')
{
mptr->value = nstrdup(begin, ptr - begin);
mptr++; mptr++;
state=( *ptr==',' ) ? CS_WAITKEY : CS_WAITDELIM; state = (*ptr == ',') ? CS_WAITKEY : CS_WAITDELIM;
} else if ( *ptr=='\\' ) }
state=CS_INESC; else if (*ptr == '\\')
} else if ( state==CS_WAITDELIM ) { state = CS_INESC;
if ( *ptr==',' ) }
state=CS_WAITKEY; else if (state == CS_WAITDELIM)
else if ( !isspace(*ptr) ) {
if (*ptr == ',')
state = CS_WAITKEY;
else if (!isspace(*ptr))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error"), errmsg("syntax error"),
errdetail("Syntax error in position %d near \"%c\"", errdetail("Syntax error in position %d near \"%c\"",
(int) (ptr-VARDATA(in)), *ptr))); (int) (ptr - VARDATA(in)), *ptr)));
} else if ( state == CS_INESC ) { }
state=CS_INVALUE; else if (state == CS_INESC)
} else if ( state == CS_IN2ESC ) { state = CS_INVALUE;
state=CS_IN2VALUE; else if (state == CS_IN2ESC)
} else state = CS_IN2VALUE;
else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad parser state"), errmsg("bad parser state"),
errdetail("%d at position %d near \"%c\"", errdetail("%d at position %d near \"%c\"",
state, (int) (ptr-VARDATA(in)), *ptr))); state, (int) (ptr - VARDATA(in)), *ptr)));
ptr++; ptr++;
} }
if (state==CS_IN2VALUE) { if (state == CS_IN2VALUE)
mptr->value = nstrdup(begin, ptr-begin); {
mptr->value = nstrdup(begin, ptr - begin);
mptr++; mptr++;
} else if ( !(state==CS_WAITDELIM || state==CS_WAITKEY) ) }
else if (!(state == CS_WAITDELIM || state == CS_WAITKEY))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unexpected end of line"))); errmsg("unexpected end of line")));
} }
...@@ -102,21 +102,33 @@ typedef struct ...@@ -102,21 +102,33 @@ typedef struct
int cfg_id; int cfg_id;
} QPRS_STATE; } QPRS_STATE;
static char* static char *
get_weight(char *buf, int2 *weight) { get_weight(char *buf, int2 *weight)
{
*weight = 0; *weight = 0;
if ( *buf != ':' ) if (*buf != ':')
return buf; return buf;
buf++; buf++;
while( *buf ) { while (*buf)
switch(tolower(*buf)) { {
case 'a': *weight |= 1<<3; break; switch (tolower(*buf))
case 'b': *weight |= 1<<2; break; {
case 'c': *weight |= 1<<1; break; case 'a':
case 'd': *weight |= 1; break; *weight |= 1 << 3;
default: return buf; break;
case 'b':
*weight |= 1 << 2;
break;
case 'c':
*weight |= 1 << 1;
break;
case 'd':
*weight |= 1;
break;
default:
return buf;
} }
buf++; buf++;
} }
...@@ -146,11 +158,15 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2 ...@@ -146,11 +158,15 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
state->count++; state->count++;
(state->buf)++; (state->buf)++;
return OPEN; return OPEN;
} else if ( *(state->buf) == ':' ) { }
else if (*(state->buf) == ':')
{
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("error at start of operand"))); errmsg("error at start of operand")));
} else if (*(state->buf) != ' ') { }
else if (*(state->buf) != ' ')
{
state->valstate.prsbuf = state->buf; state->valstate.prsbuf = state->buf;
state->state = WAITOPERATOR; state->state = WAITOPERATOR;
if (gettoken_tsvector(&(state->valstate))) if (gettoken_tsvector(&(state->valstate)))
...@@ -266,16 +282,17 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we ...@@ -266,16 +282,17 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we
parsetext_v2(findcfg(state->cfg_id), &prs, strval, lenval); parsetext_v2(findcfg(state->cfg_id), &prs, strval, lenval);
for(count=0;count<prs.curwords;count++) { for (count = 0; count < prs.curwords; count++)
{
pushval_asis(state, VAL, prs.words[count].word, prs.words[count].len, weight); pushval_asis(state, VAL, prs.words[count].word, prs.words[count].len, weight);
pfree( prs.words[count].word ); pfree(prs.words[count].word);
if (count) if (count)
pushquery(state, OPR, (int4) '&', 0, 0, 0 ); pushquery(state, OPR, (int4) '&', 0, 0, 0);
} }
pfree(prs.words); pfree(prs.words);
/* XXX */ /* XXX */
if ( prs.curwords==0 ) if (prs.curwords == 0)
pushval_asis(state, VALTRUE, 0, 0, 0); pushval_asis(state, VALTRUE, 0, 0, 0);
} }
...@@ -381,11 +398,14 @@ ValCompare(CHKVAL * chkval, WordEntry * ptr, ITEM * item) ...@@ -381,11 +398,14 @@ ValCompare(CHKVAL * chkval, WordEntry * ptr, ITEM * item)
* check weight info * check weight info
*/ */
static bool static bool
checkclass_str(CHKVAL * chkval, WordEntry * val, ITEM * item) { checkclass_str(CHKVAL * chkval, WordEntry * val, ITEM * item)
WordEntryPos *ptr = (WordEntryPos*) (chkval->values+val->pos+SHORTALIGN(val->len)+sizeof(uint16)); {
uint16 len = *( (uint16*) (chkval->values+val->pos+SHORTALIGN(val->len)) ); WordEntryPos *ptr = (WordEntryPos *) (chkval->values + val->pos + SHORTALIGN(val->len) + sizeof(uint16));
while (len--) { uint16 len = *((uint16 *) (chkval->values + val->pos + SHORTALIGN(val->len)));
if ( item->weight & ( 1<<ptr->weight ) )
while (len--)
{
if (item->weight & (1 << ptr->weight))
return true; return true;
ptr++; ptr++;
} }
...@@ -410,8 +430,8 @@ checkcondition_str(void *checkval, ITEM * val) ...@@ -410,8 +430,8 @@ checkcondition_str(void *checkval, ITEM * val)
StopMiddle = StopLow + (StopHigh - StopLow) / 2; StopMiddle = StopLow + (StopHigh - StopLow) / 2;
difference = ValCompare((CHKVAL *) checkval, StopMiddle, val); difference = ValCompare((CHKVAL *) checkval, StopMiddle, val);
if (difference == 0) if (difference == 0)
return ( val->weight && StopMiddle->haspos ) ? return (val->weight && StopMiddle->haspos) ?
checkclass_str((CHKVAL *) checkval,StopMiddle, val) : true; checkclass_str((CHKVAL *) checkval, StopMiddle, val) : true;
else if (difference < 0) else if (difference < 0)
StopLow = StopMiddle + 1; StopLow = StopMiddle + 1;
else else
...@@ -534,7 +554,7 @@ findoprnd(ITEM * ptr, int4 *pos) ...@@ -534,7 +554,7 @@ findoprnd(ITEM * ptr, int4 *pos)
* input * input
*/ */
static QUERYTYPE * static QUERYTYPE *
queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int cfg_id) queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int cfg_id)
{ {
QPRS_STATE state; QPRS_STATE state;
int4 i; int4 i;
...@@ -555,7 +575,7 @@ queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int c ...@@ -555,7 +575,7 @@ queryin(char *buf, void (*pushval) (QPRS_STATE *, int, char *, int, int2), int c
state.count = 0; state.count = 0;
state.num = 0; state.num = 0;
state.str = NULL; state.str = NULL;
state.cfg_id=cfg_id; state.cfg_id = cfg_id;
/* init value parser's state */ /* init value parser's state */
state.valstate.oprisdelim = true; state.valstate.oprisdelim = true;
...@@ -678,12 +698,30 @@ infix(INFIX * in, bool first) ...@@ -678,12 +698,30 @@ infix(INFIX * in, bool first)
} }
*(in->cur) = '\''; *(in->cur) = '\'';
in->cur++; in->cur++;
if ( in->curpol->weight ) { if (in->curpol->weight)
*(in->cur) = ':'; in->cur++; {
if ( in->curpol->weight & (1<<3) ) { *(in->cur) = 'A'; in->cur++; } *(in->cur) = ':';
if ( in->curpol->weight & (1<<2) ) { *(in->cur) = 'B'; in->cur++; } in->cur++;
if ( in->curpol->weight & (1<<1) ) { *(in->cur) = 'C'; in->cur++; } if (in->curpol->weight & (1 << 3))
if ( in->curpol->weight & 1 ) { *(in->cur) = 'D'; in->cur++; } {
*(in->cur) = 'A';
in->cur++;
}
if (in->curpol->weight & (1 << 2))
{
*(in->cur) = 'B';
in->cur++;
}
if (in->curpol->weight & (1 << 1))
{
*(in->cur) = 'C';
in->cur++;
}
if (in->curpol->weight & 1)
{
*(in->cur) = 'D';
in->cur++;
}
} }
*(in->cur) = '\0'; *(in->cur) = '\0';
in->curpol++; in->curpol++;
...@@ -827,15 +865,16 @@ tsquerytree(PG_FUNCTION_ARGS) ...@@ -827,15 +865,16 @@ tsquerytree(PG_FUNCTION_ARGS)
} }
Datum Datum
to_tsquery(PG_FUNCTION_ARGS) { to_tsquery(PG_FUNCTION_ARGS)
{
text *in = PG_GETARG_TEXT_P(1); text *in = PG_GETARG_TEXT_P(1);
char *str; char *str;
QUERYTYPE *query; QUERYTYPE *query;
ITEM *res; ITEM *res;
int4 len; int4 len;
str=text2char(in); str = text2char(in);
PG_FREE_IF_COPY(in,1); PG_FREE_IF_COPY(in, 1);
query = queryin(str, pushval_morph, PG_GETARG_INT32(0)); query = queryin(str, pushval_morph, PG_GETARG_INT32(0));
res = clean_fakeval_v2(GETQUERY(query), &len); res = clean_fakeval_v2(GETQUERY(query), &len);
...@@ -851,25 +890,25 @@ to_tsquery(PG_FUNCTION_ARGS) { ...@@ -851,25 +890,25 @@ to_tsquery(PG_FUNCTION_ARGS) {
} }
Datum Datum
to_tsquery_name(PG_FUNCTION_ARGS) { to_tsquery_name(PG_FUNCTION_ARGS)
text *name=PG_GETARG_TEXT_P(0); {
Datum res= DirectFunctionCall2( text *name = PG_GETARG_TEXT_P(0);
Datum res = DirectFunctionCall2(
to_tsquery, to_tsquery,
Int32GetDatum( name2id_cfg(name) ), Int32GetDatum(name2id_cfg(name)),
PG_GETARG_DATUM(1) PG_GETARG_DATUM(1)
); );
PG_FREE_IF_COPY(name,1); PG_FREE_IF_COPY(name, 1);
PG_RETURN_DATUM(res); PG_RETURN_DATUM(res);
} }
Datum Datum
to_tsquery_current(PG_FUNCTION_ARGS) { to_tsquery_current(PG_FUNCTION_ARGS)
PG_RETURN_DATUM( DirectFunctionCall2( {
PG_RETURN_DATUM(DirectFunctionCall2(
to_tsquery, to_tsquery,
Int32GetDatum( get_currcfg() ), Int32GetDatum(get_currcfg()),
PG_GETARG_DATUM(0) PG_GETARG_DATUM(0)
)); ));
} }
This diff is collapsed.
...@@ -11,69 +11,85 @@ ...@@ -11,69 +11,85 @@
#include "common.h" #include "common.h"
static int static int
compareSNMapEntry(const void *a, const void *b) { compareSNMapEntry(const void *a, const void *b)
return strcmp( ((SNMapEntry*)a)->key, ((SNMapEntry*)b)->key ); {
return strcmp(((SNMapEntry *) a)->key, ((SNMapEntry *) b)->key);
} }
void void
addSNMap( SNMap *map, char *key, Oid value ) { addSNMap(SNMap * map, char *key, Oid value)
if (map->len>=map->reallen) { {
if (map->len >= map->reallen)
{
SNMapEntry *tmp; SNMapEntry *tmp;
int len = (map->reallen) ? 2*map->reallen : 16; int len = (map->reallen) ? 2 * map->reallen : 16;
tmp=(SNMapEntry*)realloc(map->list, sizeof(SNMapEntry) * len);
if ( !tmp ) tmp = (SNMapEntry *) realloc(map->list, sizeof(SNMapEntry) * len);
if (!tmp)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
map->reallen=len; map->reallen = len;
map->list=tmp; map->list = tmp;
} }
map->list[ map->len ].key = strdup(key); map->list[map->len].key = strdup(key);
if ( ! map->list[ map->len ].key ) if (!map->list[map->len].key)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY), (errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"))); errmsg("out of memory")));
map->list[ map->len ].value=value; map->list[map->len].value = value;
map->len++; map->len++;
if ( map->len>1 ) qsort(map->list, map->len, sizeof(SNMapEntry), compareSNMapEntry); if (map->len > 1)
qsort(map->list, map->len, sizeof(SNMapEntry), compareSNMapEntry);
} }
void void
addSNMap_t( SNMap *map, text *key, Oid value ) { addSNMap_t(SNMap * map, text *key, Oid value)
char *k=text2char( key ); {
char *k = text2char(key);
addSNMap(map, k, value); addSNMap(map, k, value);
pfree(k); pfree(k);
} }
Oid Oid
findSNMap( SNMap *map, char *key ) { findSNMap(SNMap * map, char *key)
{
SNMapEntry *ptr; SNMapEntry *ptr;
SNMapEntry ks = {key, 0}; SNMapEntry ks = {key, 0};
if ( map->len==0 || !map->list )
if (map->len == 0 || !map->list)
return 0; return 0;
ptr = (SNMapEntry*) bsearch(&ks, map->list, map->len, sizeof(SNMapEntry), compareSNMapEntry); ptr = (SNMapEntry *) bsearch(&ks, map->list, map->len, sizeof(SNMapEntry), compareSNMapEntry);
return (ptr) ? ptr->value : 0; return (ptr) ? ptr->value : 0;
} }
Oid Oid
findSNMap_t( SNMap *map, text *key ) { findSNMap_t(SNMap * map, text *key)
char *k=text2char(key); {
char *k = text2char(key);
int res; int res;
res= findSNMap(map, k);
res = findSNMap(map, k);
pfree(k); pfree(k);
return res; return res;
} }
void freeSNMap( SNMap *map ) { void
SNMapEntry *entry=map->list; freeSNMap(SNMap * map)
if ( map->list ) { {
while( map->len ) { SNMapEntry *entry = map->list;
if ( entry->key ) free(entry->key);
entry++; map->len--; if (map->list)
{
while (map->len)
{
if (entry->key)
free(entry->key);
entry++;
map->len--;
} }
free( map->list ); free(map->list);
} }
memset(map,0,sizeof(SNMap)); memset(map, 0, sizeof(SNMap));
} }
...@@ -3,21 +3,23 @@ ...@@ -3,21 +3,23 @@
#include "postgres.h" #include "postgres.h"
typedef struct { typedef struct
{
char *key; char *key;
Oid value; Oid value;
} SNMapEntry; } SNMapEntry;
typedef struct { typedef struct
{
int len; int len;
int reallen; int reallen;
SNMapEntry *list; SNMapEntry *list;
} SNMap; } SNMap;
void addSNMap( SNMap *map, char *key, Oid value ); void addSNMap(SNMap * map, char *key, Oid value);
void addSNMap_t( SNMap *map, text *key, Oid value ); void addSNMap_t(SNMap * map, text *key, Oid value);
Oid findSNMap( SNMap *map, char *key ); Oid findSNMap(SNMap * map, char *key);
Oid findSNMap_t( SNMap *map, text *key ); Oid findSNMap_t(SNMap * map, text *key);
void freeSNMap( SNMap *map ); void freeSNMap(SNMap * map);
#endif #endif
This diff is collapsed.
...@@ -11,17 +11,24 @@ typedef unsigned char symbol; ...@@ -11,17 +11,24 @@ typedef unsigned char symbol;
*/ */
struct SN_env { struct SN_env
symbol * p; {
int c; int a; int l; int lb; int bra; int ket; symbol *p;
int S_size; int I_size; int B_size; int c;
symbol * * S; int a;
int * I; int l;
symbol * B; int lb;
int bra;
int ket;
int S_size;
int I_size;
int B_size;
symbol **S;
int *I;
symbol *B;
}; };
extern struct SN_env * SN_create_env(int S_size, int I_size, int B_size); extern struct SN_env *SN_create_env(int S_size, int I_size, int B_size);
extern void SN_close_env(struct SN_env * z); extern void SN_close_env(struct SN_env * z);
extern void SN_set_current(struct SN_env * z, int size, const symbol * s); extern void SN_set_current(struct SN_env * z, int size, const symbol * s);
This diff is collapsed.
/* This file was generated automatically by the Snowball to ANSI C compiler */ /* This file was generated automatically by the Snowball to ANSI C compiler */
extern struct SN_env * english_create_env(void); extern struct SN_env *english_create_env(void);
extern void english_close_env(struct SN_env * z); extern void english_close_env(struct SN_env * z);
extern int english_stem(struct SN_env * z); extern int english_stem(struct SN_env * z);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment