[MDEV-26611] ERROR_INDEX isn't intuitively clear Created: 2021-09-15 Updated: 2021-10-05 Resolved: 2021-10-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | None |
| Fix Version/s: | 10.7.1 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Sergei Golubchik | Assignee: | Rucha Deodhar |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
can be discussed
|
| Comments |
| Comment by Rucha Deodhar [ 2021-09-17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi elenst , I could change it to ROW_NUMBER since it is more intuitive. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ROW_NUMBER sounds good to me in principle, but I'm wondering if it can cause any parser or other difficulties, given that we also have ROW_NUMBER as a window function. Also, if we want to be "user-focused" from the start, maybe we should ask for an independent opinion, for example, the documentation team could provide valuable input? And of course karlsson as an original creator of the feature task. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Federico Razzoli [ 2021-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I suggest:
My reasoning is based on GET DIAGNOSTICS: it seems to me the closest syntax, so I'd try to be consistent with it. It uses the term CONDITION for errors and warnings, for example:
It also uses the unfortunate word NUMBER to mean the conditions count, not a single condition index. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I think you've misinterpreted the question a little bit.
The question is about a name for the new property. In your example above the property name is RETURNED_SQLSTATE. For the newly implemented property, the name is currently ERROR_INDEX, that is
and we're discussing whether we could have a better name than ERROR_INDEX here. You are right though that ROW_NUMBER can be interpreted as "count of rows". I don't know if it's a reasonable interpretation or not, but it can happen. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Federico Razzoli [ 2021-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for explaining the parts I misunderstood. My suggestion about ERROR_INDEX is that something like CONDITION_INDEX could be more consistent (condition seems to mean error or warning). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm afraid that CONDITION_INDEX would be entirely misleading though. What is most likely thought as a condition index is the number which goes after the CONDITION word in GET DIAGNOSTICS statement, and it's very different from the value which is currently implemented as ERROR_INDEX. Please consider the example:
So, at this point we have 4 conditions:
For the condition no. 1, the value in question is 2 (2nd row in the VALUES list violates the PK constraint). And for all other conditions, no. 2-4, the value in question is 3 (3rd row in the VALUES list violates the PK restriction, the CHECK constraint, and exceeds the char length):
So, only n3 value coincides with the condition index, and it is indeed a pure coincidence. In reality it will rarely happen, it will be as uncorrelated as this:
So, the condition index is 1, the violating PK value is 20, and the property value in question is 16. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
May be CONDITION_ROW ? But it's RETURNED_SQLSTATE not CONDITION_SQLSTATE. ROW_NUMBER has an additional benefit of not adding a new keyword into the grammar, so not blowing up the parser (even though the effect of one new keyword is tiny). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Federico Razzoli [ 2021-09-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm adding one more argument against my previous suggestion: ROW_NUMBER would be, at least, similar to Db2 (DB2_ROW_NUMBER). PostgreSQL, SQL Server, Oracle and Informix don't seem to have an exact equivalent, so Db2 is the only "reference" I've found. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-09-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Could you please make a decision and if you decide to change it, push the fix? I'd rather not have it postponed till the last moment. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-09-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
rucha174, please, rename ERROR_INDEX to ROW_NUMBER similar to DB2. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-09-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I think it would be good to do the renaming before any other feature-related fixes go to 10.7 main branch. It's bad enough that we'll have a scattered git history of this feature (bugfixes detached from the initial push), but now the patches and commit comments also contain the syntax which is about to change, it will be difficult to search and understand later. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Rucha Deodhar [ 2021-09-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Patch: https://github.com/MariaDB/server/commit/28224147833e59f47491e05f247948a774b4c712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-10-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
2822414783 looks ok |