Hi,
Please find the attachments.
pgColumn.patch:
Detect serial columns from pg_depend, not column default (observe deviating
serial name)
pgSequence.patch:
bugfix, in SQL pane of the sequence, the script is
CREATE SEQUENCE xxx
...;
ALTER TABLE ...
Regards,
Quan Zongliang
diff --git a/pgadmin/schema/pgSequence.cpp b/pgadmin/schema/pgSequence.cpp
index 870cf2f..3816706 100644
--- a/pgadmin/schema/pgSequence.cpp
+++ b/pgadmin/schema/pgSequence.cpp
@@ -150,7 +150,7 @@ wxString pgSequence::GetSql(ctlTree *browser)
if (GetCycled())
sql += wxT("\n CYCLE");
sql += wxT(";\n")
- + GetOwnerSql(7, 3, wxT("TABLE ") +
GetQuotedFullIdentifier());
+ + GetOwnerSql(7, 3, wxT("SEQUENCE ") +
GetQuotedFullIdentifier());
if (!GetConnection()->BackendMinimumVersion(8, 2))
sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") +
GetQuotedFullIdentifier());
diff --git a/pgadmin/schema/pgColumn.cpp b/pgadmin/schema/pgColumn.cpp
index 49a44d6..a2cf0b1 100644
--- a/pgadmin/schema/pgColumn.cpp
+++ b/pgadmin/schema/pgColumn.cpp
@@ -338,13 +338,31 @@ wxString pgColumn::GetDefinition()
sql == wxT("pg_catalog.integer") || sql ==
wxT("pg_catalog.bigint"))
&& (GetDefault() == seqDefault1 || GetDefault() == seqDefault2))
{
- if (sql.Right(6) == wxT("bigint"))
- sql = wxT("bigserial");
- else
- sql = wxT("serial");
+ pgSet *set = ExecuteSet(
+ wxT("SELECT classid\n")
+ wxT(" FROM pg_depend\n")
+ wxT(" WHERE refobjid=") +
table->GetOidStr() +
+ wxT(" AND refobjsubid =
") + NumToStr(GetColNumber()) +
+ wxT(" AND objid IN ('")
+
+
schema->GetPrefix() + GetTableName() + wxT("_") + GetName() +
wxT("_seq'::regclass,'\"") +
+
schema->GetPrefix() + GetTableName() + wxT("_") + GetName() +
wxT("_seq\"'::regclass)")
+ + wxT(" AND
deptype='a'"));
+ if (set && set->NumRows())
+ {
+ if (sql.Right(6) == wxT("bigint"))
+ sql = wxT("bigserial");
+ else
+ sql = wxT("serial");
+ }
if (GetNotNull())
sql += wxT(" NOT NULL");
+
+ if (set && set->NumRows())
+ AppendIfFilled(sql, wxT(" DEFAULT "), GetDefault());
+
+ if (set)
+ delete set;
}
else
{
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers