Permalink
Browse files

Add smallserial handling

Per a request from Matthew Syphus.
  • Loading branch information...
1 parent 603f921 commit 415dddd844b46de42babdc2f6ff5eb5a9eafaff8 @gleu gleu committed Mar 17, 2013
View
@@ -37,6 +37,8 @@ Changes
Date Dev Ver Change details
---------- --- ------ --------------
+2013-03-17 GL 1.18.0 Add smallserial handling. Per a request from Matthew
+ Syphus.
2013-03-01 DP 1.16.2 Fix the editing of pg_hba.conf files [Dhiraj Chawla].
2013-02-25 DP 1.16.2 Fix the display of extension owner names.
2013-02-23 GL 1.18.0 Add a title to the backup and restore windows. Per
@@ -407,7 +407,7 @@ wxString dlgColumn::GetSql()
wxString sql;
wxString name = GetName();
- bool isSerial = (cbDatatype->GetValue() == wxT("serial") || cbDatatype->GetValue() == wxT("bigserial"));
+ bool isSerial = (cbDatatype->GetValue() == wxT("serial") || cbDatatype->GetValue() == wxT("bigserial") || cbDatatype->GetValue() == wxT("smallserial"));
if (table)
{
@@ -698,7 +698,7 @@ void dlgColumn::OnSelChangeTyp(wxCommandEvent &ev)
CheckLenEnable();
txtLength->Enable(isVarLen);
- bool isSerial = (cbDatatype->GetValue() == wxT("serial") || cbDatatype->GetValue() == wxT("bigserial"));
+ bool isSerial = (cbDatatype->GetValue() == wxT("serial") || cbDatatype->GetValue() == wxT("bigserial") || cbDatatype->GetValue() == wxT("smallserial"));
txtDefault->Enable(!isSerial);
CheckChange();
@@ -2556,6 +2556,9 @@ wxString sqlTable::GetColLabelValue(int col)
case (Oid)PGOID_TYPE_SERIAL8:
label += wxT("bigserial");
break;
+ case (Oid)PGOID_TYPE_SERIAL2:
+ label += wxT("smallserial");
+ break;
default:
label += columns[col].displayTypeName;
break;
@@ -20,6 +20,7 @@
#define PGOID_TYPE_SERIAL -42L
#define PGOID_TYPE_SERIAL8 -43L
+#define PGOID_TYPE_SERIAL2 -44L
#define PGOID_TYPE_BOOL 16L
#define PGOID_TYPE_BYTEA 17L
#define PGOID_TYPE_CHAR 18L
@@ -342,8 +342,8 @@ wxString pgColumn::GetDefinition()
+ wxT("_") + GetName() + wxT("_seq\"'::text)");
}
- if ((sql == wxT("integer") || sql == wxT("bigint") ||
- sql == wxT("pg_catalog.integer") || sql == wxT("pg_catalog.bigint"))
+ if ((sql == wxT("integer") || sql == wxT("bigint") || sql == wxT("smallint") ||
+ sql == wxT("pg_catalog.integer") || sql == wxT("pg_catalog.bigint") || sql == wxT("pg_catalog.smallint"))
&& (GetDefault() == seqDefault1 || GetDefault() == seqDefault2))
{
if (GetDatabase()->BackendMinimumVersion(8, 1))
@@ -360,6 +360,8 @@ wxString pgColumn::GetDefinition()
{
if (sql.Right(6) == wxT("bigint"))
sql = wxT("bigserial");
+ else if (sql.Right(8) == wxT("smallint"))
+ sql = wxT("smallserial");
else
sql = wxT("serial");
}
@@ -377,6 +379,8 @@ wxString pgColumn::GetDefinition()
{
if (sql.Right(6) == wxT("bigint"))
sql = wxT("bigserial");
+ else if (sql.Right(8) == wxT("smallint"))
+ sql = wxT("smallserial");
else
sql = wxT("serial");
@@ -213,6 +213,10 @@ void DatatypeReader::init(pgDatabase *db, const wxString &condition, bool addSer
if (addSerials)
{
+ if (db->GetConnection()->BackendMinimumVersion(9, 2))
+ {
+ sql += wxT(" UNION SELECT 'smallserial', 0, 2, 'b', 0, 'pg_catalog', false\n");
+ }
sql += wxT(" UNION SELECT 'bigserial', 0, 8, 'b', 0, 'pg_catalog', false\n");
sql += wxT(" UNION SELECT 'serial', 0, 4, 'b', 0, 'pg_catalog', false\n");
}

0 comments on commit 415dddd

Please sign in to comment.