8.1 has changed the default text for serials from something like
nextval('public.tab_col_seq'::text) to nextval('tab_col_seq'::regclass)

Kris Jurka
Index: src/schema/pgColumn.cpp
===================================================================
*** src/schema/pgColumn.cpp     (revision 5006)
--- src/schema/pgColumn.cpp     (working copy)
***************
*** 126,136 ****
  {
      wxString sql = GetQuotedTypename();
  
      if ((sql == wxT("int4") || sql == wxT("int8") || 
           sql == wxT("pg_catalog.int4") || sql == wxT("pg_catalog.int8"))
!         && GetDefault() == wxT("nextval('") 
!                         + schema->GetName() + wxT(".") + GetTableName() 
!                         + wxT("_") + GetName() + wxT("_seq'::text)"))
      {
          if (sql.Right(4) == wxT("int8"))
              sql = wxT("bigserial");
--- 126,150 ----
  {
      wxString sql = GetQuotedTypename();
  
+     // Technically this serial check can still fail for sequences that
+     // get created with non-default names.  Consider:
+     // CREATE SEQUENCE st_a_seq;
+     // CREATE TABLE st (a serial);
+     // Now the default's sequence is actually st_a_seq1.
+ 
+     wxString sequenceDefault;
+     if (GetDatabase()->BackendMinimumVersion(8, 1)) {
+         sequenceDefault = wxT("nextval('") + GetTableName() 
+                         + wxT("_") + GetName() + wxT("_seq'::regclass)");
+     } else {
+         sequenceDefault = wxT("nextval('") 
+                         + schema->GetName() + wxT(".") + GetTableName() 
+                         + wxT("_") + GetName() + wxT("_seq'::text)");
+     }
+ 
      if ((sql == wxT("int4") || sql == wxT("int8") || 
           sql == wxT("pg_catalog.int4") || sql == wxT("pg_catalog.int8"))
!         && GetDefault() == sequenceDefault)
      {
          if (sql.Right(4) == wxT("int8"))
              sql = wxT("bigserial");
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to