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

@ -1,5 +1,6 @@
#include "PgAttributeContainer.h"
#include "Pgsql_Col.h"
#include "PgDatabaseCatalog.h"
//SELECT attname, pg_get_expr(adbin, adrelid) AS def_value
//FROM pg_attribute
@ -8,12 +9,16 @@
std::string PgAttributeContainer::getLoadQuery() const
{
return R"__(
std::string q = R"__(
SELECT attrelid, attname, atttypid, attstattarget,
attnum, attndims, atttypmod, attnotnull, atthasdef, attisdropped,
attcollation, attacl, attoptions, pg_get_expr(adbin, adrelid) AS def_value
FROM pg_catalog.pg_attribute
LEFT JOIN pg_attrdef ON attrelid=adrelid AND attnum=adnum)__";
attcollation, attacl, attoptions, pg_get_expr(adbin, adrelid) AS def_value)__";
if (m_catalog.serverVersion() >= 100000)
q += ", attidentity";
q +=
"\n FROM pg_catalog.pg_attribute \n"
" LEFT JOIN pg_attrdef ON attrelid=adrelid AND attnum=adnum";
return q;
}
PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
@ -23,6 +28,9 @@ PgAttribute PgAttributeContainer::loadElem(const Pgsql::Row &row)
col >> v.relid >> v.name >> v.typid >> v.stattarget
>> v.num >> v.ndims >> v.typmod >> v.notnull >> v.hasdef >> v.isdropped
>> v.collation >> v.acl >> v.options >> v.defaultValue;
if (m_catalog.serverVersion() >= 100000)
col >> v.identity;
return v;
}