New column page

Shows SQL for columns ALTER TABLE ... [ADD|DROP] COLUMN combines a selection
of multiple columns into a single alter table.
Show collation in list of columns.

(order of columns isn't what is should be but that should maybe be fixed
by a generic column selection and ordering mechanism that knows what the
default sort should be)
This commit is contained in:
eelke 2018-11-29 20:21:36 +01:00
parent 73c4cf4790
commit 57217974f4
19 changed files with 345 additions and 55 deletions

View file

@ -6,11 +6,13 @@
#include <libpq-fe.h>
#include <tuple>
class PgClass;
class PgDatabaseCatalog;
class PgAttribute {
public:
using Key = std::tuple<Oid, int16_t>;
// Oid oid = InvalidOid;
Oid relid = InvalidOid;
QString name;
Oid typid = InvalidOid;
@ -20,6 +22,7 @@ public:
int32_t typmod = -1;
bool notnull = false;
bool hasdef = false;
char identity = ' ';
bool isdropped = false;
Oid collation = InvalidOid;
QString acl;
@ -33,6 +36,10 @@ public:
bool operator<(Key _k) const { return relid < std::get<0>(_k) || (relid == std::get<0>(_k) && num < std::get<1>(_k)); }
bool operator<(const PgAttribute &rhs) const { return relid < rhs.relid || (relid == rhs.relid && num < rhs.num); }
/// Return the part of the SQL create statement that can be reused for both the CREATE TABLE and ALTER TABLE ADD COLUMN
QString columnDefinition(const PgDatabaseCatalog &cat) const;
QString alterTableAddColumn(const PgDatabaseCatalog &cat, const PgClass &table) const;
QString alterTableDropColumn(const PgDatabaseCatalog &cat, const PgClass &table) const;
};
#endif // PGATTRIBUTE_H