Commit 9e155260 authored by Bruce Momjian's avatar Bruce Momjian

pgindent run. Make it all clean.

parent 6cf8707b
...@@ -4,76 +4,81 @@ ...@@ -4,76 +4,81 @@
#include "utils/elog.h" #include "utils/elog.h"
static char * PARSE_BUFFER; static char *PARSE_BUFFER;
static char * PARSE_BUFFER_PTR; static char *PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE; static unsigned int PARSE_BUFFER_SIZE;
static unsigned int SCANNER_POS; static unsigned int SCANNER_POS;
void set_parse_buffer( char* s ); void set_parse_buffer(char *s);
void reset_parse_buffer( void ); void reset_parse_buffer(void);
int read_parse_buffer( void ); int read_parse_buffer(void);
char * parse_buffer( void ); char *parse_buffer(void);
char * parse_buffer_ptr( void ); char *parse_buffer_ptr(void);
unsigned int parse_buffer_curr_char( void ); unsigned int parse_buffer_curr_char(void);
unsigned int parse_buffer_size( void ); unsigned int parse_buffer_size(void);
unsigned int parse_buffer_pos( void ); unsigned int parse_buffer_pos(void);
extern void cube_flush_scanner_buffer(void); /* defined in cubescan.l */ extern void cube_flush_scanner_buffer(void); /* defined in cubescan.l */
void set_parse_buffer( char* s ) void
set_parse_buffer(char *s)
{ {
PARSE_BUFFER = s; PARSE_BUFFER = s;
PARSE_BUFFER_SIZE = strlen(s); PARSE_BUFFER_SIZE = strlen(s);
if ( PARSE_BUFFER_SIZE == 0 ) { if (PARSE_BUFFER_SIZE == 0)
elog(ERROR, "cube_in: can't parse an empty string"); elog(ERROR, "cube_in: can't parse an empty string");
}
PARSE_BUFFER_PTR = PARSE_BUFFER; PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0; SCANNER_POS = 0;
} }
void reset_parse_buffer( void ) void
reset_parse_buffer(void)
{ {
PARSE_BUFFER_PTR = PARSE_BUFFER; PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0; SCANNER_POS = 0;
cube_flush_scanner_buffer(); cube_flush_scanner_buffer();
} }
int read_parse_buffer( void ) int
read_parse_buffer(void)
{ {
int c; int c;
/* /*
c = *PARSE_BUFFER_PTR++; * c = *PARSE_BUFFER_PTR++; SCANNER_POS++;
SCANNER_POS++;
*/ */
c = PARSE_BUFFER[SCANNER_POS]; c = PARSE_BUFFER[SCANNER_POS];
if(SCANNER_POS < PARSE_BUFFER_SIZE) if (SCANNER_POS < PARSE_BUFFER_SIZE)
SCANNER_POS++; SCANNER_POS++;
return c; return c;
} }
char * parse_buffer( void ) char *
parse_buffer(void)
{ {
return PARSE_BUFFER; return PARSE_BUFFER;
} }
unsigned int parse_buffer_curr_char( void ) unsigned int
parse_buffer_curr_char(void)
{ {
return PARSE_BUFFER[SCANNER_POS]; return PARSE_BUFFER[SCANNER_POS];
} }
char * parse_buffer_ptr( void ) char *
parse_buffer_ptr(void)
{ {
return PARSE_BUFFER_PTR; return PARSE_BUFFER_PTR;
} }
unsigned int parse_buffer_pos( void ) unsigned int
parse_buffer_pos(void)
{ {
return SCANNER_POS; return SCANNER_POS;
} }
unsigned int parse_buffer_size( void ) unsigned int
parse_buffer_size(void)
{ {
return PARSE_BUFFER_SIZE; return PARSE_BUFFER_SIZE;
} }
extern void set_parse_buffer( char* s ); extern void set_parse_buffer(char *s);
extern void reset_parse_buffer( void ); extern void reset_parse_buffer(void);
extern int read_parse_buffer( void ); extern int read_parse_buffer(void);
extern char * parse_buffer( void ); extern char *parse_buffer(void);
extern char * parse_buffer_ptr( void ); extern char *parse_buffer_ptr(void);
extern unsigned int parse_buffer_curr_char( void ); extern unsigned int parse_buffer_curr_char(void);
extern unsigned int parse_buffer_pos( void ); extern unsigned int parse_buffer_pos(void);
extern unsigned int parse_buffer_size( void ); extern unsigned int parse_buffer_size(void);
This diff is collapsed.
typedef struct NDBOX { typedef struct NDBOX
{
unsigned int size; /* required to be a Postgres varlena type */ unsigned int size; /* required to be a Postgres varlena type */
unsigned int dim; unsigned int dim;
float x[1]; float x[1];
......
/* /*
* PostgreSQL type definitions for managed LargeObjects. * PostgreSQL type definitions for managed LargeObjects.
* *
* $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.7 2001/02/10 02:31:25 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/lo/lo.c,v 1.8 2001/03/22 03:59:09 momjian Exp $
* *
*/ */
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
#include "libpq-fe.h" #include "libpq-fe.h"
/* these are the opts structures for command line params */ /* these are the opts structures for command line params */
struct options { struct options
{
int getdatabase; int getdatabase;
int gettable; int gettable;
int getoid; int getoid;
...@@ -38,7 +39,7 @@ struct options { ...@@ -38,7 +39,7 @@ struct options {
/* function prototypes */ /* function prototypes */
void get_opts(int, char **, struct options *); void get_opts(int, char **, struct options *);
PGconn *sql_conn(char *, struct options *); PGconn *sql_conn(char *, struct options *);
void sql_exec_error (int); void sql_exec_error(int);
int sql_exec(PGconn *, char *, int); int sql_exec(PGconn *, char *, int);
void sql_exec_dumpdb(PGconn *); void sql_exec_dumpdb(PGconn *);
void sql_exec_dumptable(PGconn *, int); void sql_exec_dumptable(PGconn *, int);
...@@ -46,7 +47,8 @@ void sql_exec_searchtable(PGconn *, char *); ...@@ -46,7 +47,8 @@ void sql_exec_searchtable(PGconn *, char *);
void sql_exec_searchoid(PGconn *, int); void sql_exec_searchoid(PGconn *, int);
/* fuction to parse command line options and check for some usage errors. */ /* fuction to parse command line options and check for some usage errors. */
void get_opts(int argc, char **argv, struct options *my_opts) void
get_opts(int argc, char **argv, struct options * my_opts)
{ {
char c; char c;
...@@ -63,9 +65,9 @@ void get_opts(int argc, char **argv, struct options *my_opts) ...@@ -63,9 +65,9 @@ void get_opts(int argc, char **argv, struct options *my_opts)
my_opts->remotepass = 0; my_opts->remotepass = 0;
/* get opts */ /* get opts */
while( (c = getopt(argc, argv, "H:p:U:P:d:t:o:xh?")) != EOF) while ((c = getopt(argc, argv, "H:p:U:P:d:t:o:xh?")) != EOF)
{ {
switch(c) switch (c)
{ {
/* specify the database */ /* specify the database */
case 'd': case 'd':
...@@ -76,13 +78,13 @@ void get_opts(int argc, char **argv, struct options *my_opts) ...@@ -76,13 +78,13 @@ void get_opts(int argc, char **argv, struct options *my_opts)
/* specify the table name */ /* specify the table name */
case 't': case 't':
/* make sure we set the database first */ /* make sure we set the database first */
if(!my_opts->getdatabase) if (!my_opts->getdatabase)
{ {
fprintf(stderr, "Sorry, but you must specify a database to dump from.\n"); fprintf(stderr, "Sorry, but you must specify a database to dump from.\n");
exit(1); exit(1);
} }
/* make sure we don't try to do a -o also */ /* make sure we don't try to do a -o also */
if(my_opts->getoid) if (my_opts->getoid)
{ {
fprintf(stderr, "Sorry, you can only specify either oid or table\n"); fprintf(stderr, "Sorry, you can only specify either oid or table\n");
exit(1); exit(1);
...@@ -96,13 +98,13 @@ void get_opts(int argc, char **argv, struct options *my_opts) ...@@ -96,13 +98,13 @@ void get_opts(int argc, char **argv, struct options *my_opts)
/* specify the oid int */ /* specify the oid int */
case 'o': case 'o':
/* make sure we set the database first */ /* make sure we set the database first */
if(!my_opts->getdatabase) if (!my_opts->getdatabase)
{ {
fprintf(stderr, "Sorry, but you must specify a database to dump from.\n"); fprintf(stderr, "Sorry, but you must specify a database to dump from.\n");
exit(1); exit(1);
} }
/* make sure we don't try to do a -t also */ /* make sure we don't try to do a -t also */
if(my_opts->gettable) if (my_opts->gettable)
{ {
fprintf(stderr, "Sorry, you can only specify either oid or table\n"); fprintf(stderr, "Sorry, you can only specify either oid or table\n");
exit(1); exit(1);
...@@ -148,11 +150,11 @@ void get_opts(int argc, char **argv, struct options *my_opts) ...@@ -148,11 +150,11 @@ void get_opts(int argc, char **argv, struct options *my_opts)
case 'h': case 'h':
fprintf(stderr, "\n\ fprintf(stderr, "\n\
Usage: pg_oid2name [-d database [-x] ] [-t table | -o oid] \n\ Usage: pg_oid2name [-d database [-x] ] [-t table | -o oid] \n\
dafault action display all databases dafault action display all databases\n\
-d database database to oid2name\n\ -d database database to oid2name\n\
-x display system tables\n\ -x display system tables\n\
-t table | -o oid search for table name (-t) or\n\ -t table | -o oid search for table name (-t) or\n\
oid (-o) in -d database oid (-o) in -d database\n\
-H host connect to remote host\n\ -H host connect to remote host\n\
-p port host port to connect to\n\ -p port host port to connect to\n\
-U username username to connect with\n\ -U username username to connect with\n\
...@@ -165,11 +167,15 @@ Usage: pg_oid2name [-d database [-x] ] [-t table | -o oid] \n\ ...@@ -165,11 +167,15 @@ Usage: pg_oid2name [-d database [-x] ] [-t table | -o oid] \n\
} }
/* establish connection with database. */ /* establish connection with database. */
PGconn *sql_conn(char *dbName, struct options *my_opts) PGconn *
sql_conn(char *dbName, struct options * my_opts)
{ {
char *pghost, *pgport; char *pghost,
char *pgoptions, *pgtty; *pgport;
char *pguser, *pgpass; char *pgoptions,
*pgtty;
char *pguser,
*pgpass;
PGconn *conn; PGconn *conn;
...@@ -184,27 +190,27 @@ PGconn *sql_conn(char *dbName, struct options *my_opts) ...@@ -184,27 +190,27 @@ PGconn *sql_conn(char *dbName, struct options *my_opts)
pgpass = NULL; pgpass = NULL;
/* override the NULLs with the user params if passed */ /* override the NULLs with the user params if passed */
if(my_opts->remotehost) if (my_opts->remotehost)
{ {
pghost = (char *) malloc (128); pghost = (char *) malloc(128);
sscanf(my_opts->_hostname, "%s", pghost); sscanf(my_opts->_hostname, "%s", pghost);
} }
if(my_opts->remoteport) if (my_opts->remoteport)
{ {
pgport = (char *) malloc (6); pgport = (char *) malloc(6);
sscanf(my_opts->_port, "%s", pgport); sscanf(my_opts->_port, "%s", pgport);
} }
if(my_opts->remoteuser) if (my_opts->remoteuser)
{ {
pguser = (char *) malloc (128); pguser = (char *) malloc(128);
sscanf(my_opts->_username, "%s", pguser); sscanf(my_opts->_username, "%s", pguser);
} }
if(my_opts->remotepass) if (my_opts->remotepass)
{ {
pgpass = (char *) malloc (128); pgpass = (char *) malloc(128);
sscanf(my_opts->_password, "%s", pgpass); sscanf(my_opts->_password, "%s", pgpass);
} }
...@@ -228,10 +234,11 @@ PGconn *sql_conn(char *dbName, struct options *my_opts) ...@@ -228,10 +234,11 @@ PGconn *sql_conn(char *dbName, struct options *my_opts)
} }
/* If the sql_ command has an error, this function looks up the error number and prints it out. */ /* If the sql_ command has an error, this function looks up the error number and prints it out. */
void sql_exec_error (int error_number) void
sql_exec_error(int error_number)
{ {
fprintf(stderr, "Error number %i.\n", error_number); fprintf(stderr, "Error number %i.\n", error_number);
switch(error_number) switch (error_number)
{ {
case 3: case 3:
fprintf(stderr, "Error: PGRES_COPY_OUT\n"); fprintf(stderr, "Error: PGRES_COPY_OUT\n");
...@@ -256,13 +263,15 @@ void sql_exec_error (int error_number) ...@@ -256,13 +263,15 @@ void sql_exec_error (int error_number)
} }
/* actual code to make call to the database and print the output data */ /* actual code to make call to the database and print the output data */
int sql_exec(PGconn *conn, char *todo, int match) int
sql_exec(PGconn *conn, char *todo, int match)
{ {
PGresult *res; PGresult *res;
int numbfields; int numbfields;
int error_number; int error_number;
int i, len; int i,
len;
/* make the call */ /* make the call */
res = PQexec(conn, todo); res = PQexec(conn, todo);
...@@ -284,15 +293,15 @@ int sql_exec(PGconn *conn, char *todo, int match) ...@@ -284,15 +293,15 @@ int sql_exec(PGconn *conn, char *todo, int match)
numbfields = PQntuples(res); numbfields = PQntuples(res);
/* if we only expect 1 and there mode than, return -2 */ /* if we only expect 1 and there mode than, return -2 */
if(match == 1 && numbfields > 1) if (match == 1 && numbfields > 1)
return -2; return -2;
/* return -1 if there aren't any returns */ /* return -1 if there aren't any returns */
if(match == 1 && numbfields < 1) if (match == 1 && numbfields < 1)
return -1; return -1;
/* for each row, dump the information */ /* for each row, dump the information */
for(i = 0; i < numbfields; i++) for (i = 0; i < numbfields; i++)
{ {
len = strlen(PQgetvalue(res, i, 0)); len = strlen(PQgetvalue(res, i, 0));
...@@ -306,11 +315,12 @@ int sql_exec(PGconn *conn, char *todo, int match) ...@@ -306,11 +315,12 @@ int sql_exec(PGconn *conn, char *todo, int match)
} }
/* dump all databases know by the system table */ /* dump all databases know by the system table */
void sql_exec_dumpdb(PGconn *conn) void
sql_exec_dumpdb(PGconn *conn)
{ {
char *todo; char *todo;
todo = (char *) malloc (1024); todo = (char *) malloc(1024);
/* get the oid and database name from the system pg_database table */ /* get the oid and database name from the system pg_database table */
sprintf(todo, "select oid,datname from pg_database"); sprintf(todo, "select oid,datname from pg_database");
...@@ -320,14 +330,15 @@ void sql_exec_dumpdb(PGconn *conn) ...@@ -320,14 +330,15 @@ void sql_exec_dumpdb(PGconn *conn)
/* display all tables in whatever db we are connected to. don't display the /* display all tables in whatever db we are connected to. don't display the
system tables by default */ system tables by default */
void sql_exec_dumptable(PGconn *conn, int systables) void
sql_exec_dumptable(PGconn *conn, int systables)
{ {
char *todo; char *todo;
todo = (char *) malloc (1024); todo = (char *) malloc(1024);
/* don't exclude the systables if this is set */ /* don't exclude the systables if this is set */
if(systables == 1) if (systables == 1)
sprintf(todo, "select relfilenode,relname from pg_class order by relname"); sprintf(todo, "select relfilenode,relname from pg_class order by relname");
else else
sprintf(todo, "select relfilenode,relname from pg_class where relname not like 'pg_%%' order by relname"); sprintf(todo, "select relfilenode,relname from pg_class where relname not like 'pg_%%' order by relname");
...@@ -337,12 +348,13 @@ void sql_exec_dumptable(PGconn *conn, int systables) ...@@ -337,12 +348,13 @@ void sql_exec_dumptable(PGconn *conn, int systables)
/* display the oid for a given tablename for whatever db we are connected /* display the oid for a given tablename for whatever db we are connected
to. do we want to allow %bar% in the search? Not now. */ to. do we want to allow %bar% in the search? Not now. */
void sql_exec_searchtable(PGconn *conn, char *tablename) void
sql_exec_searchtable(PGconn *conn, char *tablename)
{ {
int returnvalue; int returnvalue;
char *todo; char *todo;
todo = (char *) malloc (1024); todo = (char *) malloc(1024);
/* get the oid and tablename where the name matches tablename */ /* get the oid and tablename where the name matches tablename */
sprintf(todo, "select relfilenode,relname from pg_class where relname = '%s'", tablename); sprintf(todo, "select relfilenode,relname from pg_class where relname = '%s'", tablename);
...@@ -350,52 +362,46 @@ void sql_exec_searchtable(PGconn *conn, char *tablename) ...@@ -350,52 +362,46 @@ void sql_exec_searchtable(PGconn *conn, char *tablename)
returnvalue = sql_exec(conn, todo, 1); returnvalue = sql_exec(conn, todo, 1);
/* deal with the return errors */ /* deal with the return errors */
if(returnvalue == -1) if (returnvalue == -1)
{
printf("No tables with that name found\n"); printf("No tables with that name found\n");
}
if(returnvalue == -2) if (returnvalue == -2)
{
printf("VERY scary: more than one table with that name found!!\n"); printf("VERY scary: more than one table with that name found!!\n");
}
} }
/* same as above */ /* same as above */
void sql_exec_searchoid(PGconn *conn, int oid) void
sql_exec_searchoid(PGconn *conn, int oid)
{ {
int returnvalue; int returnvalue;
char *todo; char *todo;
todo = (char *) malloc (1024); todo = (char *) malloc(1024);
sprintf(todo, "select relfilenode,relname from pg_class where oid = %i", oid); sprintf(todo, "select relfilenode,relname from pg_class where oid = %i", oid);
returnvalue = sql_exec(conn, todo, 1); returnvalue = sql_exec(conn, todo, 1);
if(returnvalue == -1) if (returnvalue == -1)
{
printf("No tables with that oid found\n"); printf("No tables with that oid found\n");
}
if(returnvalue == -2) if (returnvalue == -2)
{
printf("VERY scary: more than one table with that oid found!!\n"); printf("VERY scary: more than one table with that oid found!!\n");
}
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
struct options *my_opts; struct options *my_opts;
PGconn *pgconn; PGconn *pgconn;
my_opts = (struct options *) malloc (sizeof(struct options)); my_opts = (struct options *) malloc(sizeof(struct options));
/* parse the opts */ /* parse the opts */
get_opts(argc, argv, my_opts); get_opts(argc, argv, my_opts);
/* display all the tables in the database */ /* display all the tables in the database */
if(my_opts->getdatabase & my_opts->gettable) if (my_opts->getdatabase & my_opts->gettable)
{ {
printf("Oid of table %s from database \"%s\":\n", my_opts->_tbname, my_opts->_dbname); printf("Oid of table %s from database \"%s\":\n", my_opts->_tbname, my_opts->_dbname);
printf("_______________________________\n"); printf("_______________________________\n");
...@@ -408,7 +414,7 @@ int main(int argc, char **argv) ...@@ -408,7 +414,7 @@ int main(int argc, char **argv)
} }
/* search for the tablename of the given OID */ /* search for the tablename of the given OID */
if(my_opts->getdatabase & my_opts->getoid) if (my_opts->getdatabase & my_opts->getoid)
{ {
printf("Tablename of oid %i from database \"%s\":\n", my_opts->_oid, my_opts->_dbname); printf("Tablename of oid %i from database \"%s\":\n", my_opts->_oid, my_opts->_dbname);
printf("---------------------------------\n"); printf("---------------------------------\n");
...@@ -421,7 +427,7 @@ int main(int argc, char **argv) ...@@ -421,7 +427,7 @@ int main(int argc, char **argv)
} }
/* search for the oid for the given tablename */ /* search for the oid for the given tablename */
if(my_opts->getdatabase) if (my_opts->getdatabase)
{ {
printf("All tables from database \"%s\":\n", my_opts->_dbname); printf("All tables from database \"%s\":\n", my_opts->_dbname);
printf("---------------------------------\n"); printf("---------------------------------\n");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001; * copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD * licence: BSD
* *
* $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/pg_controldata.c,v 1.2 2001/03/13 01:17:40 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/pg_controldata/Attic/pg_controldata.c,v 1.3 2001/03/22 03:59:09 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -51,8 +51,9 @@ main() ...@@ -51,8 +51,9 @@ main()
char ckpttime_str[32]; char ckpttime_str[32];
DataDir = getenv("PGDATA"); DataDir = getenv("PGDATA");
if ( DataDir == NULL ) { if (DataDir == NULL)
fprintf(stderr,"PGDATA is not defined\n"); {
fprintf(stderr, "PGDATA is not defined\n");
exit(1); exit(1);
} }
...@@ -74,7 +75,7 @@ main() ...@@ -74,7 +75,7 @@ main()
/* Check the CRC. */ /* Check the CRC. */
INIT_CRC64(crc); INIT_CRC64(crc);
COMP_CRC64(crc, COMP_CRC64(crc,
(char*) &ControlFile + sizeof(crc64), (char *) &ControlFile + sizeof(crc64),
sizeof(ControlFileData) - sizeof(crc64)); sizeof(ControlFileData) - sizeof(crc64));
FIN_CRC64(crc); FIN_CRC64(crc);
......
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* pg_dumplo * pg_dumplo
* *
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_export.c,v 1.5 2001/01/24 19:42:44 momjian Exp $ * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_export.c,v 1.6 2001/03/22 03:59:10 momjian Exp $
* *
* Karel Zak 1999-2000 * Karel Zak 1999-2000
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
...@@ -26,7 +26,7 @@ extern int errno; ...@@ -26,7 +26,7 @@ extern int errno;
void void
load_lolist( LODumpMaster *pgLO ) load_lolist(LODumpMaster * pgLO)
{ {
LOlist *ll; LOlist *ll;
int i; int i;
...@@ -52,25 +52,29 @@ load_lolist( LODumpMaster *pgLO ) ...@@ -52,25 +52,29 @@ load_lolist( LODumpMaster *pgLO )
" AND c.relkind = 'r' " " AND c.relkind = 'r' "
" AND c.relname NOT LIKE 'pg_%'"); " AND c.relname NOT LIKE 'pg_%'");
if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK) { if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK)
{
fprintf(stderr, "%s: Failed to get LO OIDs:\n%s", progname, fprintf(stderr, "%s: Failed to get LO OIDs:\n%s", progname,
PQerrorMessage(pgLO->conn)); PQerrorMessage(pgLO->conn));
exit(RE_ERROR); exit(RE_ERROR);
} }
if ((n = PQntuples(pgLO->res)) == 0) { if ((n = PQntuples(pgLO->res)) == 0)
{
fprintf(stderr, "%s: No OID columns in the database.\n", progname); fprintf(stderr, "%s: No OID columns in the database.\n", progname);
exit(RE_ERROR); exit(RE_ERROR);
} }
pgLO->lolist = (LOlist *) malloc((n + 1) * sizeof(LOlist)); pgLO->lolist = (LOlist *) malloc((n + 1) * sizeof(LOlist));
if (!pgLO->lolist) { if (!pgLO->lolist)
{
fprintf(stderr, "%s: can't allocate memory\n", progname); fprintf(stderr, "%s: can't allocate memory\n", progname);
exit(RE_ERROR); exit(RE_ERROR);
} }
for (i = 0, ll = pgLO->lolist; i < n; i++, ll++) { for (i = 0, ll = pgLO->lolist; i < n; i++, ll++)
{
ll->lo_table = strdup(PQgetvalue(pgLO->res, i, 0)); ll->lo_table = strdup(PQgetvalue(pgLO->res, i, 0));
ll->lo_attr = strdup(PQgetvalue(pgLO->res, i, 1)); ll->lo_attr = strdup(PQgetvalue(pgLO->res, i, 1));
} }
...@@ -80,15 +84,17 @@ load_lolist( LODumpMaster *pgLO ) ...@@ -80,15 +84,17 @@ load_lolist( LODumpMaster *pgLO )
} }
void void
pglo_export(LODumpMaster *pgLO) pglo_export(LODumpMaster * pgLO)
{ {
LOlist *ll; LOlist *ll;
int tuples; int tuples;
char path[BUFSIZ], char path[BUFSIZ],
Qbuff[QUERY_BUFSIZ]; Qbuff[QUERY_BUFSIZ];
if (pgLO->action != ACTION_SHOW) { if (pgLO->action != ACTION_SHOW)
{
time_t t; time_t t;
time(&t); time(&t);
fprintf(pgLO->index, "#\n# This is the PostgreSQL large object dump index\n#\n"); fprintf(pgLO->index, "#\n# This is the PostgreSQL large object dump index\n#\n");
fprintf(pgLO->index, "#\tDate: %s", ctime(&t)); fprintf(pgLO->index, "#\tDate: %s", ctime(&t));
...@@ -100,7 +106,8 @@ pglo_export(LODumpMaster *pgLO) ...@@ -100,7 +106,8 @@ pglo_export(LODumpMaster *pgLO)
pgLO->counter = 0; pgLO->counter = 0;
for(ll=pgLO->lolist; ll->lo_table != NULL; ll++) { for (ll = pgLO->lolist; ll->lo_table != NULL; ll++)
{
/* ---------- /* ----------
* Query: find the LOs referenced by this column * Query: find the LOs referenced by this column
...@@ -113,15 +120,19 @@ pglo_export(LODumpMaster *pgLO) ...@@ -113,15 +120,19 @@ pglo_export(LODumpMaster *pgLO)
pgLO->res = PQexec(pgLO->conn, Qbuff); pgLO->res = PQexec(pgLO->conn, Qbuff);
if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK) { if (PQresultStatus(pgLO->res) != PGRES_TUPLES_OK)
{
fprintf(stderr, "%s: Failed to get LO OIDs:\n%s", progname, fprintf(stderr, "%s: Failed to get LO OIDs:\n%s", progname,
PQerrorMessage(pgLO->conn)); PQerrorMessage(pgLO->conn));
} }
else if ((tuples = PQntuples(pgLO->res)) == 0) { else if ((tuples = PQntuples(pgLO->res)) == 0)
{
if (!pgLO->quiet && pgLO->action == ACTION_EXPORT_ATTR) if (!pgLO->quiet && pgLO->action == ACTION_EXPORT_ATTR)
printf("%s: no large objects in \"%s\".\"%s\"\n", printf("%s: no large objects in \"%s\".\"%s\"\n",
progname, ll->lo_table, ll->lo_attr); progname, ll->lo_table, ll->lo_attr);
} else { }
else
{
int t; int t;
char *val; char *val;
...@@ -130,13 +141,16 @@ pglo_export(LODumpMaster *pgLO) ...@@ -130,13 +141,16 @@ pglo_export(LODumpMaster *pgLO)
* Create DIR/FILE * Create DIR/FILE
* ---------- * ----------
*/ */
if (pgLO->action != ACTION_SHOW) { if (pgLO->action != ACTION_SHOW)
{
sprintf(path, "%s/%s/%s", pgLO->space, pgLO->db, sprintf(path, "%s/%s/%s", pgLO->space, pgLO->db,
ll->lo_table); ll->lo_table);
if (mkdir(path, DIR_UMASK) == -1) { if (mkdir(path, DIR_UMASK) == -1)
if (errno != EEXIST) { {
if (errno != EEXIST)
{
perror(path); perror(path);
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -145,8 +159,10 @@ pglo_export(LODumpMaster *pgLO) ...@@ -145,8 +159,10 @@ pglo_export(LODumpMaster *pgLO)
sprintf(path, "%s/%s/%s/%s", pgLO->space, pgLO->db, sprintf(path, "%s/%s/%s/%s", pgLO->space, pgLO->db,
ll->lo_table, ll->lo_attr); ll->lo_table, ll->lo_attr);
if (mkdir(path, DIR_UMASK) == -1) { if (mkdir(path, DIR_UMASK) == -1)
if (errno != EEXIST) { {
if (errno != EEXIST)
{
perror(path); perror(path);
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -159,14 +175,16 @@ pglo_export(LODumpMaster *pgLO) ...@@ -159,14 +175,16 @@ pglo_export(LODumpMaster *pgLO)
pgLO->counter += tuples; pgLO->counter += tuples;
for(t=0; t<tuples; t++) { for (t = 0; t < tuples; t++)
{
Oid lo; Oid lo;
val = PQgetvalue(pgLO->res, t, 0); val = PQgetvalue(pgLO->res, t, 0);
lo = atooid(val); lo = atooid(val);
if (pgLO->action == ACTION_SHOW) { if (pgLO->action == ACTION_SHOW)
{
printf("%s.%s: %u\n", ll->lo_table, ll->lo_attr, lo); printf("%s.%s: %u\n", ll->lo_table, ll->lo_attr, lo);
continue; continue;
} }
......
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* pg_dumplo * pg_dumplo
* *
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_import.c,v 1.3 2001/01/24 19:42:45 momjian Exp $ * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/lo_import.c,v 1.4 2001/03/22 03:59:10 momjian Exp $
* *
* Karel Zak 1999-2000 * Karel Zak 1999-2000
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
...@@ -25,20 +25,23 @@ ...@@ -25,20 +25,23 @@
extern int errno; extern int errno;
void void
pglo_import(LODumpMaster *pgLO) pglo_import(LODumpMaster * pgLO)
{ {
LOlist loa; LOlist loa;
Oid new_oid; Oid new_oid;
char tab[MAX_TABLE_NAME], attr[MAX_ATTR_NAME], char tab[MAX_TABLE_NAME],
path[BUFSIZ], lo_path[BUFSIZ], attr[MAX_ATTR_NAME],
path[BUFSIZ],
lo_path[BUFSIZ],
Qbuff[QUERY_BUFSIZ]; Qbuff[QUERY_BUFSIZ];
while(fgets(Qbuff, QUERY_BUFSIZ, pgLO->index)) { while (fgets(Qbuff, QUERY_BUFSIZ, pgLO->index))
{
if (*Qbuff == '#') if (*Qbuff == '#')
continue; continue;
if (! pgLO->remove && ! pgLO->quiet) if (!pgLO->remove && !pgLO->quiet)
printf(Qbuff); printf(Qbuff);
sscanf(Qbuff, "%u\t%s\t%s\t%s\n", &loa.lo_oid, tab, attr, path); sscanf(Qbuff, "%u\t%s\t%s\t%s\n", &loa.lo_oid, tab, attr, path);
...@@ -51,7 +54,8 @@ pglo_import(LODumpMaster *pgLO) ...@@ -51,7 +54,8 @@ pglo_import(LODumpMaster *pgLO)
* Import LO * Import LO
* ---------- * ----------
*/ */
if ((new_oid = lo_import(pgLO->conn, lo_path)) == 0) { if ((new_oid = lo_import(pgLO->conn, lo_path)) == 0)
{
fprintf(stderr, "%s: %s\n", progname, PQerrorMessage(pgLO->conn)); fprintf(stderr, "%s: %s\n", progname, PQerrorMessage(pgLO->conn));
...@@ -60,7 +64,8 @@ pglo_import(LODumpMaster *pgLO) ...@@ -60,7 +64,8 @@ pglo_import(LODumpMaster *pgLO)
exit(RE_ERROR); exit(RE_ERROR);
} }
if (pgLO->remove) { if (pgLO->remove)
{
notice(pgLO, FALSE); notice(pgLO, FALSE);
if (lo_unlink(pgLO->conn, loa.lo_oid) < 0) if (lo_unlink(pgLO->conn, loa.lo_oid) < 0)
fprintf(stderr, "%s: can't remove LO %u:\n%s", fprintf(stderr, "%s: can't remove LO %u:\n%s",
...@@ -81,12 +86,13 @@ pglo_import(LODumpMaster *pgLO) ...@@ -81,12 +86,13 @@ pglo_import(LODumpMaster *pgLO)
sprintf(Qbuff, "UPDATE \"%s\" SET \"%s\"=%u WHERE \"%s\"=%u", sprintf(Qbuff, "UPDATE \"%s\" SET \"%s\"=%u WHERE \"%s\"=%u",
loa.lo_table, loa.lo_attr, new_oid, loa.lo_attr, loa.lo_oid); loa.lo_table, loa.lo_attr, new_oid, loa.lo_attr, loa.lo_oid);
/*fprintf(stderr, Qbuff);*/ /* fprintf(stderr, Qbuff); */
pgLO->res = PQexec(pgLO->conn, Qbuff); pgLO->res = PQexec(pgLO->conn, Qbuff);
if (PQresultStatus(pgLO->res) != PGRES_COMMAND_OK) { if (PQresultStatus(pgLO->res) != PGRES_COMMAND_OK)
fprintf(stderr, "%s: %s\n",progname, PQerrorMessage(pgLO->conn)); {
fprintf(stderr, "%s: %s\n", progname, PQerrorMessage(pgLO->conn));
PQclear(pgLO->res); PQclear(pgLO->res);
PQexec(pgLO->conn, "ROLLBACK"); PQexec(pgLO->conn, "ROLLBACK");
fprintf(stderr, "\n%s: ROLLBACK\n", progname); fprintf(stderr, "\n%s: ROLLBACK\n", progname);
...@@ -94,4 +100,4 @@ pglo_import(LODumpMaster *pgLO) ...@@ -94,4 +100,4 @@ pglo_import(LODumpMaster *pgLO)
} }
PQclear(pgLO->res); PQclear(pgLO->res);
} }
} }
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* pg_dumplo * pg_dumplo
* *
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.6 2001/02/10 02:31:25 tgl Exp $ * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/main.c,v 1.7 2001/03/22 03:59:10 momjian Exp $
* *
* Karel Zak 1999-2000 * Karel Zak 1999-2000
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
#include "pg_dumplo.h" #include "pg_dumplo.h"
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
#include <getopt.h> #include <getopt.h>
#define no_argument 0 #define no_argument 0
#define required_argument 1 #define required_argument 1
#endif #endif
extern int errno; extern int errno;
...@@ -35,7 +35,7 @@ char *progname = NULL; ...@@ -35,7 +35,7 @@ char *progname = NULL;
int main(int argc, char **argv); int main(int argc, char **argv);
static void usage(void); static void usage(void);
static void parse_lolist (LODumpMaster *pgLO); static void parse_lolist(LODumpMaster * pgLO);
/*----- /*-----
...@@ -45,7 +45,8 @@ static void parse_lolist (LODumpMaster *pgLO); ...@@ -45,7 +45,8 @@ static void parse_lolist (LODumpMaster *pgLO);
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
LODumpMaster _pgLO, *pgLO = &_pgLO; LODumpMaster _pgLO,
*pgLO = &_pgLO;
char *pwd = NULL; char *pwd = NULL;
pgLO->argv = argv; pgLO->argv = argv;
...@@ -68,33 +69,37 @@ main(int argc, char **argv) ...@@ -68,33 +69,37 @@ main(int argc, char **argv)
* Parse ARGV * Parse ARGV
* ---------- * ----------
*/ */
if (argc > 1) { if (argc > 1)
{
int arg; int arg;
extern int optind; extern int optind;
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
int l_index=0; int l_index = 0;
static struct option l_opt[] = { static struct option l_opt[] = {
{ "help", no_argument, 0, 'h' }, {"help", no_argument, 0, 'h'},
{ "user", required_argument, 0, 'u' }, {"user", required_argument, 0, 'u'},
{ "pwd", required_argument, 0, 'p' }, {"pwd", required_argument, 0, 'p'},
{ "db", required_argument, 0, 'd' }, {"db", required_argument, 0, 'd'},
{ "host", required_argument, 0, 'h' }, {"host", required_argument, 0, 'h'},
{ "space", required_argument, 0, 's' }, {"space", required_argument, 0, 's'},
{ "import", no_argument, 0, 'i' }, {"import", no_argument, 0, 'i'},
{ "export", no_argument, 0, 'e' }, {"export", no_argument, 0, 'e'},
{ "remove", no_argument, 0, 'r' }, {"remove", no_argument, 0, 'r'},
{ "quiet", no_argument, 0, 'q' }, {"quiet", no_argument, 0, 'q'},
{ "all", no_argument, 0, 'a' }, {"all", no_argument, 0, 'a'},
{ "show", no_argument, 0, 'w' }, {"show", no_argument, 0, 'w'},
{ NULL, 0, 0, 0 } {NULL, 0, 0, 0}
}; };
while((arg = getopt_long(argc, argv, "?aehu:p:qd:l:t:irs:w", l_opt, &l_index)) != -1) { while ((arg = getopt_long(argc, argv, "?aehu:p:qd:l:t:irs:w", l_opt, &l_index)) != -1)
{
#else #else
while((arg = getopt(argc, argv, "?aehu:p:qd:l:t:irs:w")) != -1) { while ((arg = getopt(argc, argv, "?aehu:p:qd:l:t:irs:w")) != -1)
{
#endif #endif
switch(arg) { switch (arg)
{
case '?': case '?':
case 'h': case 'h':
usage(); usage();
...@@ -119,8 +124,8 @@ main(int argc, char **argv) ...@@ -119,8 +124,8 @@ main(int argc, char **argv)
break; break;
case 'l': case 'l':
pgLO->action = ACTION_EXPORT_ATTR; pgLO->action = ACTION_EXPORT_ATTR;
pgLO->lolist_start = optind-1; pgLO->lolist_start = optind - 1;
parse_lolist (pgLO); parse_lolist(pgLO);
break; break;
case 'e': case 'e':
case 'a': case 'a':
...@@ -141,7 +146,9 @@ main(int argc, char **argv) ...@@ -141,7 +146,9 @@ main(int argc, char **argv)
exit(RE_ERROR); exit(RE_ERROR);
} }
} }
} else { }
else
{
usage(); usage();
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -150,14 +157,17 @@ main(int argc, char **argv) ...@@ -150,14 +157,17 @@ main(int argc, char **argv)
* Check space * Check space
* ---------- * ----------
*/ */
if (! pgLO->space && ! pgLO->action == ACTION_SHOW) { if (!pgLO->space && !pgLO->action == ACTION_SHOW)
if (!(pgLO->space = getenv("PWD"))) { {
if (!(pgLO->space = getenv("PWD")))
{
fprintf(stderr, "%s: not set space for dump-tree (option '-s' or $PWD).\n", progname); fprintf(stderr, "%s: not set space for dump-tree (option '-s' or $PWD).\n", progname);
exit(RE_ERROR); exit(RE_ERROR);
} }
} }
if (!pgLO->action) { if (!pgLO->action)
{
fprintf(stderr, "%s: What do you want - export or import?\n", progname); fprintf(stderr, "%s: What do you want - export or import?\n", progname);
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -169,7 +179,8 @@ main(int argc, char **argv) ...@@ -169,7 +179,8 @@ main(int argc, char **argv)
pgLO->conn = PQsetdbLogin(pgLO->host, NULL, NULL, NULL, pgLO->db, pgLO->conn = PQsetdbLogin(pgLO->host, NULL, NULL, NULL, pgLO->db,
pgLO->user, pwd); pgLO->user, pwd);
if (PQstatus(pgLO->conn) == CONNECTION_BAD) { if (PQstatus(pgLO->conn) == CONNECTION_BAD)
{
fprintf(stderr, "%s (connection): %s\n", progname, PQerrorMessage(pgLO->conn)); fprintf(stderr, "%s (connection): %s\n", progname, PQerrorMessage(pgLO->conn));
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -187,7 +198,8 @@ main(int argc, char **argv) ...@@ -187,7 +198,8 @@ main(int argc, char **argv)
PQexec(pgLO->conn, "BEGIN"); PQexec(pgLO->conn, "BEGIN");
switch(pgLO->action) { switch (pgLO->action)
{
case ACTION_SHOW: case ACTION_SHOW:
case ACTION_EXPORT_ALL: case ACTION_EXPORT_ALL:
...@@ -196,7 +208,8 @@ main(int argc, char **argv) ...@@ -196,7 +208,8 @@ main(int argc, char **argv)
case ACTION_EXPORT_ATTR: case ACTION_EXPORT_ATTR:
pglo_export(pgLO); pglo_export(pgLO);
if (!pgLO->quiet) { if (!pgLO->quiet)
{
if (pgLO->action == ACTION_SHOW) if (pgLO->action == ACTION_SHOW)
printf("\nDatabase '%s' contains %d large objects.\n\n", pgLO->db, pgLO->counter); printf("\nDatabase '%s' contains %d large objects.\n\n", pgLO->db, pgLO->counter);
else else
...@@ -221,27 +234,30 @@ main(int argc, char **argv) ...@@ -221,27 +234,30 @@ main(int argc, char **argv)
} }
static void static void
parse_lolist (LODumpMaster *pgLO) parse_lolist(LODumpMaster * pgLO)
{ {
LOlist *ll; LOlist *ll;
char **d, char **d,
*loc, *loc,
buff[MAX_TABLE_NAME + MAX_ATTR_NAME +1]; buff[MAX_TABLE_NAME + MAX_ATTR_NAME + 1];
pgLO->lolist = (LOlist *) malloc(pgLO->argc * sizeof(LOlist)); pgLO->lolist = (LOlist *) malloc(pgLO->argc * sizeof(LOlist));
if (! pgLO->lolist) { if (!pgLO->lolist)
{
fprintf(stderr, "%s: can't allocate memory\n", progname); fprintf(stderr, "%s: can't allocate memory\n", progname);
exit(RE_ERROR); exit(RE_ERROR);
} }
for( d=pgLO->argv + pgLO->lolist_start, ll=pgLO->lolist; for (d = pgLO->argv + pgLO->lolist_start, ll = pgLO->lolist;
*d != NULL; *d != NULL;
d++, ll++) { d++, ll++)
{
strncpy(buff, *d, MAX_TABLE_NAME + MAX_ATTR_NAME); strncpy(buff, *d, MAX_TABLE_NAME + MAX_ATTR_NAME);
if ((loc = strchr(buff, '.')) == NULL) { if ((loc = strchr(buff, '.')) == NULL)
{
fprintf(stderr, "%s: '%s' is bad 'table.attr'\n", progname, buff); fprintf(stderr, "%s: '%s' is bad 'table.attr'\n", progname, buff);
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -304,5 +320,5 @@ usage() ...@@ -304,5 +320,5 @@ usage()
" * option '-i' without option '-r' make new large obj in DB\n" " * option '-i' without option '-r' make new large obj in DB\n"
" not rewrite old, the '-i' UPDATE oid numbers in table.attr only!\n" " not rewrite old, the '-i' UPDATE oid numbers in table.attr only!\n"
" * if is not set option -s, the pg_dumplo use $PWD\n" " * if is not set option -s, the pg_dumplo use $PWD\n"
); /* puts()*/ ); /* puts() */
} }
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* pg_dumplo * pg_dumplo
* *
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.3 2001/01/24 19:42:45 momjian Exp $ * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/pg_dumplo.h,v 1.4 2001/03/22 03:59:10 momjian Exp $
* *
* Karel Zak 1999-2000 * Karel Zak 1999-2000
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
...@@ -36,13 +36,15 @@ ...@@ -36,13 +36,15 @@
* LO struct * LO struct
* ---------- * ----------
*/ */
typedef struct { typedef struct
{
char *lo_table, char *lo_table,
*lo_attr; *lo_attr;
Oid lo_oid; Oid lo_oid;
} LOlist; } LOlist;
typedef struct { typedef struct
{
int action; int action;
LOlist *lolist; LOlist *lolist;
char **argv, char **argv,
...@@ -60,7 +62,8 @@ typedef struct { ...@@ -60,7 +62,8 @@ typedef struct {
PGconn *conn; PGconn *conn;
} LODumpMaster; } LODumpMaster;
typedef enum { typedef enum
{
ACTION_NONE, ACTION_NONE,
ACTION_SHOW, ACTION_SHOW,
ACTION_EXPORT_ATTR, ACTION_EXPORT_ATTR,
...@@ -70,10 +73,10 @@ typedef enum { ...@@ -70,10 +73,10 @@ typedef enum {
extern char *progname; extern char *progname;
extern void notice (LODumpMaster *pgLO, int set); extern void notice(LODumpMaster * pgLO, int set);
extern void index_file (LODumpMaster *pgLO); extern void index_file(LODumpMaster * pgLO);
extern void load_lolist (LODumpMaster *pgLO); extern void load_lolist(LODumpMaster * pgLO);
extern void pglo_export (LODumpMaster *pgLO); extern void pglo_export(LODumpMaster * pgLO);
extern void pglo_import (LODumpMaster *pgLO); extern void pglo_import(LODumpMaster * pgLO);
#endif /* PG_DUMPLO_H */ #endif /* PG_DUMPLO_H */
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* pg_dumplo * pg_dumplo
* *
* $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/utils.c,v 1.3 2001/01/24 19:42:45 momjian Exp $ * $Header: /cvsroot/pgsql/contrib/pg_dumplo/Attic/utils.c,v 1.4 2001/03/22 03:59:10 momjian Exp $
* *
* Karel Zak 1999-2000 * Karel Zak 1999-2000
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
extern int errno; extern int errno;
static void Dummy_NoticeProcessor(void * arg, const char * message); static void Dummy_NoticeProcessor(void *arg, const char *message);
static void Default_NoticeProcessor(void * arg, const char * message); static void Default_NoticeProcessor(void *arg, const char *message);
void void
index_file(LODumpMaster *pgLO) index_file(LODumpMaster * pgLO)
{ {
char path[BUFSIZ]; char path[BUFSIZ];
...@@ -39,10 +39,13 @@ index_file(LODumpMaster *pgLO) ...@@ -39,10 +39,13 @@ index_file(LODumpMaster *pgLO)
sprintf(path, "%s/%s", pgLO->space, pgLO->db); sprintf(path, "%s/%s", pgLO->space, pgLO->db);
if (pgLO->action == ACTION_EXPORT_ATTR || if (pgLO->action == ACTION_EXPORT_ATTR ||
pgLO->action == ACTION_EXPORT_ALL) { pgLO->action == ACTION_EXPORT_ALL)
{
if (mkdir(path, DIR_UMASK) == -1) { if (mkdir(path, DIR_UMASK) == -1)
if (errno != EEXIST) { {
if (errno != EEXIST)
{
perror(path); perror(path);
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -50,16 +53,20 @@ index_file(LODumpMaster *pgLO) ...@@ -50,16 +53,20 @@ index_file(LODumpMaster *pgLO)
sprintf(path, "%s/lo_dump.index", path); sprintf(path, "%s/lo_dump.index", path);
if ((pgLO->index = fopen(path, "w")) == NULL) { if ((pgLO->index = fopen(path, "w")) == NULL)
{
perror(path); perror(path);
exit(RE_ERROR); exit(RE_ERROR);
} }
} else if (pgLO->action != ACTION_NONE ) { }
else if (pgLO->action != ACTION_NONE)
{
sprintf(path, "%s/lo_dump.index", path); sprintf(path, "%s/lo_dump.index", path);
if ((pgLO->index = fopen(path, "r")) == NULL) { if ((pgLO->index = fopen(path, "r")) == NULL)
{
perror(path); perror(path);
exit(RE_ERROR); exit(RE_ERROR);
} }
...@@ -67,20 +74,24 @@ index_file(LODumpMaster *pgLO) ...@@ -67,20 +74,24 @@ index_file(LODumpMaster *pgLO)
} }
static static
void Dummy_NoticeProcessor(void * arg, const char * message) void
Dummy_NoticeProcessor(void *arg, const char *message)
{ {
; ;
} }
static static
void Default_NoticeProcessor(void * arg, const char * message) void
Default_NoticeProcessor(void *arg, const char *message)
{ {
fprintf(stderr, "%s", message); fprintf(stderr, "%s", message);
} }
void void
notice(LODumpMaster *pgLO, int set) notice(LODumpMaster * pgLO, int set)
{ {
if (set)PQsetNoticeProcessor(pgLO->conn, Default_NoticeProcessor, NULL); if (set)
else PQsetNoticeProcessor(pgLO->conn, Dummy_NoticeProcessor, NULL); PQsetNoticeProcessor(pgLO->conn, Default_NoticeProcessor, NULL);
else
PQsetNoticeProcessor(pgLO->conn, Dummy_NoticeProcessor, NULL);
} }
...@@ -13,24 +13,48 @@ ...@@ -13,24 +13,48 @@
#include <syslog.h> #include <syslog.h>
#include <string.h> #include <string.h>
struct { struct
{
const char *tag; const char *tag;
int size; int size;
int priority; int priority;
} tags[] = { } tags[] =
{ "", 0, LOG_NOTICE },
{ "emerg:", sizeof("emerg"), LOG_EMERG }, {
{ "alert:", sizeof("alert"), LOG_ALERT }, {
{ "crit:", sizeof("crit"), LOG_CRIT }, "", 0, LOG_NOTICE
{ "err:", sizeof("err"), LOG_ERR }, },
{ "error:", sizeof("error"), LOG_ERR }, {
{ "warning:", sizeof("warning"), LOG_WARNING }, "emerg:", sizeof("emerg"), LOG_EMERG
{ "notice:", sizeof("notice"), LOG_NOTICE }, },
{ "info:", sizeof("info"), LOG_INFO }, {
{ "debug:", sizeof("debug"), LOG_DEBUG } "alert:", sizeof("alert"), LOG_ALERT
},
{
"crit:", sizeof("crit"), LOG_CRIT
},
{
"err:", sizeof("err"), LOG_ERR
},
{
"error:", sizeof("error"), LOG_ERR
},
{
"warning:", sizeof("warning"), LOG_WARNING
},
{
"notice:", sizeof("notice"), LOG_NOTICE
},
{
"info:", sizeof("info"), LOG_INFO
},
{
"debug:", sizeof("debug"), LOG_DEBUG
}
}; };
int main() int
main()
{ {
char buf[301]; char buf[301];
int c; int c;
...@@ -40,29 +64,29 @@ int main() ...@@ -40,29 +64,29 @@ int main()
#ifndef DEBUG #ifndef DEBUG
openlog("postgresql", LOG_CONS, LOG_LOCAL1); openlog("postgresql", LOG_CONS, LOG_LOCAL1);
#endif #endif
while ( (c = getchar()) != EOF) { while ((c = getchar()) != EOF)
if (c == '\r') { {
if (c == '\r')
continue; continue;
} if (c == '\n')
if (c == '\n') { {
int level = sizeof(tags)/sizeof(*tags); int level = sizeof(tags) / sizeof(*tags);
char *bol; char *bol;
if (colon == 0 || (size_t)(colon - buf) > sizeof("warning")) { if (colon == 0 || (size_t) (colon - buf) > sizeof("warning"))
level = 1; level = 1;
}
*pos = 0; *pos = 0;
while (--level) { while (--level)
{
if (pos - buf >= tags[level].size if (pos - buf >= tags[level].size
&& strncmp(buf, tags[level].tag, tags[level].size) == 0) { && strncmp(buf, tags[level].tag, tags[level].size) == 0)
break; break;
} }
}
bol = buf + tags[level].size; bol = buf + tags[level].size;
if (bol > buf && *bol == ' ') { if (bol > buf && *bol == ' ')
++bol; ++bol;
} if (pos - bol > 0)
if (pos - bol > 0) { {
#ifndef DEBUG #ifndef DEBUG
syslog(tags[level].priority, "%s", bol); syslog(tags[level].priority, "%s", bol);
#else #else
...@@ -70,16 +94,13 @@ int main() ...@@ -70,16 +94,13 @@ int main()
#endif #endif
} }
pos = buf; pos = buf;
colon = (char const *)0; colon = (char const *) 0;
continue; continue;
} }
if (c == ':' && !colon) { if (c == ':' && !colon)
colon = pos; colon = pos;
} if ((size_t) (pos - buf) < sizeof(buf) - 1)
if ((size_t)(pos - buf) < sizeof(buf)-1) {
*pos++ = c; *pos++ = c;
} }
}
return 0; return 0;
} }
This diff is collapsed.
...@@ -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: encode.c,v 1.3 2001/02/10 02:31:25 tgl Exp $ * $Id: encode.c,v 1.4 2001/03/22 03:59:10 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
#endif #endif
static pg_coding * static pg_coding *
find_coding(pg_coding *hbuf, text *name, int silent); find_coding(pg_coding * hbuf, text *name, int silent);
static pg_coding * static pg_coding *
pg_find_coding(pg_coding *res, char *name); pg_find_coding(pg_coding * res, char *name);
/* SQL function: encode(bytea, text) returns text */ /* SQL function: encode(bytea, text) returns text */
...@@ -56,8 +56,11 @@ encode(PG_FUNCTION_ARGS) ...@@ -56,8 +56,11 @@ encode(PG_FUNCTION_ARGS)
{ {
text *arg; text *arg;
text *name; text *name;
uint len, rlen, rlen0; uint len,
pg_coding *c, cbuf; rlen,
rlen0;
pg_coding *c,
cbuf;
text *res; text *res;
if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
...@@ -71,7 +74,7 @@ encode(PG_FUNCTION_ARGS) ...@@ -71,7 +74,7 @@ encode(PG_FUNCTION_ARGS)
rlen0 = c->encode_len(len); rlen0 = c->encode_len(len);
res = (text *)palloc(rlen0 + VARHDRSZ); res = (text *) palloc(rlen0 + VARHDRSZ);
rlen = c->encode(VARDATA(arg), len, VARDATA(res)); rlen = c->encode(VARDATA(arg), len, VARDATA(res));
VARATT_SIZEP(res) = rlen + VARHDRSZ; VARATT_SIZEP(res) = rlen + VARHDRSZ;
...@@ -93,8 +96,11 @@ decode(PG_FUNCTION_ARGS) ...@@ -93,8 +96,11 @@ decode(PG_FUNCTION_ARGS)
{ {
text *arg; text *arg;
text *name; text *name;
uint len, rlen, rlen0; uint len,
pg_coding *c, cbuf; rlen,
rlen0;
pg_coding *c,
cbuf;
text *res; text *res;
if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
...@@ -108,7 +114,7 @@ decode(PG_FUNCTION_ARGS) ...@@ -108,7 +114,7 @@ decode(PG_FUNCTION_ARGS)
rlen0 = c->decode_len(len); rlen0 = c->decode_len(len);
res = (text *)palloc(rlen0 + VARHDRSZ); res = (text *) palloc(rlen0 + VARHDRSZ);
rlen = c->decode(VARDATA(arg), len, VARDATA(res)); rlen = c->decode(VARDATA(arg), len, VARDATA(res));
VARATT_SIZEP(res) = rlen + VARHDRSZ; VARATT_SIZEP(res) = rlen + VARHDRSZ;
...@@ -123,14 +129,15 @@ decode(PG_FUNCTION_ARGS) ...@@ -123,14 +129,15 @@ decode(PG_FUNCTION_ARGS)
} }
static pg_coding * static pg_coding *
find_coding(pg_coding *dst, text *name, int silent) find_coding(pg_coding * dst, text *name, int silent)
{ {
pg_coding *p; pg_coding *p;
char buf[NAMEDATALEN]; char buf[NAMEDATALEN];
uint len; uint len;
len = VARSIZE(name) - VARHDRSZ; len = VARSIZE(name) - VARHDRSZ;
if (len >= NAMEDATALEN) { if (len >= NAMEDATALEN)
{
if (silent) if (silent)
return NULL; return NULL;
elog(ERROR, "Encoding type does not exist (name too long)"); elog(ERROR, "Encoding type does not exist (name too long)");
...@@ -152,12 +159,14 @@ uint ...@@ -152,12 +159,14 @@ uint
hex_encode(uint8 *src, uint len, uint8 *dst) hex_encode(uint8 *src, uint len, uint8 *dst)
{ {
uint8 *end = src + len; uint8 *end = src + len;
while (src < end) {
while (src < end)
{
*dst++ = hextbl[(*src >> 4) & 0xF]; *dst++ = hextbl[(*src >> 4) & 0xF];
*dst++ = hextbl[*src & 0xF]; *dst++ = hextbl[*src & 0xF];
src++; src++;
} }
return len*2; return len * 2;
} }
/* probably should use lookup table */ /* probably should use lookup table */
...@@ -181,12 +190,19 @@ get_hex(char c) ...@@ -181,12 +190,19 @@ get_hex(char c)
uint uint
hex_decode(uint8 *src, uint len, uint8 *dst) hex_decode(uint8 *src, uint len, uint8 *dst)
{ {
uint8 *s, *srcend, v1, v2, *p = dst; uint8 *s,
*srcend,
v1,
v2,
*p = dst;
srcend = src + len; srcend = src + len;
s = src; p = dst; s = src;
while (s < srcend) { p = dst;
if (*s == ' ' || *s == '\n' || *s == '\t' || *s == '\r') { while (s < srcend)
{
if (*s == ' ' || *s == '\n' || *s == '\t' || *s == '\r')
{
s++; s++;
continue; continue;
} }
...@@ -202,24 +218,30 @@ hex_decode(uint8 *src, uint len, uint8 *dst) ...@@ -202,24 +218,30 @@ hex_decode(uint8 *src, uint len, uint8 *dst)
static unsigned char _base64[] = static unsigned char _base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
uint uint
b64_encode(uint8 *src, uint len, uint8 *dst) b64_encode(uint8 *src, uint len, uint8 *dst)
{ {
uint8 *s, *p, *end = src + len, *lend = dst + 76; uint8 *s,
*p,
*end = src + len,
*lend = dst + 76;
int pos = 2; int pos = 2;
unsigned long buf = 0; unsigned long buf = 0;
s = src; p = dst; s = src;
p = dst;
while (s < end) { while (s < end)
{
buf |= *s << (pos << 3); buf |= *s << (pos << 3);
pos--; pos--;
s++; s++;
/* write it out */ /* write it out */
if (pos < 0) { if (pos < 0)
{
*p++ = _base64[(buf >> 18) & 0x3f]; *p++ = _base64[(buf >> 18) & 0x3f];
*p++ = _base64[(buf >> 12) & 0x3f]; *p++ = _base64[(buf >> 12) & 0x3f];
*p++ = _base64[(buf >> 6) & 0x3f]; *p++ = _base64[(buf >> 6) & 0x3f];
...@@ -228,12 +250,14 @@ b64_encode(uint8 *src, uint len, uint8 *dst) ...@@ -228,12 +250,14 @@ b64_encode(uint8 *src, uint len, uint8 *dst)
pos = 2; pos = 2;
buf = 0; buf = 0;
} }
if (p >= lend) { if (p >= lend)
{
*p++ = '\n'; *p++ = '\n';
lend = p + 76; lend = p + 76;
} }
} }
if (pos != 2) { if (pos != 2)
{
*p++ = _base64[(buf >> 18) & 0x3f]; *p++ = _base64[(buf >> 18) & 0x3f];
*p++ = _base64[(buf >> 12) & 0x3f]; *p++ = _base64[(buf >> 12) & 0x3f];
*p++ = (pos == 0) ? _base64[(buf >> 6) & 0x3f] : '='; *p++ = (pos == 0) ? _base64[(buf >> 6) & 0x3f] : '=';
...@@ -247,14 +271,17 @@ b64_encode(uint8 *src, uint len, uint8 *dst) ...@@ -247,14 +271,17 @@ b64_encode(uint8 *src, uint len, uint8 *dst)
uint uint
b64_decode(uint8 *src, uint len, uint8 *dst) b64_decode(uint8 *src, uint len, uint8 *dst)
{ {
char *srcend = src + len, *s = src; char *srcend = src + len,
*s = src;
uint8 *p = dst; uint8 *p = dst;
char c; char c;
uint b = 0; uint b = 0;
unsigned long buf = 0; unsigned long buf = 0;
int pos = 0, end = 0; int pos = 0,
end = 0;
while (s < srcend) { while (s < srcend)
{
c = *s++; c = *s++;
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
b = c - 'A'; b = c - 'A';
...@@ -266,16 +293,21 @@ b64_decode(uint8 *src, uint len, uint8 *dst) ...@@ -266,16 +293,21 @@ b64_decode(uint8 *src, uint len, uint8 *dst)
b = 62; b = 62;
else if (c == '/') else if (c == '/')
b = 63; b = 63;
else if (c == '=') { else if (c == '=')
{
/* end sequence */ /* end sequence */
if (!end) { if (!end)
if (pos == 2) end = 1; {
else if (pos == 3) end = 2; if (pos == 2)
end = 1;
else if (pos == 3)
end = 2;
else else
elog(ERROR, "base64: unexpected '='"); elog(ERROR, "base64: unexpected '='");
} }
b = 0; b = 0;
} else if (c == ' ' || c == '\t' || c == '\n' || c == '\r') }
else if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
continue; continue;
else else
elog(ERROR, "base64: Invalid symbol"); elog(ERROR, "base64: Invalid symbol");
...@@ -283,7 +315,8 @@ b64_decode(uint8 *src, uint len, uint8 *dst) ...@@ -283,7 +315,8 @@ b64_decode(uint8 *src, uint len, uint8 *dst)
/* add it to buffer */ /* add it to buffer */
buf = (buf << 6) + b; buf = (buf << 6) + b;
pos++; pos++;
if (pos == 4) { if (pos == 4)
{
*p++ = (buf >> 16) & 255; *p++ = (buf >> 16) & 255;
if (end == 0 || end > 1) if (end == 0 || end > 1)
*p++ = (buf >> 8) & 255; *p++ = (buf >> 8) & 255;
...@@ -326,21 +359,22 @@ b64_dec_len(uint srclen) ...@@ -326,21 +359,22 @@ b64_dec_len(uint srclen)
} }
static pg_coding static pg_coding
encoding_list [] = { encoding_list[] = {
{ "hex", hex_enc_len, hex_dec_len, hex_encode, hex_decode}, {"hex", hex_enc_len, hex_dec_len, hex_encode, hex_decode},
{ "base64", b64_enc_len, b64_dec_len, b64_encode, b64_decode}, {"base64", b64_enc_len, b64_dec_len, b64_encode, b64_decode},
{ NULL, NULL, NULL, NULL, NULL} {NULL, NULL, NULL, NULL, NULL}
}; };
static pg_coding * static pg_coding *
pg_find_coding(pg_coding *res, char *name) pg_find_coding(pg_coding * res, char *name)
{ {
pg_coding *p; pg_coding *p;
for (p = encoding_list; p->name; p++) {
for (p = encoding_list; p->name; p++)
{
if (!strcasecmp(p->name, name)) if (!strcasecmp(p->name, name))
return p; return p;
} }
return NULL; return NULL;
} }
...@@ -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: encode.h,v 1.1 2001/01/24 03:46:16 momjian Exp $ * $Id: encode.h,v 1.2 2001/03/22 03:59:10 momjian Exp $
*/ */
#ifndef __PG_ENCODE_H #ifndef __PG_ENCODE_H
...@@ -37,12 +37,13 @@ Datum encode(PG_FUNCTION_ARGS); ...@@ -37,12 +37,13 @@ Datum encode(PG_FUNCTION_ARGS);
Datum decode(PG_FUNCTION_ARGS); Datum decode(PG_FUNCTION_ARGS);
typedef struct _pg_coding pg_coding; typedef struct _pg_coding pg_coding;
struct _pg_coding { struct _pg_coding
{
char *name; char *name;
uint (*encode_len)(uint dlen); uint (*encode_len) (uint dlen);
uint (*decode_len)(uint dlen); uint (*decode_len) (uint dlen);
uint (*encode)(uint8 *data, uint dlen, uint8 *res); uint (*encode) (uint8 *data, uint dlen, uint8 *res);
uint (*decode)(uint8 *data, uint dlen, uint8 *res); uint (*decode) (uint8 *data, uint dlen, uint8 *res);
}; };
/* They are for outside usage in C code, if needed */ /* They are for outside usage in C code, if needed */
...@@ -57,4 +58,3 @@ uint b64_enc_len(uint srclen); ...@@ -57,4 +58,3 @@ uint b64_enc_len(uint srclen);
uint b64_dec_len(uint srclen); uint b64_dec_len(uint srclen);
#endif /* __PG_ENCODE_H */ #endif /* __PG_ENCODE_H */
...@@ -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: internal.c,v 1.2 2001/02/10 02:31:25 tgl Exp $ * $Id: internal.c,v 1.3 2001/03/22 03:59:10 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -49,29 +49,30 @@ ...@@ -49,29 +49,30 @@
#endif #endif
static uint static uint
pg_md5_len(pg_digest *h); pg_md5_len(pg_digest * h);
static uint8 * static uint8 *
pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf); pg_md5_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf);
static uint static uint
pg_sha1_len(pg_digest *h); pg_sha1_len(pg_digest * h);
static uint8 * static uint8 *
pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf); pg_sha1_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf);
static pg_digest static pg_digest
int_digest_list [] = { int_digest_list[] = {
{ "md5", pg_md5_len, pg_md5_digest, {0}}, {"md5", pg_md5_len, pg_md5_digest, {0}},
{ "sha1", pg_sha1_len, pg_sha1_digest, {0}}, {"sha1", pg_sha1_len, pg_sha1_digest, {0}},
{ NULL, NULL, NULL, {0}} {NULL, NULL, NULL, {0}}
}; };
static uint static uint
pg_md5_len(pg_digest *h) { pg_md5_len(pg_digest * h)
{
return MD5_DIGEST_LENGTH; return MD5_DIGEST_LENGTH;
} }
static uint8 * static uint8 *
pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) pg_md5_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf)
{ {
MD5_CTX ctx; MD5_CTX ctx;
...@@ -83,12 +84,13 @@ pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) ...@@ -83,12 +84,13 @@ pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf)
} }
static uint static uint
pg_sha1_len(pg_digest *h) { pg_sha1_len(pg_digest * h)
{
return SHA1_DIGEST_LENGTH; return SHA1_DIGEST_LENGTH;
} }
static uint8 * static uint8 *
pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) pg_sha1_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf)
{ {
SHA1_CTX ctx; SHA1_CTX ctx;
...@@ -101,7 +103,7 @@ pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) ...@@ -101,7 +103,7 @@ pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf)
pg_digest * pg_digest *
pg_find_digest(pg_digest *h, char *name) pg_find_digest(pg_digest * h, char *name)
{ {
pg_digest *p; pg_digest *p;
...@@ -110,5 +112,3 @@ pg_find_digest(pg_digest *h, char *name) ...@@ -110,5 +112,3 @@ pg_find_digest(pg_digest *h, char *name)
return p; return p;
return NULL; return NULL;
} }
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* It is possible that this works with other SHA1/MD5 * It is possible that this works with other SHA1/MD5
* implementations too. * implementations too.
* *
* $Id: krb.c,v 1.3 2001/02/20 15:34:14 momjian Exp $ * $Id: krb.c,v 1.4 2001/03/22 03:59:10 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -54,29 +54,30 @@ ...@@ -54,29 +54,30 @@
#endif #endif
static uint static uint
pg_md5_len(pg_digest *h); pg_md5_len(pg_digest * h);
static uint8 * static uint8 *
pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf); pg_md5_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf);
static uint static uint
pg_sha1_len(pg_digest *h); pg_sha1_len(pg_digest * h);
static uint8 * static uint8 *
pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf); pg_sha1_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf);
static pg_digest static pg_digest
int_digest_list [] = { int_digest_list[] = {
{ "md5", pg_md5_len, pg_md5_digest, {0}}, {"md5", pg_md5_len, pg_md5_digest, {0}},
{ "sha1", pg_sha1_len, pg_sha1_digest, {0}}, {"sha1", pg_sha1_len, pg_sha1_digest, {0}},
{ NULL, NULL, NULL, {0}} {NULL, NULL, NULL, {0}}
}; };
static uint static uint
pg_md5_len(pg_digest *h) { pg_md5_len(pg_digest * h)
{
return MD5_DIGEST_LENGTH; return MD5_DIGEST_LENGTH;
} }
static uint8 * static uint8 *
pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) pg_md5_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf)
{ {
MD5_CTX ctx; MD5_CTX ctx;
...@@ -88,12 +89,13 @@ pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) ...@@ -88,12 +89,13 @@ pg_md5_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf)
} }
static uint static uint
pg_sha1_len(pg_digest *h) { pg_sha1_len(pg_digest * h)
{
return SHA1_DIGEST_LENGTH; return SHA1_DIGEST_LENGTH;
} }
static uint8 * static uint8 *
pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) pg_sha1_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf)
{ {
SHA1_CTX ctx; SHA1_CTX ctx;
...@@ -106,7 +108,7 @@ pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) ...@@ -106,7 +108,7 @@ pg_sha1_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf)
pg_digest * pg_digest *
pg_find_digest(pg_digest *h, char *name) pg_find_digest(pg_digest * h, char *name)
{ {
pg_digest *p; pg_digest *p;
...@@ -115,5 +117,3 @@ pg_find_digest(pg_digest *h, char *name) ...@@ -115,5 +117,3 @@ pg_find_digest(pg_digest *h, char *name)
return p; return p;
return NULL; return NULL;
} }
This diff is collapsed.
/* $Id: md5.h,v 1.3 2001/01/09 16:07:13 momjian Exp $ */ /* $Id: md5.h,v 1.4 2001/03/22 03:59:10 momjian Exp $ */
/* $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
/* /*
...@@ -35,8 +35,10 @@ ...@@ -35,8 +35,10 @@
#define MD5_BUFLEN 64 #define MD5_BUFLEN 64
typedef struct { typedef struct
union { {
union
{
uint32 md5_state32[4]; uint32 md5_state32[4];
uint8 md5_state8[16]; uint8 md5_state8[16];
} md5_st; } md5_st;
...@@ -47,7 +49,8 @@ typedef struct { ...@@ -47,7 +49,8 @@ typedef struct {
#define md5_std md5_st.md5_state32[3] #define md5_std md5_st.md5_state32[3]
#define md5_st8 md5_st.md5_state8 #define md5_st8 md5_st.md5_state8
union { union
{
uint64 md5_count64; uint64 md5_count64;
uint8 md5_count8[8]; uint8 md5_count8[8];
} md5_count; } md5_count;
...@@ -58,10 +61,10 @@ typedef struct { ...@@ -58,10 +61,10 @@ typedef struct {
uint8 md5_buf[MD5_BUFLEN]; uint8 md5_buf[MD5_BUFLEN];
} md5_ctxt; } md5_ctxt;
extern void md5_init (md5_ctxt *); extern void md5_init(md5_ctxt *);
extern void md5_loop (md5_ctxt *, uint8 *, unsigned int); extern void md5_loop(md5_ctxt *, uint8 *, unsigned int);
extern void md5_pad (md5_ctxt *); extern void md5_pad(md5_ctxt *);
extern void md5_result (uint8 *, md5_ctxt *); extern void md5_result(uint8 *, md5_ctxt *);
/* compatibility */ /* compatibility */
#define MD5_CTX md5_ctxt #define MD5_CTX md5_ctxt
...@@ -73,4 +76,4 @@ do { \ ...@@ -73,4 +76,4 @@ do { \
md5_result((x), (y)); \ md5_result((x), (y)); \
} while (0) } while (0)
#endif /* ! _NETINET6_MD5_H_*/ #endif /* ! _NETINET6_MD5_H_ */
...@@ -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: mhash.c,v 1.2 2001/02/10 02:31:26 tgl Exp $ * $Id: mhash.c,v 1.3 2001/03/22 03:59:10 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -36,22 +36,23 @@ ...@@ -36,22 +36,23 @@
#include <mhash.h> #include <mhash.h>
static uint static uint
pg_mhash_len(pg_digest *hash); pg_mhash_len(pg_digest * hash);
static uint8 * static uint8 *pg_mhash_digest(pg_digest * hash, uint8 *src,
pg_mhash_digest(pg_digest *hash, uint8 *src,
uint len, uint8 *buf); uint len, uint8 *buf);
static uint static uint
pg_mhash_len(pg_digest *h) { pg_mhash_len(pg_digest * h)
{
return mhash_get_block_size(h->misc.code); return mhash_get_block_size(h->misc.code);
} }
static uint8 * static uint8 *
pg_mhash_digest(pg_digest *h, uint8 *src, uint len, uint8 *dst) pg_mhash_digest(pg_digest * h, uint8 *src, uint len, uint8 *dst)
{ {
uint8 *res; uint8 *res;
MHASH mh = mhash_init(h->misc.code); MHASH mh = mhash_init(h->misc.code);
mhash(mh, src, len); mhash(mh, src, len);
res = mhash_end(mh); res = mhash_end(mh);
...@@ -62,19 +63,23 @@ pg_mhash_digest(pg_digest *h, uint8 *src, uint len, uint8 *dst) ...@@ -62,19 +63,23 @@ pg_mhash_digest(pg_digest *h, uint8 *src, uint len, uint8 *dst)
} }
pg_digest * pg_digest *
pg_find_digest(pg_digest *h, char *name) pg_find_digest(pg_digest * h, char *name)
{ {
size_t hnum, i, b; size_t hnum,
i,
b;
char *mname; char *mname;
hnum = mhash_count(); hnum = mhash_count();
for (i = 0; i <= hnum; i++) { for (i = 0; i <= hnum; i++)
{
mname = mhash_get_hash_name(i); mname = mhash_get_hash_name(i);
if (mname == NULL) if (mname == NULL)
continue; continue;
b = strcasecmp(name, mname); b = strcasecmp(name, mname);
free(mname); free(mname);
if (!b) { if (!b)
{
h->name = mhash_get_hash_name(i); h->name = mhash_get_hash_name(i);
h->length = pg_mhash_len; h->length = pg_mhash_len;
h->digest = pg_mhash_digest; h->digest = pg_mhash_digest;
...@@ -84,4 +89,3 @@ pg_find_digest(pg_digest *h, char *name) ...@@ -84,4 +89,3 @@ pg_find_digest(pg_digest *h, char *name)
} }
return NULL; return NULL;
} }
...@@ -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.2 2001/02/10 02:31:26 tgl Exp $ * $Id: openssl.c,v 1.3 2001/03/22 03:59:10 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -36,19 +36,20 @@ ...@@ -36,19 +36,20 @@
#include <evp.h> #include <evp.h>
static uint static uint
pg_ossl_len(pg_digest *h); pg_ossl_len(pg_digest * h);
static uint8 * static uint8 *
pg_ossl_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf); pg_ossl_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf);
static uint static uint
pg_ossl_len(pg_digest *h) { pg_ossl_len(pg_digest * h)
return EVP_MD_size((EVP_MD*)h->misc.ptr); {
return EVP_MD_size((EVP_MD *) h->misc.ptr);
} }
static uint8 * static uint8 *
pg_ossl_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) pg_ossl_digest(pg_digest * h, uint8 *src, uint len, uint8 *buf)
{ {
EVP_MD *md = (EVP_MD*)h->misc.ptr; EVP_MD *md = (EVP_MD *) h->misc.ptr;
EVP_MD_CTX ctx; EVP_MD_CTX ctx;
EVP_DigestInit(&ctx, md); EVP_DigestInit(&ctx, md);
...@@ -61,11 +62,12 @@ pg_ossl_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf) ...@@ -61,11 +62,12 @@ pg_ossl_digest(pg_digest *h, uint8 *src, uint len, uint8 *buf)
static int pg_openssl_initialized = 0; static int pg_openssl_initialized = 0;
pg_digest * pg_digest *
pg_find_digest(pg_digest *h, char *name) pg_find_digest(pg_digest * h, char *name)
{ {
const EVP_MD *md; const EVP_MD *md;
if (!pg_openssl_initialized) { if (!pg_openssl_initialized)
{
OpenSSL_add_all_digests(); OpenSSL_add_all_digests();
pg_openssl_initialized = 1; pg_openssl_initialized = 1;
} }
...@@ -77,9 +79,7 @@ pg_find_digest(pg_digest *h, char *name) ...@@ -77,9 +79,7 @@ pg_find_digest(pg_digest *h, char *name)
h->name = name; h->name = name;
h->length = pg_ossl_len; h->length = pg_ossl_len;
h->digest = pg_ossl_digest; h->digest = pg_ossl_digest;
h->misc.ptr = (void*)md; h->misc.ptr = (void *) md;
return h; return h;
} }
...@@ -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.6 2001/02/10 02:31:26 tgl Exp $ * $Id: pgcrypto.c,v 1.7 2001/03/22 03:59:10 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -49,7 +49,7 @@ Datum digest_exists(PG_FUNCTION_ARGS); ...@@ -49,7 +49,7 @@ Datum digest_exists(PG_FUNCTION_ARGS);
/* private stuff */ /* private stuff */
static pg_digest * static pg_digest *
find_digest(pg_digest *hbuf, text *name, int silent); find_digest(pg_digest * hbuf, text *name, int silent);
/* SQL function: hash(text, text) returns text */ /* SQL function: hash(text, text) returns text */
...@@ -60,8 +60,10 @@ digest(PG_FUNCTION_ARGS) ...@@ -60,8 +60,10 @@ digest(PG_FUNCTION_ARGS)
{ {
text *arg; text *arg;
text *name; text *name;
uint len, hlen; uint len,
pg_digest *h, _hbuf; hlen;
pg_digest *h,
_hbuf;
text *res; text *res;
if (PG_ARGISNULL(0) || PG_ARGISNULL(1)) if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
...@@ -72,7 +74,7 @@ digest(PG_FUNCTION_ARGS) ...@@ -72,7 +74,7 @@ digest(PG_FUNCTION_ARGS)
hlen = h->length(h); hlen = h->length(h);
res = (text *)palloc(hlen + VARHDRSZ); res = (text *) palloc(hlen + VARHDRSZ);
VARATT_SIZEP(res) = hlen + VARHDRSZ; VARATT_SIZEP(res) = hlen + VARHDRSZ;
arg = PG_GETARG_TEXT_P(0); arg = PG_GETARG_TEXT_P(0);
...@@ -93,7 +95,8 @@ Datum ...@@ -93,7 +95,8 @@ Datum
digest_exists(PG_FUNCTION_ARGS) digest_exists(PG_FUNCTION_ARGS)
{ {
text *name; text *name;
pg_digest _hbuf, *res; pg_digest _hbuf,
*res;
if (PG_ARGISNULL(0)) if (PG_ARGISNULL(0))
PG_RETURN_NULL(); PG_RETURN_NULL();
...@@ -110,14 +113,15 @@ digest_exists(PG_FUNCTION_ARGS) ...@@ -110,14 +113,15 @@ digest_exists(PG_FUNCTION_ARGS)
} }
static pg_digest * static pg_digest *
find_digest(pg_digest *hbuf, text *name, int silent) find_digest(pg_digest * hbuf, text *name, int silent)
{ {
pg_digest *p; pg_digest *p;
char buf[NAMEDATALEN]; char buf[NAMEDATALEN];
uint len; uint len;
len = VARSIZE(name) - VARHDRSZ; len = VARSIZE(name) - VARHDRSZ;
if (len >= NAMEDATALEN) { if (len >= NAMEDATALEN)
{
if (silent) if (silent)
return NULL; return NULL;
elog(ERROR, "Hash type does not exist (name too long)"); elog(ERROR, "Hash type does not exist (name too long)");
...@@ -132,4 +136,3 @@ find_digest(pg_digest *hbuf, text *name, int silent) ...@@ -132,4 +136,3 @@ find_digest(pg_digest *hbuf, text *name, int silent)
elog(ERROR, "Hash type does not exist: '%s'", buf); elog(ERROR, "Hash type does not exist: '%s'", buf);
return p; return p;
} }
...@@ -26,25 +26,27 @@ ...@@ -26,25 +26,27 @@
* 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.h,v 1.2 2001/01/09 16:07:13 momjian Exp $ * $Id: pgcrypto.h,v 1.3 2001/03/22 03:59:10 momjian Exp $
*/ */
#ifndef _PG_CRYPTO_H #ifndef _PG_CRYPTO_H
#define _PG_CRYPTO_H #define _PG_CRYPTO_H
typedef struct _pg_digest pg_digest; typedef struct _pg_digest pg_digest;
struct _pg_digest { struct _pg_digest
{
char *name; char *name;
uint (*length)(pg_digest *h); uint (*length) (pg_digest * h);
uint8 *(*digest)(pg_digest *h, uint8 *data, uint8 *(*digest) (pg_digest * h, uint8 *data,
uint dlen, uint8 *buf); uint dlen, uint8 *buf);
/* private */ /* private */
union { union
{
uint code; uint code;
const void *ptr; const void *ptr;
} misc; } misc;
}; };
extern pg_digest *pg_find_digest(pg_digest *hbuf, char *name); extern pg_digest *pg_find_digest(pg_digest * hbuf, char *name);
#endif #endif
This diff is collapsed.
/* $Id: sha1.h,v 1.3 2001/01/09 16:07:13 momjian Exp $ */ /* $Id: sha1.h,v 1.4 2001/03/22 03:59:10 momjian Exp $ */
/* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */ /* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */
/* /*
...@@ -38,33 +38,38 @@ ...@@ -38,33 +38,38 @@
#ifndef _NETINET6_SHA1_H_ #ifndef _NETINET6_SHA1_H_
#define _NETINET6_SHA1_H_ #define _NETINET6_SHA1_H_
struct sha1_ctxt { struct sha1_ctxt
union { {
union
{
uint8 b8[20]; uint8 b8[20];
uint32 b32[5]; uint32 b32[5];
} h; } h;
union { union
{
uint8 b8[8]; uint8 b8[8];
uint64 b64[1]; uint64 b64[1];
} c; } c;
union { union
{
uint8 b8[64]; uint8 b8[64];
uint32 b32[16]; uint32 b32[16];
} m; } m;
uint8 count; uint8 count;
}; };
extern void sha1_init (struct sha1_ctxt *); extern void sha1_init(struct sha1_ctxt *);
extern void sha1_pad (struct sha1_ctxt *); extern void sha1_pad(struct sha1_ctxt *);
extern void sha1_loop (struct sha1_ctxt *, const caddr_t, size_t); extern void sha1_loop(struct sha1_ctxt *, const caddr_t, size_t);
extern void sha1_result (struct sha1_ctxt *, caddr_t); extern void sha1_result(struct sha1_ctxt *, caddr_t);
/* compatibilty with other SHA1 source codes */ /* compatibilty with other SHA1 source codes */
typedef struct sha1_ctxt SHA1_CTX; typedef struct sha1_ctxt SHA1_CTX;
#define SHA1Init(x) sha1_init((x)) #define SHA1Init(x) sha1_init((x))
#define SHA1Update(x, y, z) sha1_loop((x), (y), (z)) #define SHA1Update(x, y, z) sha1_loop((x), (y), (z))
#define SHA1Final(x, y) sha1_result((y), (x)) #define SHA1Final(x, y) sha1_result((y), (x))
#define SHA1_RESULTLEN (160/8) #define SHA1_RESULTLEN (160/8)
#endif /*_NETINET6_SHA1_H_*/ #endif /* _NETINET6_SHA1_H_ */
...@@ -19,15 +19,17 @@ PG_FUNCTION_INFO_V1(_rserv_debug_); ...@@ -19,15 +19,17 @@ PG_FUNCTION_INFO_V1(_rserv_debug_);
Datum _rserv_log_(PG_FUNCTION_ARGS); Datum _rserv_log_(PG_FUNCTION_ARGS);
Datum _rserv_sync_(PG_FUNCTION_ARGS); Datum _rserv_sync_(PG_FUNCTION_ARGS);
Datum _rserv_debug_(PG_FUNCTION_ARGS); Datum _rserv_debug_(PG_FUNCTION_ARGS);
#else #else
HeapTuple _rserv_log_(void); HeapTuple _rserv_log_(void);
int32 _rserv_sync_(int32); int32 _rserv_sync_(int32);
int32 _rserv_debug_(int32); int32 _rserv_debug_(int32);
#endif #endif
static int debug = 0; static int debug = 0;
static char* OutputValue(char *key, char *buf, int size); static char *OutputValue(char *key, char *buf, int size);
#ifdef PG_FUNCTION_INFO_V1 #ifdef PG_FUNCTION_INFO_V1
Datum Datum
...@@ -203,6 +205,7 @@ _rserv_sync_(int32 server) ...@@ -203,6 +205,7 @@ _rserv_sync_(int32 server)
{ {
#ifdef PG_FUNCTION_INFO_V1 #ifdef PG_FUNCTION_INFO_V1
int32 server = PG_GETARG_INT32(0); int32 server = PG_GETARG_INT32(0);
#endif #endif
char sql[8192]; char sql[8192];
char buf[8192]; char buf[8192];
...@@ -248,6 +251,7 @@ _rserv_debug_(int32 newval) ...@@ -248,6 +251,7 @@ _rserv_debug_(int32 newval)
{ {
#ifdef PG_FUNCTION_INFO_V1 #ifdef PG_FUNCTION_INFO_V1
int32 newval = PG_GETARG_INT32(0); int32 newval = PG_GETARG_INT32(0);
#endif #endif
int32 oldval = debug; int32 oldval = debug;
...@@ -258,7 +262,7 @@ _rserv_debug_(int32 newval) ...@@ -258,7 +262,7 @@ _rserv_debug_(int32 newval)
#define ExtendBy 1024 #define ExtendBy 1024
static char* static char *
OutputValue(char *key, char *buf, int size) OutputValue(char *key, char *buf, int size)
{ {
int i = 0; int i = 0;
...@@ -267,25 +271,31 @@ OutputValue(char *key, char *buf, int size) ...@@ -267,25 +271,31 @@ OutputValue(char *key, char *buf, int size)
int slen = 0; int slen = 0;
size--; size--;
for ( ; ; ) for (;;)
{ {
switch (*key) switch (*key)
{ {
case '\\': subst ="\\\\"; case '\\':
subst = "\\\\";
slen = 2; slen = 2;
break; break;
case ' ': subst = "\\011"; case ' ':
subst = "\\011";
slen = 4; slen = 4;
break; break;
case '\n': subst = "\\012"; case '\n':
subst = "\\012";
slen = 4; slen = 4;
break; break;
case '\'': subst = "\\047"; case '\'':
subst = "\\047";
slen = 4; slen = 4;
break; break;
case '\0': out[i] = 0; case '\0':
return(out); out[i] = 0;
default: slen = 1; return (out);
default:
slen = 1;
break; break;
} }
...@@ -293,13 +303,13 @@ OutputValue(char *key, char *buf, int size) ...@@ -293,13 +303,13 @@ OutputValue(char *key, char *buf, int size)
{ {
if (out == buf) if (out == buf)
{ {
out = (char*) palloc(size + ExtendBy); out = (char *) palloc(size + ExtendBy);
strncpy(out, buf, i); strncpy(out, buf, i);
size += ExtendBy; size += ExtendBy;
} }
else else
{ {
out = (char*) repalloc(out, size + ExtendBy); out = (char *) repalloc(out, size + ExtendBy);
size += ExtendBy; size += ExtendBy;
} }
} }
...@@ -314,6 +324,6 @@ OutputValue(char *key, char *buf, int size) ...@@ -314,6 +324,6 @@ OutputValue(char *key, char *buf, int size)
key++; key++;
} }
return(out); return (out);
} }
...@@ -4,76 +4,81 @@ ...@@ -4,76 +4,81 @@
#include "utils/elog.h" #include "utils/elog.h"
static char * PARSE_BUFFER; static char *PARSE_BUFFER;
static char * PARSE_BUFFER_PTR; static char *PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE; static unsigned int PARSE_BUFFER_SIZE;
static unsigned int SCANNER_POS; static unsigned int SCANNER_POS;
void set_parse_buffer( char* s ); void set_parse_buffer(char *s);
void reset_parse_buffer( void ); void reset_parse_buffer(void);
int read_parse_buffer( void ); int read_parse_buffer(void);
char * parse_buffer( void ); char *parse_buffer(void);
char * parse_buffer_ptr( void ); char *parse_buffer_ptr(void);
unsigned int parse_buffer_curr_char( void ); unsigned int parse_buffer_curr_char(void);
unsigned int parse_buffer_size( void ); unsigned int parse_buffer_size(void);
unsigned int parse_buffer_pos( void ); unsigned int parse_buffer_pos(void);
extern void seg_flush_scanner_buffer(void); /* defined in segscan.l */ extern void seg_flush_scanner_buffer(void); /* defined in segscan.l */
void set_parse_buffer( char* s ) void
set_parse_buffer(char *s)
{ {
PARSE_BUFFER = s; PARSE_BUFFER = s;
PARSE_BUFFER_SIZE = strlen(s); PARSE_BUFFER_SIZE = strlen(s);
if ( PARSE_BUFFER_SIZE == 0 ) { if (PARSE_BUFFER_SIZE == 0)
elog(ERROR, "seg_in: can't parse an empty string"); elog(ERROR, "seg_in: can't parse an empty string");
}
PARSE_BUFFER_PTR = PARSE_BUFFER; PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0; SCANNER_POS = 0;
} }
void reset_parse_buffer( void ) void
reset_parse_buffer(void)
{ {
PARSE_BUFFER_PTR = PARSE_BUFFER; PARSE_BUFFER_PTR = PARSE_BUFFER;
SCANNER_POS = 0; SCANNER_POS = 0;
seg_flush_scanner_buffer(); seg_flush_scanner_buffer();
} }
int read_parse_buffer( void ) int
read_parse_buffer(void)
{ {
int c; int c;
/* /*
c = *PARSE_BUFFER_PTR++; * c = *PARSE_BUFFER_PTR++; SCANNER_POS++;
SCANNER_POS++;
*/ */
c = PARSE_BUFFER[SCANNER_POS]; c = PARSE_BUFFER[SCANNER_POS];
if(SCANNER_POS < PARSE_BUFFER_SIZE) if (SCANNER_POS < PARSE_BUFFER_SIZE)
SCANNER_POS++; SCANNER_POS++;
return c; return c;
} }
char * parse_buffer( void ) char *
parse_buffer(void)
{ {
return PARSE_BUFFER; return PARSE_BUFFER;
} }
unsigned int parse_buffer_curr_char( void ) unsigned int
parse_buffer_curr_char(void)
{ {
return PARSE_BUFFER[SCANNER_POS]; return PARSE_BUFFER[SCANNER_POS];
} }
char * parse_buffer_ptr( void ) char *
parse_buffer_ptr(void)
{ {
return PARSE_BUFFER_PTR; return PARSE_BUFFER_PTR;
} }
unsigned int parse_buffer_pos( void ) unsigned int
parse_buffer_pos(void)
{ {
return SCANNER_POS; return SCANNER_POS;
} }
unsigned int parse_buffer_size( void ) unsigned int
parse_buffer_size(void)
{ {
return PARSE_BUFFER_SIZE; return PARSE_BUFFER_SIZE;
} }
extern void set_parse_buffer( char* s ); extern void set_parse_buffer(char *s);
extern void reset_parse_buffer( void ); extern void reset_parse_buffer(void);
extern int read_parse_buffer( void ); extern int read_parse_buffer(void);
extern char * parse_buffer( void ); extern char *parse_buffer(void);
extern char * parse_buffer_ptr( void ); extern char *parse_buffer_ptr(void);
extern unsigned int parse_buffer_curr_char( void ); extern unsigned int parse_buffer_curr_char(void);
extern unsigned int parse_buffer_pos( void ); extern unsigned int parse_buffer_pos(void);
extern unsigned int parse_buffer_size( void ); extern unsigned int parse_buffer_size(void);
This diff is collapsed.
typedef struct SEG { typedef struct SEG
{
float lower; float lower;
float upper; float upper;
char l_sigd; char l_sigd;
......
/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.10 2001/02/10 02:31:26 tgl Exp $ */ /* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.11 2001/03/22 03:59:10 momjian Exp $ */
#include "postgres.h" #include "postgres.h"
#include <ctype.h> #include <ctype.h>
...@@ -42,6 +42,7 @@ text_soundex(PG_FUNCTION_ARGS) ...@@ -42,6 +42,7 @@ text_soundex(PG_FUNCTION_ARGS)
/* ABCDEFGHIJKLMNOPQRSTUVWXYZ */ /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
static const char *soundex_table = "01230120022455012623010202"; static const char *soundex_table = "01230120022455012623010202";
#define soundex_code(letter) soundex_table[toupper((unsigned char) (letter)) - 'A'] #define soundex_code(letter) soundex_table[toupper((unsigned char) (letter)) - 'A']
...@@ -98,7 +99,7 @@ soundex(const char *instr, char *outstr) ...@@ -98,7 +99,7 @@ soundex(const char *instr, char *outstr)
#ifdef SOUNDEX_TEST #ifdef SOUNDEX_TEST
int int
main (int argc, char *argv[]) main(int argc, char *argv[])
{ {
if (argc < 2) if (argc < 2)
{ {
...@@ -114,4 +115,5 @@ main (int argc, char *argv[]) ...@@ -114,4 +115,5 @@ main (int argc, char *argv[])
return 0; return 0;
} }
} }
#endif /* SOUNDEX_TEST */ #endif /* SOUNDEX_TEST */
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.8 2001/01/24 19:42:45 momjian Exp $ * $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.9 2001/03/22 03:59:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -76,6 +76,7 @@ vacuumlo(char *database, int verbose) ...@@ -76,6 +76,7 @@ vacuumlo(char *database, int verbose)
return -1; return -1;
} }
PQclear(res); PQclear(res);
/* /*
* Vacuum the temp table so that planner will generate decent plans * Vacuum the temp table so that planner will generate decent plans
* for the DELETEs below. * for the DELETEs below.
...@@ -96,13 +97,13 @@ vacuumlo(char *database, int verbose) ...@@ -96,13 +97,13 @@ vacuumlo(char *database, int verbose)
/* /*
* Now find any candidate tables who have columns of type oid. * Now find any candidate tables who have columns of type oid.
* *
* NOTE: the temp table formed above is ignored, because its real * NOTE: the temp table formed above is ignored, because its real table
* table name will be pg_something. Also, pg_largeobject will be * name will be pg_something. Also, pg_largeobject will be ignored.
* ignored. If either of these were scanned, obviously we'd end up * If either of these were scanned, obviously we'd end up with nothing
* with nothing to delete... * to delete...
* *
* NOTE: the system oid column is ignored, as it has attnum < 1. * NOTE: the system oid column is ignored, as it has attnum < 1. This
* This shouldn't matter for correctness, but it saves time. * shouldn't matter for correctness, but it saves time.
*/ */
buf[0] = '\0'; buf[0] = '\0';
strcat(buf, "SELECT c.relname, a.attname "); strcat(buf, "SELECT c.relname, a.attname ");
...@@ -135,9 +136,9 @@ vacuumlo(char *database, int verbose) ...@@ -135,9 +136,9 @@ vacuumlo(char *database, int verbose)
fprintf(stdout, "Checking %s in %s\n", field, table); fprintf(stdout, "Checking %s in %s\n", field, table);
/* /*
* We use a DELETE with implicit join for efficiency. This * We use a DELETE with implicit join for efficiency. This is a
* is a Postgres-ism and not portable to other DBMSs, but * Postgres-ism and not portable to other DBMSs, but then this
* then this whole program is a Postgres-ism. * whole program is a Postgres-ism.
*/ */
sprintf(buf, "DELETE FROM vacuum_l WHERE lo = \"%s\".\"%s\" ", sprintf(buf, "DELETE FROM vacuum_l WHERE lo = \"%s\".\"%s\" ",
table, field); table, field);
...@@ -159,8 +160,8 @@ vacuumlo(char *database, int verbose) ...@@ -159,8 +160,8 @@ vacuumlo(char *database, int verbose)
/* /*
* Run the actual deletes in a single transaction. Note that this * Run the actual deletes in a single transaction. Note that this
* would be a bad idea in pre-7.1 Postgres releases (since rolling * would be a bad idea in pre-7.1 Postgres releases (since rolling
* back a table delete used to cause problems), but it should * back a table delete used to cause problems), but it should be safe
* be safe now. * now.
*/ */
res = PQexec(conn, "begin"); res = PQexec(conn, "begin");
PQclear(res); PQclear(res);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.69 2001/01/24 19:42:46 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.70 2001/03/22 03:59:11 momjian Exp $
* *
* NOTES * NOTES
* The old interface functions have been converted to macros * The old interface functions have been converted to macros
...@@ -306,8 +306,8 @@ nocachegetattr(HeapTuple tuple, ...@@ -306,8 +306,8 @@ nocachegetattr(HeapTuple tuple,
int j; int j;
/* /*
* In for(), we test <= and not < because we want to see * In for(), we test <= and not < because we want to see if we
* if we can go past it in initializing offsets. * can go past it in initializing offsets.
*/ */
for (j = 0; j <= attnum; j++) for (j = 0; j <= attnum; j++)
{ {
...@@ -321,9 +321,9 @@ nocachegetattr(HeapTuple tuple, ...@@ -321,9 +321,9 @@ nocachegetattr(HeapTuple tuple,
} }
/* /*
* If slow is false, and we got here, we know that we have a tuple with * If slow is false, and we got here, we know that we have a tuple
* no nulls or varlenas before the target attribute. If possible, we * with no nulls or varlenas before the target attribute. If possible,
* also want to initialize the remainder of the attribute cached * we also want to initialize the remainder of the attribute cached
* offset values. * offset values.
*/ */
if (!slow) if (!slow)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.52 2001/02/22 21:48:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.53 2001/03/22 03:59:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -45,9 +45,11 @@ index_formtuple(TupleDesc tupleDescriptor, ...@@ -45,9 +45,11 @@ index_formtuple(TupleDesc tupleDescriptor,
bool hasnull = false; bool hasnull = false;
uint16 tupmask = 0; uint16 tupmask = 0;
int numberOfAttributes = tupleDescriptor->natts; int numberOfAttributes = tupleDescriptor->natts;
#ifdef TOAST_INDEX_HACK #ifdef TOAST_INDEX_HACK
Datum untoasted_value[INDEX_MAX_KEYS]; Datum untoasted_value[INDEX_MAX_KEYS];
bool untoasted_free[INDEX_MAX_KEYS]; bool untoasted_free[INDEX_MAX_KEYS];
#endif #endif
if (numberOfAttributes > INDEX_MAX_KEYS) if (numberOfAttributes > INDEX_MAX_KEYS)
...@@ -79,8 +81,8 @@ index_formtuple(TupleDesc tupleDescriptor, ...@@ -79,8 +81,8 @@ index_formtuple(TupleDesc tupleDescriptor,
} }
/* /*
* If value is above size target, and is of a compressible datatype, * If value is above size target, and is of a compressible
* try to compress it in-line. * datatype, try to compress it in-line.
*/ */
if (VARATT_SIZE(untoasted_value[i]) > TOAST_INDEX_TARGET && if (VARATT_SIZE(untoasted_value[i]) > TOAST_INDEX_TARGET &&
!VARATT_IS_EXTENDED(untoasted_value[i]) && !VARATT_IS_EXTENDED(untoasted_value[i]) &&
...@@ -146,8 +148,8 @@ index_formtuple(TupleDesc tupleDescriptor, ...@@ -146,8 +148,8 @@ index_formtuple(TupleDesc tupleDescriptor,
/* /*
* We do this because DataFill wants to initialize a "tupmask" which * We do this because DataFill wants to initialize a "tupmask" which
* is used for HeapTuples, but we want an indextuple infomask. The * is used for HeapTuples, but we want an indextuple infomask. The
* only relevant info is the "has variable attributes" field. * only relevant info is the "has variable attributes" field. We have
* We have already set the hasnull bit above. * already set the hasnull bit above.
*/ */
if (tupmask & HEAP_HASVARLENA) if (tupmask & HEAP_HASVARLENA)
...@@ -315,9 +317,9 @@ nocache_index_getattr(IndexTuple tup, ...@@ -315,9 +317,9 @@ nocache_index_getattr(IndexTuple tup,
} }
/* /*
* If slow is false, and we got here, we know that we have a tuple with * If slow is false, and we got here, we know that we have a tuple
* no nulls or varlenas before the target attribute. If possible, we * with no nulls or varlenas before the target attribute. If possible,
* also want to initialize the remainder of the attribute cached * we also want to initialize the remainder of the attribute cached
* offset values. * offset values.
*/ */
if (!slow) if (!slow)
...@@ -391,10 +393,8 @@ nocache_index_getattr(IndexTuple tup, ...@@ -391,10 +393,8 @@ nocache_index_getattr(IndexTuple tup,
usecache = false; usecache = false;
} }
else else
{
off += att[i]->attlen; off += att[i]->attlen;
} }
}
off = att_align(off, att[attnum]->attlen, att[attnum]->attalign); off = att_align(off, att[attnum]->attlen, att[attnum]->attalign);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.57 2001/01/24 19:42:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.58 2001/03/22 03:59:11 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -51,7 +51,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem, ...@@ -51,7 +51,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
*typOutput = pt->typoutput; *typOutput = pt->typoutput;
*typElem = pt->typelem; *typElem = pt->typelem;
*typIsVarlena = (! pt->typbyval) && (pt->typlen == -1); *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
return OidIsValid(*typOutput); return OidIsValid(*typOutput);
} }
...@@ -200,9 +200,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -200,9 +200,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
continue; continue;
if (OidIsValid(thisState->typoutput)) if (OidIsValid(thisState->typoutput))
{ {
/* /*
* If we have a toasted datum, forcibly detoast it here to avoid * If we have a toasted datum, forcibly detoast it here to
* memory leakage inside the type's output routine. * avoid memory leakage inside the type's output routine.
*/ */
if (thisState->typisvarlena) if (thisState->typisvarlena)
attr = PointerGetDatum(PG_DETOAST_DATUM(origattr)); attr = PointerGetDatum(PG_DETOAST_DATUM(origattr));
...@@ -308,9 +309,10 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -308,9 +309,10 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
if (getTypeOutputInfo(typeinfo->attrs[i]->atttypid, if (getTypeOutputInfo(typeinfo->attrs[i]->atttypid,
&typoutput, &typelem, &typisvarlena)) &typoutput, &typelem, &typisvarlena))
{ {
/* /*
* If we have a toasted datum, forcibly detoast it here to avoid * If we have a toasted datum, forcibly detoast it here to
* memory leakage inside the type's output routine. * avoid memory leakage inside the type's output routine.
*/ */
if (typisvarlena) if (typisvarlena)
attr = PointerGetDatum(PG_DETOAST_DATUM(origattr)); attr = PointerGetDatum(PG_DETOAST_DATUM(origattr));
...@@ -405,6 +407,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -405,6 +407,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
/* send # of bytes, and opaque data */ /* send # of bytes, and opaque data */
if (thisState->typisvarlena) if (thisState->typisvarlena)
{ {
/* /*
* If we have a toasted datum, must detoast before sending. * If we have a toasted datum, must detoast before sending.
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.71 2001/01/24 19:42:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.72 2001/03/22 03:59:11 momjian Exp $
* *
* NOTES * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
...@@ -242,9 +242,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) ...@@ -242,9 +242,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
/* /*
* We do not need to check every single field here, and in fact * We do not need to check every single field here, and in fact
* some fields such as attdispersion probably shouldn't be * some fields such as attdispersion probably shouldn't be
* compared. We can also disregard attnum (it was used to * compared. We can also disregard attnum (it was used to place
* place the row in the attrs array) and everything derived * the row in the attrs array) and everything derived from the
* from the column datatype. * column datatype.
*/ */
if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0) if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
return false; return false;
...@@ -276,8 +276,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) ...@@ -276,8 +276,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
/* /*
* We can't assume that the items are always read from the * We can't assume that the items are always read from the
* system catalogs in the same order; so use the adnum field to * system catalogs in the same order; so use the adnum field
* identify the matching item to compare. * to identify the matching item to compare.
*/ */
for (j = 0; j < n; defval2++, j++) for (j = 0; j < n; defval2++, j++)
{ {
...@@ -298,9 +298,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) ...@@ -298,9 +298,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
ConstrCheck *check2 = constr2->check; ConstrCheck *check2 = constr2->check;
/* /*
* Similarly, don't assume that the checks are always read * Similarly, don't assume that the checks are always read in
* in the same order; match them up by name and contents. * the same order; match them up by name and contents. (The
* (The name *should* be unique, but...) * name *should* be unique, but...)
*/ */
for (j = 0; j < n; check2++, j++) for (j = 0; j < n; check2++, j++)
{ {
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.49 2001/02/22 21:48:49 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.50 2001/03/22 03:59:12 momjian Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
...@@ -45,8 +45,10 @@ hashbuild(PG_FUNCTION_ARGS) ...@@ -45,8 +45,10 @@ hashbuild(PG_FUNCTION_ARGS)
Relation index = (Relation) PG_GETARG_POINTER(1); Relation index = (Relation) PG_GETARG_POINTER(1);
IndexInfo *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2); IndexInfo *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2);
Node *oldPred = (Node *) PG_GETARG_POINTER(3); Node *oldPred = (Node *) PG_GETARG_POINTER(3);
#ifdef NOT_USED #ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4); IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4);
#endif #endif
HeapScanDesc hscan; HeapScanDesc hscan;
HeapTuple htup; HeapTuple htup;
...@@ -59,9 +61,11 @@ hashbuild(PG_FUNCTION_ARGS) ...@@ -59,9 +61,11 @@ hashbuild(PG_FUNCTION_ARGS)
nitups; nitups;
HashItem hitem; HashItem hitem;
Node *pred = indexInfo->ii_Predicate; Node *pred = indexInfo->ii_Predicate;
#ifndef OMIT_PARTIAL_INDEX #ifndef OMIT_PARTIAL_INDEX
TupleTable tupleTable; TupleTable tupleTable;
TupleTableSlot *slot; TupleTableSlot *slot;
#endif #endif
ExprContext *econtext; ExprContext *econtext;
InsertIndexResult res = NULL; InsertIndexResult res = NULL;
...@@ -117,6 +121,7 @@ hashbuild(PG_FUNCTION_ARGS) ...@@ -117,6 +121,7 @@ hashbuild(PG_FUNCTION_ARGS)
nhtups++; nhtups++;
#ifndef OMIT_PARTIAL_INDEX #ifndef OMIT_PARTIAL_INDEX
/* /*
* If oldPred != NULL, this is an EXTEND INDEX command, so skip * If oldPred != NULL, this is an EXTEND INDEX command, so skip
* this tuple if it was already in the existing partial index * this tuple if it was already in the existing partial index
...@@ -191,9 +196,7 @@ hashbuild(PG_FUNCTION_ARGS) ...@@ -191,9 +196,7 @@ hashbuild(PG_FUNCTION_ARGS)
#ifndef OMIT_PARTIAL_INDEX #ifndef OMIT_PARTIAL_INDEX
if (pred != NULL || oldPred != NULL) if (pred != NULL || oldPred != NULL)
{
ExecDropTupleTable(tupleTable, true); ExecDropTupleTable(tupleTable, true);
}
#endif /* OMIT_PARTIAL_INDEX */ #endif /* OMIT_PARTIAL_INDEX */
FreeExprContext(econtext); FreeExprContext(econtext);
...@@ -245,8 +248,10 @@ hashinsert(PG_FUNCTION_ARGS) ...@@ -245,8 +248,10 @@ hashinsert(PG_FUNCTION_ARGS)
Datum *datum = (Datum *) PG_GETARG_POINTER(1); Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2); char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3); ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
#ifdef NOT_USED #ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4); Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif #endif
InsertIndexResult res; InsertIndexResult res;
HashItem hitem; HashItem hitem;
...@@ -327,8 +332,10 @@ Datum ...@@ -327,8 +332,10 @@ Datum
hashrescan(PG_FUNCTION_ARGS) hashrescan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0); IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
#ifdef NOT_USED /* XXX surely it's wrong to ignore this? */ #ifdef NOT_USED /* XXX surely it's wrong to ignore this? */
bool fromEnd = PG_GETARG_BOOL(1); bool fromEnd = PG_GETARG_BOOL(1);
#endif #endif
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2); ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2);
ItemPointer iptr; ItemPointer iptr;
...@@ -493,6 +500,6 @@ hash_undo(XLogRecPtr lsn, XLogRecord *record) ...@@ -493,6 +500,6 @@ hash_undo(XLogRecPtr lsn, XLogRecord *record)
} }
void void
hash_desc(char *buf, uint8 xl_info, char* rec) hash_desc(char *buf, uint8 xl_info, char *rec)
{ {
} }
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Id: hio.c,v 1.35 2001/01/24 19:42:48 momjian Exp $ * $Id: hio.c,v 1.36 2001/03/22 03:59:13 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -92,7 +92,7 @@ RelationGetBufferForTuple(Relation relation, Size len) ...@@ -92,7 +92,7 @@ RelationGetBufferForTuple(Relation relation, Size len)
*/ */
if (len > MaxTupleSize) if (len > MaxTupleSize)
elog(ERROR, "Tuple is too big: size %lu, max size %ld", elog(ERROR, "Tuple is too big: size %lu, max size %ld",
(unsigned long)len, MaxTupleSize); (unsigned long) len, MaxTupleSize);
if (!relation->rd_myxactonly) if (!relation->rd_myxactonly)
LockPage(relation, 0, ExclusiveLock); LockPage(relation, 0, ExclusiveLock);
...@@ -140,13 +140,13 @@ RelationGetBufferForTuple(Relation relation, Size len) ...@@ -140,13 +140,13 @@ RelationGetBufferForTuple(Relation relation, Size len)
{ {
/* We should not get here given the test at the top */ /* We should not get here given the test at the top */
elog(STOP, "Tuple is too big: size %lu", elog(STOP, "Tuple is too big: size %lu",
(unsigned long)len); (unsigned long) len);
} }
} }
if (!relation->rd_myxactonly) if (!relation->rd_myxactonly)
UnlockPage(relation, 0, ExclusiveLock); UnlockPage(relation, 0, ExclusiveLock);
return(buffer); return (buffer);
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.24 2001/01/24 19:42:49 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.25 2001/03/22 03:59:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.35 2001/01/24 19:42:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.36 2001/03/22 03:59:16 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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