这个 postgres 查询是怎么工作的?
How come this postgres query is working?
SELECT NOW() - INTERVAL ' DAY';
我不明白为什么这个查询有效。查询中存在无效的 $ 文字。
当解析 timestamp
或 interval
值时,PostgreSQL 忽略非 +
、-
、.
、数字或字母的可打印字符字符.
参见 src/backend/utils/adt/datetime.c
中的 ParseDateTime
:
/* ignore other punctuation but use as delimiter */
else if (ispunct((unsigned char) *cp))
{
cp++;
continue;
}
来自man ispunct
:
ispunct()
checks for any printable character which is not a space or an
alphanumeric character.
SELECT NOW() - INTERVAL ' DAY';
我不明白为什么这个查询有效。查询中存在无效的 $ 文字。
当解析 timestamp
或 interval
值时,PostgreSQL 忽略非 +
、-
、.
、数字或字母的可打印字符字符.
参见 src/backend/utils/adt/datetime.c
中的 ParseDateTime
:
/* ignore other punctuation but use as delimiter */
else if (ispunct((unsigned char) *cp))
{
cp++;
continue;
}
来自man ispunct
:
ispunct()
checks for any printable character which is not a space or an
alphanumeric character.