Page 1 of 1

The rule here can be roughly described as follows in ORACLE:

Posted: Thu Jan 23, 2025 9:22 am
by Rina7RS
If {} does not satisfy one of the following formats: {m}, {m,}, {,n}, {m,n}, then {} is not used as a declaration symbol for the number of times, but is recognized as a regular string.

However, the second expression above will report an error in openGaussDB, because there is another rule:
if the first character in {} is a number, the parsing logic of the number will begin. If the parsing does not meet the number rule, an error will be reported.
Looking at the openGauss source code, I found that this logic comes from the PG source code in 1998 and has not changed for decades.
Please note that this is not a bug, but the regular expression standard is inconsistent. I used 7 development languages ​​to verify and found that JAVA and RUST also report errors.

You can use the following link to test the performance of this kuwait phone number data regular expression in different development languages

4. Related source code
When using openGauss to analyze this logic, I broke down a few points and found some source code

When the first character is a number and the second is not the expected character (0-9, ", " and "}"), it will go to the default error.
If you are interested, you can download the source code to debug and analyze it yourself. I will not interpret the source code in detail here.

5. How other domestic databases handle {}
DM8, YASHAN and ORACLE are consistent and can correctly treat {} as a string when it is not a number. However, several other databases based on PG and OG and the purely self-developed OCEANBASE will report an error in this case (MySQL will not report an error, but the execution returns nothing).
6. Back to business applications
In fact, although this ambiguous usage in this article does not report an error in ORACLE, the correct encoding method should be to escape the reserved symbols that you want to recognize as characters, that is, (${1*}).
However, combined with actual business rules, although the escape method seems to be correct, the logic is actually wrong.