From 0caf3dbf7fd0df200fa02f850ff18b9ab463457d Mon Sep 17 00:00:00 2001 From: lsv Date: Tue, 15 Aug 2023 20:40:22 +0500 Subject: [PATCH] STORAGE clause support, COMPRESS clause support --- db/keywords.c | 2 +- include/schema/pgColumn.h | 10 +++++++++- schema/pgColumn.cpp | 19 ++++++++++++++++++- schema/pgTable.cpp | 3 ++- ui/xrcDialogs.cpp | 39 +++++++++++++++++++++++++++++---------- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/db/keywords.c b/db/keywords.c index 0a14d40..5c0b3e8 100644 --- a/db/keywords.c +++ b/db/keywords.c @@ -28,7 +28,7 @@ /* * List of (keyword-name, keyword-token-value) pairs. */ -#define PG_KEYWORD(a,b,c) {a,c}, +#define PG_KEYWORD(a,b,c,d) {a,c}, const ScanKeyword ScanKeywords[] = { #ifdef WIN32 diff --git a/include/schema/pgColumn.h b/include/schema/pgColumn.h index 103b921..9dcd36f 100644 --- a/include/schema/pgColumn.h +++ b/include/schema/pgColumn.h @@ -245,6 +245,14 @@ public: { generated = s; } + void iSetCompression(const wxString& s) + { + compression = s; + } + wxString GetCompression() const + { + return compression == "p" ? "pglz" : (compression == "l" ? "lz4" : ""); + } wxString GetIdentity() const { return identity; @@ -315,7 +323,7 @@ public: private: wxString varTypename, quotedTypename, defaultVal, tableName, quotedFullTable, defaultStorage, storage, rawTypename; - wxString serialSequence, serialSchema, pkCols, inheritedTableName, collation, generated, identity; + wxString serialSequence, serialSchema, pkCols, inheritedTableName, collation, generated, identity, compression; long colNumber, length, precision, statistics, attstattarget; long typlen, typmod, inheritedCount; bool isPK, isFK, notNull, isArray, isLocal; diff --git a/schema/pgColumn.cpp b/schema/pgColumn.cpp index 64f99b2..5d46052 100644 --- a/schema/pgColumn.cpp +++ b/schema/pgColumn.cpp @@ -314,6 +314,18 @@ wxString pgColumn::GetDefinition() if (table->GetOfTypeOid() == 0) sql += GetQuotedTypename(); + if (GetDatabase()->BackendMinimumVersion(16, 0)) + { + if (GetStorage() != GetDefaultStorage()) + sql += " STORAGE " + GetStorage(); + } + if (GetDatabase()->BackendMinimumVersion(14, 0)) + { + wxString cmp = GetCompression(); + if (!cmp.IsEmpty()) + sql += " COMPRESSION " + GetCompression(); + } + if (!GetCollation().IsEmpty() && GetCollation() != wxT("pg_catalog.\"default\"")) sql += wxT(" COLLATE ") + GetCollation(); @@ -668,7 +680,12 @@ pgObject *pgColumnFactory::CreateObjects(pgCollection *coll, ctlTree *browser, c { column->iSetGenerated(columns->GetVal(wxT("attgenerated"))); }; - + if (database->BackendMinimumVersion(14, 0)) + { + wxString compres = columns->GetVal(wxT("attcompression")); + column->iSetCompression(compres); + } + column->iSetPkCols(columns->GetVal(wxT("indkey"))); diff --git a/schema/pgTable.cpp b/schema/pgTable.cpp index 21ec1bc..4189150 100644 --- a/schema/pgTable.cpp +++ b/schema/pgTable.cpp @@ -422,7 +422,8 @@ wxString pgTable::GetSql(ctlTree *browser) if (colDetails.Length() > 0) if (colDetails.Last() != '\n') colDetails += wxT("\n"); - colDetails += column->GetStorageSql(); + if (!GetDatabase()->BackendMinimumVersion(16, 0)) + colDetails += column->GetStorageSql(); if (colDetails.Length() > 0) if (colDetails.Last() != '\n') colDetails += wxT("\n"); diff --git a/ui/xrcDialogs.cpp b/ui/xrcDialogs.cpp index e999669..33019c1 100644 --- a/ui/xrcDialogs.cpp +++ b/ui/xrcDialogs.cpp @@ -35282,7 +35282,7 @@ static unsigned char xml_res_file_78[] = { 47,111,98,106,101,99,116,62,10,60,47,114,101,115,111,117,114,99,101,62, 10}; -static size_t xml_res_size_79 = 69254; +static size_t xml_res_size_79 = 69671; static unsigned char xml_res_file_79[] = { 60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101, 110,99,111,100,105,110,103,61,34,73,83,79,45,56,56,53,57,45,49,34,63,62, @@ -35682,15 +35682,34 @@ static unsigned char xml_res_file_79[] = { 32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52,60, 47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32, -32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116, -62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,103, -62,119,120,69,88,80,65,78,68,124,119,120,84,79,80,124,119,120,76,69,70, -84,124,119,120,82,73,71,72,84,60,47,102,108,97,103,62,10,32,32,32,32,32, -32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52,60,47, -98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, -60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, -32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106,101,99,116,32,99, +108,97,115,115,61,34,115,105,122,101,114,105,116,101,109,34,62,10,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,111,98,106, +101,99,116,32,99,108,97,115,115,61,34,119,120,67,104,101,99,107,66,111, +120,34,32,110,97,109,101,61,34,99,104,107,78,117,109,98,101,114,80,114, +101,116,116,121,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,108,97,98,101,108,62,66,101,97,117,116,105,102, +117,108,32,98,105,103,32,110,117,109,98,101,114,115,32,111,110,32,116,104, +101,32,115,116,97,116,105,115,116,105,99,115,32,112,97,103,101,60,47,108, +97,98,101,108,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,60,99,104,101,99,107,101,100,62,48,60,47,99,104,101, +99,107,101,100,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97,103,62,119,120, +69,88,80,65,78,68,124,119,120,84,79,80,124,119,120,76,69,70,84,124,119, +120,82,73,71,72,84,60,47,102,108,97,103,62,10,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52, +60,47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99,116,62,10, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,47,111,98,106,101,99, +116,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,60,102,108,97, +103,62,119,120,69,88,80,65,78,68,124,119,120,84,79,80,124,119,120,76,69, +70,84,124,119,120,82,73,71,72,84,60,47,102,108,97,103,62,10,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,60,98,111,114,100,101,114,62,52,60, +47,98,111,114,100,101,114,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,60,47,111,98,106,101,99,116,62,10,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,115,105,122,101, 114,105,116,101,109,34,62,10,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,60,111,98,106,101,99,116,32,99,108,97,115,115,61,34,119,120,80,97, 110,101,108,34,32,110,97,109,101,61,34,112,110,108,66,114,111,119,115,101,