PostgreSQL error:invalid Escape String Workaround _postgresql

Source: Internet
Author: User
Tags postgresql

I have a colleague today. After configuring PostgreSQL as the hive metabase, the following error message is encountered when running hive sql:

Copy Code code as follows:

caused By:metaexception (Message:got exception:org.apache.hadoop.hive.metastore.api.MetaException Javax.jdo.JDODataStoreException:Error Executing jdoql query "select" This "." NAME ' as NUCORDER0 from ' DBS ' this ' WHERE (LOWER ("this"). NAME ") like? Escape ' \ ') Order by NUCORDER0 ': Error:invalid escape string
Hint:escape string must be empty or one character ...

The error message is clear, ESCAPE ' \ ' Here, the quotation marks can only be one character, not two. The solution is simply to set the JDBC user's connection session property standard_conforming_strings to OFF.

Copy Code code as follows:

ALTER role xx in the DATABASE yy SET standard_conforming_strings to off;

Error reason description

The ' \ ' in the early PG normal string is treated as an escape character, so ' \ \ ' will eventually be considered ' \ '. However, this is not in accordance with the SQL standard, so in PG 9.1 and later, the normal string of \ will not be the task is the escape character, and E ' xx\x ' in the \ will be treated as an escape character. In order for the previous code to run in the new PG version, there is the standard_conforming_strings option, which defaults to on, means that strings are processed according to SQL standards, and when off, the string is processed according to the older version of PG.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.