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

pgindent run. Make it all clean.

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