mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
add generate and identity columns
add generate and identity columns add storage opts for PG12
This commit is contained in:
parent
9b97fa1dcf
commit
b60012df15
5 changed files with 61 additions and 4 deletions
|
|
@ -112,6 +112,10 @@ This text Russian language.
|
|||
* исправлено падение в режиме редактирования
|
||||
* исправлено редактирование процедур без аргументов
|
||||
|
||||
15.04.2020
|
||||
* в окне SQL инструкции создания таблицы теперь отображаются новые параметры хранения
|
||||
* в описании колонок учтены generated и identity колонки
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -237,6 +237,22 @@ public:
|
|||
{
|
||||
serialSchema = s;
|
||||
}
|
||||
wxString GetGenerated() const
|
||||
{
|
||||
return generated;
|
||||
}
|
||||
void iSetGenerated(const wxString &s)
|
||||
{
|
||||
generated = s;
|
||||
}
|
||||
wxString GetIdentity() const
|
||||
{
|
||||
return identity;
|
||||
}
|
||||
void iSetIdentity(const wxString &s)
|
||||
{
|
||||
identity = s;
|
||||
}
|
||||
void iSetPkCols(const wxString &s)
|
||||
{
|
||||
pkCols = s;
|
||||
|
|
@ -299,7 +315,7 @@ public:
|
|||
|
||||
private:
|
||||
wxString varTypename, quotedTypename, defaultVal, tableName, quotedFullTable, defaultStorage, storage, rawTypename;
|
||||
wxString serialSequence, serialSchema, pkCols, inheritedTableName, collation;
|
||||
wxString serialSequence, serialSchema, pkCols, inheritedTableName, collation, generated, identity;
|
||||
long colNumber, length, precision, statistics, attstattarget;
|
||||
long typlen, typmod, inheritedCount;
|
||||
bool isPK, isFK, notNull, isArray, isLocal;
|
||||
|
|
|
|||
|
|
@ -410,7 +410,14 @@ wxString pgColumn::GetDefinition()
|
|||
{
|
||||
if (GetNotNull())
|
||||
sql += wxT(" NOT NULL");
|
||||
AppendIfFilled(sql, wxT(" DEFAULT "), GetDefault());
|
||||
if (!GetGenerated().IsEmpty()) {
|
||||
if (GetGenerated()=="s") sql+= " GENERATED ALWAYS AS " + GetDefault() + " STORED";
|
||||
} else if (!GetIdentity().IsEmpty()) {
|
||||
if (GetIdentity()=="a") sql+= " GENERATED ALWAYS AS IDENTITY";
|
||||
if (GetIdentity()=="d") sql+= " GENERATED BY DEFAULT AS IDENTITY" ;
|
||||
}
|
||||
else
|
||||
AppendIfFilled(sql, wxT(" DEFAULT "), GetDefault());
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
|
@ -618,7 +625,7 @@ pgObject *pgColumnFactory::CreateObjects(pgCollection *coll, ctlTree *browser, c
|
|||
sql += wxT(",\n(SELECT array_agg(label) FROM pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS labels");
|
||||
sql += wxT(",\n(SELECT array_agg(provider) FROM pg_seclabels sl2 WHERE sl2.objoid=att.attrelid AND sl2.objsubid=att.attnum) AS providers");
|
||||
}
|
||||
|
||||
|
||||
sql += wxT("\n")
|
||||
wxT(" FROM pg_attribute att\n")
|
||||
wxT(" JOIN pg_type ty ON ty.oid=atttypid\n")
|
||||
|
|
@ -653,6 +660,17 @@ pgObject *pgColumnFactory::CreateObjects(pgCollection *coll, ctlTree *browser, c
|
|||
column->iSetComment(columns->GetVal(wxT("description")));
|
||||
column->iSetSerialSequence(columns->GetVal(wxT("sername")));
|
||||
column->iSetSerialSchema(columns->GetVal(wxT("serschema")));
|
||||
if (database->BackendMinimumVersion(10, 0))
|
||||
{
|
||||
column->iSetIdentity(columns->GetVal(wxT("attidentity")));
|
||||
};
|
||||
if (database->BackendMinimumVersion(12, 0))
|
||||
{
|
||||
column->iSetGenerated(columns->GetVal(wxT("attgenerated")));
|
||||
};
|
||||
|
||||
|
||||
|
||||
column->iSetPkCols(columns->GetVal(wxT("indkey")));
|
||||
if (database->BackendMinimumVersion(7, 4))
|
||||
column->iSetIsFK(columns->GetBool(wxT("isfk")));
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "schema/pgConstraints.h"
|
||||
#include "schema/gpPartition.h"
|
||||
#include "schema/pgPartition.h"
|
||||
|
||||
#include <wx/regex.h>
|
||||
|
||||
// App headers
|
||||
|
||||
|
|
@ -618,6 +618,25 @@ wxString pgTable::GetSql(ctlTree *browser)
|
|||
}
|
||||
}
|
||||
}
|
||||
wxRegEx reg("vacuum_index_cleanup=[a-z]+|vacuum_truncate=[a-z]+|parallel_workers=[0-9]+|toast_tuple_target=[0-9]+|log_autovacuum_min_duration=[0-9]+|user_catalog_table=[a-z]+");
|
||||
wxString relopt=GetRelOptions();
|
||||
wxString o;
|
||||
size_t start, len;
|
||||
while ( reg.Matches(relopt) )
|
||||
{
|
||||
reg.GetMatch(&start, &len, 0);
|
||||
o=reg.GetMatch(relopt, 0);
|
||||
AppendIfFilled(sqlopt, ",\n ", o);
|
||||
relopt = relopt.Mid (start + len);
|
||||
}
|
||||
relopt=GetToastRelOptions();
|
||||
while ( reg.Matches(relopt) )
|
||||
{
|
||||
reg.GetMatch(&start, &len, 0);
|
||||
o="toast." + reg.GetMatch(relopt, 0);
|
||||
AppendIfFilled(sqlopt, ",\n ", o);
|
||||
relopt = relopt.Mid (start + len);
|
||||
}
|
||||
if (!sqlopt.IsEmpty()) {
|
||||
sql += wxT("\nWITH (");
|
||||
if (sqlopt.Index(',')==0) sqlopt=sqlopt.Mid(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue