diff -crN pgjdbc/org/postgresql/core/Field.java pgjdbc.ai/org/postgresql/core/Field.java
*** pgjdbc/org/postgresql/core/Field.java	2004-06-29 08:43:25.000000000 +0200
--- pgjdbc.ai/org/postgresql/core/Field.java	2004-09-23 00:47:33.000000000 +0200
***************
*** 28,33 ****
--- 28,34 ----
  	private final String columnLabel; // Column label
  	private String columnName;        // Column name; null if undetermined
  	private Integer nullable;         // Is this column nullable? null if undetermined.
+ 	private Boolean autoIncrement;	  // Is this column automatically numbered?
  
  	private int format = TEXT_FORMAT;   // In the V3 protocol each field has a format
  					// 0 = text, 1 = binary
***************
*** 179,184 ****
--- 180,227 ----
  		}
  	}
  
+ 	public boolean getAutoIncrement(Connection con) throws SQLException
+ 	{
+ 		if (autoIncrement != null)
+ 			return autoIncrement.booleanValue();
+ 
+ 		if (tableOid == 0 || positionInTable == 0) {
+ 			autoIncrement = Boolean.FALSE;
+ 			return autoIncrement.booleanValue();
+ 		}
+                
+ 		ResultSet res = null;
+ 		PreparedStatement ps = null;
+ 		try
+ 		{
+ 			final String sql = "SELECT def.adsrc FROM pg_catalog.pg_class c " +
+ 				"JOIN pg_catalog.pg_attribute a ON (a.attrelid=c.oid) " +
+ 				"LEFT JOIN pg_catalog.pg_attrdef def ON (a.attrelid=def.adrelid AND a.attnum = def.adnum) " +
+ 				"WHERE c.oid = ? and attnum = ? AND def.adsrc LIKE '%nextval(%'";
+ 
+ 			ps = con.prepareStatement(sql);
+ 
+ 			ps.setInt(1, tableOid);
+ 			ps.setInt(2, positionInTable);
+ 			res = ps.executeQuery();
+ 
+ 			int nullResult = ResultSetMetaData.columnNullableUnknown;
+ 			if (res.next()) {
+ 				autoIncrement = Boolean.TRUE;
+ 			}
+ 			else {
+ 				autoIncrement = Boolean.FALSE;
+ 			}
+ 			return autoIncrement.booleanValue();
+ 
+ 		} finally {
+ 			if (res != null)
+ 				res.close();
+ 			if (ps != null)
+ 				ps.close();
+ 		}
+ 	}
+ 
  	public String getColumnName(Connection con) throws SQLException
  	{
  		if (columnName != null)
diff -crN pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java pgjdbc.ai/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
*** pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java	2004-08-11 12:34:39.000000000 +0200
--- pgjdbc.ai/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java	2004-09-22 21:57:10.000000000 +0200
***************
*** 3501,3506 ****
--- 3501,3507 ----
  		byte b9[] = connection.encodeString("9");
  		byte b10[] = connection.encodeString("10");
  		byte bf[] = connection.encodeString("f");
+ 		byte bt[] = connection.encodeString("t");
  		byte bnn[] = connection.encodeString(Integer.toString(java.sql.DatabaseMetaData.typeNoNulls));
  		byte bts[] = connection.encodeString(Integer.toString(java.sql.DatabaseMetaData.typeSearchable));
  
***************
*** 3516,3527 ****
  			tuple[8] = bts;
  			tuple[9] = bf; // false for now - it's signed
  			tuple[10] = bf; // false for now - must handle money
! 			tuple[11] = bf; // false for now - handle autoincrement
  			// 12 - LOCAL_TYPE_NAME is null
  			// 13 & 14 ?
  			// 15 & 16 are unused so we return null
  			tuple[17] = b10; // everything is base 10
  			v.addElement(tuple);
  		}
  		rs.close();
  
--- 3517,3556 ----
  			tuple[8] = bts;
  			tuple[9] = bf; // false for now - it's signed
  			tuple[10] = bf; // false for now - must handle money
! 			if ( typname.equals("int4") || typname.equals("int8") ) {
! 			  tuple[11] = bt;
! 			}
! 			else {
! 			  tuple[11] = bf;
! 			}
  			// 12 - LOCAL_TYPE_NAME is null
  			// 13 & 14 ?
  			// 15 & 16 are unused so we return null
  			tuple[17] = b10; // everything is base 10
  			v.addElement(tuple);
+ 
+ 			// add pseudo-type serial, serial4, serial8, bigserial
+ 			if ( typname.equals("int4") ) {
+ 			  byte[][] tuple1 = (byte[][])tuple.clone();
+ 			  byte[][] tuple2 = (byte[][])tuple.clone();
+ 			  
+ 			  tuple1[0] = connection.encodeString("serial");
+ 			  tuple2[0] = connection.encodeString("serial4");
+ 
+ 			  v.addElement(tuple1);
+ 			  v.addElement(tuple2);
+ 			} 
+ 			else if ( typname.equals("int8") ) {
+ 			  byte[][] tuple1 = (byte[][])tuple.clone();
+ 			  byte[][] tuple2 = (byte[][])tuple.clone();
+ 			  
+ 			  tuple1[0] = connection.encodeString("bigserial");
+ 			  tuple2[0] = connection.encodeString("serial8");
+ 
+ 			  v.addElement(tuple1);
+ 			  v.addElement(tuple2);
+ 			}
+ 
  		}
  		rs.close();
  
diff -crN pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java pgjdbc.ai/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
*** pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java	2004-09-21 02:58:59.000000000 +0200
--- pgjdbc.ai/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java	2004-09-23 00:08:25.000000000 +0200
***************
*** 48,54 ****
  	 */
  	public boolean isAutoIncrement(int column) throws SQLException
  	{
! 		return false;
  	}
  
  	/*
--- 48,55 ----
  	 */
  	public boolean isAutoIncrement(int column) throws SQLException
  	{
! 		Field field = getField(column);
! 		return field.getAutoIncrement(connection);
  	}
  
  	/*
