Skip site navigation (1) Skip section navigation (2)

SVN Commit by andreas: r4858 - branches/REL-1_4_0_PATCHES/pgadmin3/src/frm

From: svn(at)pgadmin(dot)org
To: pgadmin-hackers(at)postgresql(dot)org
Subject: SVN Commit by andreas: r4858 - branches/REL-1_4_0_PATCHES/pgadmin3/src/frm
Date: 2005-12-26 14:45:35
Message-ID: 200512261445.jBQEjZE9017413@developer.pgadmin.org (view raw or flat)
Thread:
Lists: pgadmin-hackers
Author: andreas
Date: 2005-12-26 14:45:34 +0000 (Mon, 26 Dec 2005)
New Revision: 4858

Modified:
   branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp
Log:
Fix PK detection in EditGrid

Modified: branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp
===================================================================
--- branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp	2005-12-26 14:39:11 UTC (rev 4857)
+++ branches/REL-1_4_0_PATCHES/pgadmin3/src/frm/frmEditGrid.cpp	2005-12-26 14:45:34 UTC (rev 4858)
@@ -1158,7 +1158,7 @@
 
     pgSet *colSet=connection->ExecuteSet(
         wxT("SELECT n.nspname AS nspname, relname, t.typname, nt.nspname AS typnspname, ")
-               wxT("attname, COALESCE(b.oid, t.oid) AS basetype, atthasdef, adsrc,\n")
+               wxT("attname, attnum, COALESCE(b.oid, t.oid) AS basetype, atthasdef, adsrc,\n")
         wxT("       CASE WHEN t.typbasetype::oid=0 THEN att.atttypmod else t.typtypmod END AS typmod,\n")
         wxT("       CASE WHEN t.typbasetype::oid=0 THEN att.attlen else t.typlen END AS typlen\n")
         wxT("  FROM pg_attribute att\n")
@@ -1279,23 +1279,20 @@
             if (!columns[i].attr->IsReadOnly())
                 canInsert=true;
 
-            colSet->MoveNext();
-        }
-        delete colSet;
-
-        if (!hasOids)
-        {
             wxStringTokenizer collist(primaryKeyColNumbers, wxT(","));
-            long cn;
-            int pkcolcount=0;
+            long cn=0;
+            long attnum=colSet->GetLong(wxT("attnum"));
 
-            while (collist.HasMoreTokens())
+            while (cn < attnum && collist.HasMoreTokens())
             {
-                pkcolcount++;
                 cn=StrToLong(collist.GetNextToken());
-                columns[cn-1].isPrimaryKey = true;
+                if (cn == attnum)
+                    columns[i].isPrimaryKey = true;
             }
+
+            colSet->MoveNext();
         }
+        delete colSet;
     }
     else
     {


pgadmin-hackers by date

Next:From: Raphaƫl EnriciDate: 2005-12-26 22:36:35
Subject: pgAgent manpage
Previous:From: svnDate: 2005-12-26 14:39:11
Subject: SVN Commit by andreas: r4857 - in trunk/pgadmin3: . src/frm

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group