Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceRET-0001o6-Ru for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Feb 2017 18:56:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ceRET-00082n-9y for pgsql-jdbc@arkaria.postgresql.org; Thu, 16 Feb 2017 18:56:45 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ceQww-0001lF-Um for pgsql-jdbc@postgresql.org; Thu, 16 Feb 2017 18:38:39 +0000 Received: from relay2.provo.novell.com ([137.65.250.214]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ceQwu-0008LM-3W for pgsql-jdbc@postgresql.org; Thu, 16 Feb 2017 18:38:37 +0000 Received: from INET-RELAY2-MTA by relay2.provo.novell.com with Novell_GroupWise; Thu, 16 Feb 2017 11:38:34 -0700 Message-Id: <58A63EFD020000B90000F5FA@relay2.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Thu, 16 Feb 2017 11:38:29 -0700 From: "Varsha Nagarajan" To: Subject: Issue : Citext type not supported by PG JDBC driver. Mime-Version: 1.0 X-Pg-Spam-Score: -4.2 (----) Content-Type: multipart/alternative; boundary="=__PartD1E821B5.1__=" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartD1E821B5.0__= Content-Type: multipart/alternative; boundary="=__PartD1E821B5.1__=" --=__PartD1E821B5.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hello PGSQL Community, =20 I have been trying to explore and exploit the "citext" data-type which = provides for case-insensitive behavior. This is really a very cool feature = but currently I'm facing issues trying to make this work in a case-insensit= ive manner using plain JDBC queries. This defies the entire purpose of the = column type. =20 Environment : PostgreSQL server : 9.4.1211 Pgsql JDBC version : JDBC41 Postgresql Driver =20 Scenario :=20 =20 I have a table where column : name is citext type. There is a row with = name column value as "Postgres". If I now write a plain JDBC query to = fetch all rows where name =3D "postgres", it returns no result. Ideally, = name being a citext column type, the query should have returned one row as = result.=20 =20 Analysis : =20 On analyzing further, I found that the field values for the column values = fetched in the PgResultSetMetaData has "unknown" type against citext = column types. I'm guessing that this due to the lack of support for citext = type in Pg JDBC driver. Normally, a data type not known by the driver is = returned by ResultSet.getObject() as a PGobject instance. So when we are = using a PreparedStatement, during binding of parameters, the PG JDBC = driver is unable to provide a correct data type mapping for citext type = (which is an unknown type to it) so it considers it to be a default type = of varchar. Since the citext column is now treated as varchar, the search = becomes a case-sensitive one and the query returns no rows. The workarounds= provided to add "stringtype=3Dunspecified" or creating a custom PGObject = type might address this issue but it creates other new issues and it = doesn't work with ORM tools. Furthermore, the ORM tool (Hibernate) we use = also does not extend support for citext. Only when the driver starts = providing support for citext can we approach the Hibernate community with = the ORM based issues. =20 Now the real question is : Is an initiative/development already in place = for this issue?=20 =20 If not, I would like to provide a patch for the same. I'm not very = comfortable making these tweaks by adding custom PGobject data types in = our production code and would want to provide a cleaner solution by adding = support for "citext" in the PostgreSQL jdbc driver itself. A similar = change was done sometime back to extend support for "json" type. We could = do the needful and start providing support for citext type by making = changes in driver code to identify this new data type introduced on server = side. I believe that any new data type or feature added on server side = must have relevant client side support that allows us to utilize the = feature to the fullest. The case here would be for supporting citext data = type on client side. =20 When I checked many forums, I have seen people complaining about these = issues but I'm not aware if a fix has been provided or even is in = progress. I have gone through the driver code and have made the necessary = changes to support this type. I would also want your valuable inputs on = what are the other changes that are needed around this area. I'd be more = than happy to contribute to the development of this driver and provide a = fix to address this issue. Please let me know how to proceed with the = issues at hand. Eagerly looking forward to your response. =20 Regards, Varsha. =20 =20 --=__PartD1E821B5.1__= Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Description: HTML
Hello PGSQL Community,
 
I have been trying to explore and exploit the "citext" data-type = which provides for case-insensitive behavior. This is really a very cool = feature but currently I'm facing issues trying to make this work in a = case-insensitive manner using plain JDBC queries. This defies the entire = purpose of the column type.
 
Environment  :
PostgreSQL server : 9.4.1211Pgsql JDBC version : JDBC41 Postgresql Driver
 
Scenario :
 
 I have a table where column : name is citext type. = There is a row with name column value as "Postgres". If I now write = a plain JDBC query to fetch all rows where name =3D "postgres", = it returns no result.  Ideally, name being a citext column type, the = query should have returned one row as result.
 
Analysis :
 
On analyzing further, I found that the field values for the column = values fetched in the PgResultSetMetaData has "unk= nown" type against citext column types. I'm guessing = that this due to the lack of support for citext type in Pg JDBC = driver. Normally, a data type not known by the driver is returned by ResultSet.getObject() as a PGobj= ect instance.  So when we are using a PreparedStatement,&nbs= p;during binding of parameters, the PG JDBC driver is unable to = provide a correct data type mapping for citext type (which is an unknown = type to it)  so it considers it to be a default type of varchar. = Since the citext column is now treated as varchar, the search becomes a = case-sensitive one and the query returns no rows. The workarounds provided = to add "stringtype=3Dunspecified" or creating a custom PGObject type might = address this issue but it creates other new issues and it doesn't work = with ORM tools. Furthermore, the ORM tool (Hibernate) we use also does not = extend support for citext. Only when the driver starts providing support = for citext can we approach the Hibernate community with the ORM based = issues.
 
Now the real question is : Is an initiative/development = already in place for this issue?
 
If not, I would like to provide a patch for the same. I'm not very = comfortable making these tweaks by adding custom PGobject data types i= n our production code and would want to provide a cleaner solution by = adding support for "citext" in the PostgreSQL jdbc driver itself. A = similar change was done sometime back to extend support for "json" type. = We could do the needful and start providing support for citext type by = making changes in driver code to identify this new data type introduced on = server side. I believe that any new data type or feature added on server = side must have relevant client side support that allows us to utilize the = feature to the fullest. The case here would be for supporting citext data = type on client side.
 
When I checked many forums, I have seen people complaining about = these issues but I'm not aware if a fix has been provided or even is in = progress. I have gone through the driver code and have made the necessary = changes to support this type. I would also want your valuable inputs on = what are the other changes that are needed around this area. I'd be more = than happy to contribute to the development of this driver and provide a = fix to address this issue. Please let me know how to proceed with the = issues at hand. Eagerly looking forward to your response.
 
Regards,
Varsha.
 =
 =
--=__PartD1E821B5.1__=-- --=__PartD1E821B5.0__=--