Fix data corruption bug reported by robjderr (#1010664).

pg_reorg broke catalog definition if the target table had any dropped columns.
Now pg_reorg removes dropped columns and renumbers valid columns.
You can use pg_reorg to shrink column definitions if you have many dropped
columns. (without pg_reorg, dropped columns are filled with zero forever)
This commit is contained in:
Takahiro Itagaki
2009-07-02 09:50:58 +00:00
parent 5fe3f037be
commit 6155932b60
10 changed files with 251 additions and 136 deletions

View File

@ -13,6 +13,7 @@
#include "libpq-fe.h"
#include "pqexpbuffer.h"
#include <assert.h>
#include <getopt.h>
#if !defined(C_H) && !defined(__cplusplus)
@ -51,6 +52,7 @@ extern const char *port;
extern const char *username;
extern bool password;
extern bool debug;
extern bool quiet;
extern PGconn *connection;
extern bool interrupted;
@ -58,6 +60,8 @@ extern bool interrupted;
extern void parse_options(int argc, char **argv);
extern bool assign_option(const char **value, int c, const char *arg);
extern PGconn *reconnect_elevel(int elevel);
extern void reconnect(void);
extern void disconnect(void);
extern PGresult *execute_elevel(const char *query, int nParams, const char **params, int elevel);
@ -68,6 +72,15 @@ extern void command(const char *query, int nParams, const char **params);
extern unsigned int sleep(unsigned int seconds);
#endif
/*
* IsXXX
*/
#define IsSpace(c) (isspace((unsigned char)(c)))
#define IsAlpha(c) (isalpha((unsigned char)(c)))
#define IsAlnum(c) (isalnum((unsigned char)(c)))
#define IsIdentHead(c) (IsAlpha(c) || (c) == '_')
#define IsIdentBody(c) (IsAlnum(c) || (c) == '_')
/*
* elog
*/
@ -104,6 +117,20 @@ __attribute__((format(printf, 2, 3)));
#define appendStringInfoChar appendPQExpBufferChar
#define appendBinaryStringInfo appendBinaryPQExpBuffer
/*
* Assert
*/
#undef Assert
#undef AssertMacro
#ifdef USE_ASSERT_CHECKING
#define Assert(x) assert(x)
#define AssertMacro(x) assert(x)
#else
#define Assert(x) ((void) 0)
#define AssertMacro(x) ((void) 0)
#endif
/*
* import from postgres.h and catalog/genbki.h in 8.4
*/
@ -124,3 +151,4 @@ typedef int aclitem;
#endif
#endif /* PGUT_H */