非常奇怪的列字符串 "single-quote-comment-brace-time-char"-postgres 选择中的错误替换 - 可能仅与 JDBC 有关
Very strange column string "single-quote-comment-brace-time-char"-bug substitutions in postgres selects - maybe related to JDBC only
如果您曾经遇到过类似的问题并绞尽脑汁找出问题所在 - 简而言之:
--'
select '{t'::text
text
-----
TIME
???
多么令人讨厌的错误,这会导致数据真正混乱!
它 seems to be known since 9.1,可能仅与 JDBC 驱动程序有关,并且也发生在我们的 9.3 中!:
这里有一些我发现的更多细节(用于帮助在您的代码中或最终由 "source hackers" ;) 找到并修复此问题)到目前为止,示例代码如下:
- a 单引号必须出现在 select 上方的单行或多行注释中的某处(例如
--'
、/*'*/
, -- foo's cool
)
- 明确给出字符串必须包含
{t
或{d
以分别被TIME
或DATE
替代
- 其中一个 字符串必须 明确地(也可能隐含地)类型
text
- 必须在同一字符串或其他字符串中的某处使用右括号才能继续此替换(例如
select 'foo } bar'
)
- 注释中的右大括号再次禁用该行为(例如
--}
)
.
--'
select '{t'::text
union all select '{ta}'
union all select '{tfoo bar'
-- these are untouched
union all select '{ t}'
union all select 'foo { t}'
-- there seems to be an opening/closing "{" "}" match behaviour behind
-- it since the 2nd row below
union all select '{t'
union all select '{ta}'
union all select '{tfoo bar'
-- also "d" seems to be a "trigger"
union all select '}{d}'
-- a closing brace in a comment seems to disable it completely again
union all select '{d'
union all select '{d'
-- }
union all select 'a}{d}'
text
------------
TIME
{ta
TIME foo bar
{ t
foo { t}
TIME
{ta
TIME foo bar
DATE
DATE
{d
a}{d}
如果您曾经遇到过类似的问题并绞尽脑汁找出问题所在 - 简而言之:
--'
select '{t'::text
text
-----
TIME
???
多么令人讨厌的错误,这会导致数据真正混乱! 它 seems to be known since 9.1,可能仅与 JDBC 驱动程序有关,并且也发生在我们的 9.3 中!:
这里有一些我发现的更多细节(用于帮助在您的代码中或最终由 "source hackers" ;) 找到并修复此问题)到目前为止,示例代码如下:
- a 单引号必须出现在 select 上方的单行或多行注释中的某处(例如
--'
、/*'*/
,-- foo's cool
) - 明确给出字符串必须包含
{t
或{d
以分别被TIME
或DATE
替代 - 其中一个 字符串必须 明确地(也可能隐含地)类型
text
- 必须在同一字符串或其他字符串中的某处使用右括号才能继续此替换(例如
select 'foo } bar'
) - 注释中的右大括号再次禁用该行为(例如
--}
)
.
--'
select '{t'::text
union all select '{ta}'
union all select '{tfoo bar'
-- these are untouched
union all select '{ t}'
union all select 'foo { t}'
-- there seems to be an opening/closing "{" "}" match behaviour behind
-- it since the 2nd row below
union all select '{t'
union all select '{ta}'
union all select '{tfoo bar'
-- also "d" seems to be a "trigger"
union all select '}{d}'
-- a closing brace in a comment seems to disable it completely again
union all select '{d'
union all select '{d'
-- }
union all select 'a}{d}'
text
------------
TIME
{ta
TIME foo bar
{ t
foo { t}
TIME
{ta
TIME foo bar
DATE
DATE
{d
a}{d}