On 2012/9/4 19:02, Dave Page wrote:
Hi

On Tue, Sep 4, 2012 at 5:03 AM, Quan Zongliang <[email protected]> wrote:
Hi,

Please find the attachments.

pgColumn.patch:

Detect serial columns from pg_depend, not column default (observe deviating
   serial name)
This patch does not apply:

raptor:pgAdmin3 dpage$ git apply ~/Downloads/pgColumn.patch
/Users/dpage/Downloads/pgColumn.patch:13: trailing whitespace.
                pgSet *set = ExecuteSet(
/Users/dpage/Downloads/pgColumn.patch:14: trailing whitespace.
                                                    wxT("SELECT classid\n")
/Users/dpage/Downloads/pgColumn.patch:15: trailing whitespace.
                                                    wxT("  FROM pg_depend\n")
/Users/dpage/Downloads/pgColumn.patch:16: trailing whitespace.
                                                    wxT(" WHERE refobjid=") + 
table->GetOidStr() +
/Users/dpage/Downloads/pgColumn.patch:17: trailing whitespace.
                                                        wxT(" AND refobjsubid = 
") + NumToStr(GetColNumber()) +
error: patch failed: pgadmin/schema/pgColumn.cpp:338
error: pgadmin/schema/pgColumn.cpp: patch does not apply
new patch attched.
I tested it under Cygwin, seems OK.

pgSequence.patch:

bugfix, in SQL pane of the sequence, the script is

CREATE SEQUENCE xxx
   ...;
ALTER TABLE ...
That syntax is intentional - it's required with 8.3 and earlier, which
don't support ALTER SEQUENCE ... OWNER. I suppose we could make it
version dependent, but we don't normally both with multiple versions
of the same command unless required.


diff --git a/pgadmin/schema/pgColumn.cpp b/pgadmin/schema/pgColumn.cpp
old mode 100644
new mode 100755
index 49a44d6..2b7c719
--- 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

Reply via email to