@@ -84,12 +84,17 @@ name :: Field -> Maybe ByteString
8484name Field{..} = unsafePerformIO (PQ.fname result column)
8585
8686-- | Returns the name of the object id of the @table@ associated with the
87−-- column, if any. Returns 'invalidOid' when there is no such table;
87+-- column, if any. Returns 'Nothing' when there is no such table;
8888-- for example a computed column does not have a table associated with it.
8989-- Analogous to libpq's @PQftable@.
9090
91−tableOid :: Field -> PQ.Oid
92−tableOid Field{..} = unsafePerformIO (PQ.ftable result column)
91+tableOid :: Field -> Maybe PQ.Oid
92+tableOid Field{..} = toMaybeOid (unsafePerformIO (PQ.ftable result column))
93+ where
94+ toMaybeOid x
95+ = if x == PQ.invalidOid
96+ then Nothing
97+ else Just x
9398
9499-- | If the column has a table associated with it, this returns the number
95100-- of the associated table column. Numbering starts from 0. Analogous