Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e22dfb

Browse files
committed
Fix postgres 9.0 typeinfo
1 parent a368771 commit 8e22dfb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,19 @@ impl InnerConnection {
416416
ORDER BY enumsortorder") {
417417
Ok(..) => {}
418418
Err(Error::Io(e)) => return Err(ConnectError::Io(e)),
419+
// Postgres 9.0 doesn't have enumsortorder
420+
Err(Error::Db(ref e)) if e.code == SqlState::UndefinedColumn => {
421+
match self.raw_prepare(TYPEINFO_ENUM_QUERY,
422+
"SELECT enumlabel \
423+
FROM pg_catalog.pg_enum \
424+
WHERE enumtypid = $1 \
425+
ORDER BY oid") {
426+
Ok(..) => {}
427+
Err(Error::Io(e)) => return Err(ConnectError::Io(e)),
428+
Err(Error::Db(e)) => return Err(ConnectError::Db(e)),
429+
Err(Error::Conversion(_)) => unreachable!(),
430+
}
431+
}
419432
// Old versions of Postgres and things like Redshift don't support enums
420433
Err(Error::Db(ref e)) if e.code == SqlState::UndefinedTable => {}
421434
// Some Postgres-like databases are missing a pg_catalog (e.g. Cockroach)

0 commit comments

Comments
 (0)