tag:blogger.com,1999:blog-8677649049588007585.post2401795874170092383..comments2023-06-18T16:15:22.432+01:00Comments on PL/SQL Challenge: Should We Test Knowledge of "Bugs" in Quiz? (2344)Steven Feuersteinhttp://www.blogger.com/profile/16619706770920320550noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-8677649049588007585.post-47732729197396451312011-05-29T19:32:25.790+01:002011-05-29T19:32:25.790+01:00What an excellent set of comments and suggestions!...What an excellent set of comments and suggestions! <br /><br />It is definitely the case that with the new architecture, I can start a weekly or even just occasional "Weirdo" quiz. I definitely see the usefulness of making programmers aware of aberrant behaviors related to bugs. We will likely in those cases want to have a specific bug number to publish with the quiz.<br /><br />I will add this as an ER; right now, I need to get the new version settled neatly into place, launch the SQL and APEX quizzes (more on that soon on this blog), and then I can start planning other "extensions" to the daily quiz.<br /><br />Thanks so much for your feedback and help!<br /><br />SFSteven Feuersteinhttps://www.blogger.com/profile/16619706770920320550noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-38737189899972150862011-05-27T19:15:12.473+01:002011-05-27T19:15:12.473+01:00(continued)
I would not be worried if further vers...(continued)<br />I would not be worried if further versions will change certain behaviors,<br />as Tom Kyte so much likes to say, "things change over time and I am learning every day something new <br />about Oracle" ... <br />so, changes will probably bring along new quizes, with different behaviors demanding different answers...<br /><br />I should witness that I am also the kind of a player that "totaly involves" himself, and the results<br />are not a little bit indifferent to me, though sometimes I say to myself:<br />"My God, if I am such a bad player and answer so slowly a quiz that afterwards may seem easy,<br />then what at all am I looking for in this competition ?" ...<br />But, then, I always try to come back to the real value of this challenge: every day I learn something,<br />even if probably not immediately going to apply that (tricky) knowledge somewhere,<br />though this also did happen and I am very content of it.<br /><br /><br />By the way, and I ask this question to Steven, to the reviewers and to all the palyers as well,<br />how can one explain that even on a such a quiz whose answer was, ok, you are right, practically <br />impossible to be known based on knowledge alone, there are however many players that answered it <br />correctly in only very few seconds ???<br /><br />Are they testing it during those few seconds ? Or did they previously investigate the same issue <br />in the past and already were "equipped" with the right answer ? <br />And not only on one or two quizes, but day after day ?<br /><br />As I said with other occasions as well, as the PL/SQL challenge matures, I am sure we can expect to see<br />more and more quizes on very specific issues, very specialized uses of features, which probably<br />many of us will not have explored effectively before that.<br /><br />I was always among the first ones to express how frustrating this can be ( again, I cannot forget <br />that DBMS_XA one ... ), but the general answer was that the challenge cannot be kept forever alive<br />by only asking questions based on very straight-forward knowledge, though, as we all could see,<br />even such quizes are far from being answered 100% correctly always ...<br /><br /><br />As Kim said, it is a matter of balancing , and I can only hope that ultimately if will benefit all of us.<br /><br />Best Regards & Good luck further !<br />Iudith Mentzeliudithhttps://www.blogger.com/profile/04905902445036068357noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-86820933057568912982011-05-27T19:14:47.673+01:002011-05-27T19:14:47.673+01:00Hello All,
Ok, these last 2 posts sound indeed mor...Hello All,<br />Ok, these last 2 posts sound indeed more peaceful ...<br /><br />I strongly agree with Kim's remark that the feeling of having to test code out for answering correctly<br />is very frequent in the last weeks ... though, I don't think that my quiz was the first on this line.<br />I can definitely quote many others, that emphasized aspects that ARE NOT specified in the Documentation.<br /><br />One that comes to my mind immediately is the quiz about raising a NO_DATA_FOUND in a function<br />called from SQL ... also not documented anywhere, though, most probably NOT a bug.<br /><br />... and, by the way, each time when I am not sure of a choice correctness, if I try to go on without<br />testing it, just based on "immediate common sense", I always regret it afterwards ... <br />For sure, testing is also a way of learning, and even the best way, though, of course, painful enough<br />when it happens during the quiz.<br /><br />In the light of our experience, which gets richer as we play the challenge, I think we can agree<br />that NOT every behavior that we effectively experience and which is NOT specifically mentioned in the<br />Documentation is definitely and always a bug, even if it may look so sometimes.<br /><br />In the case of the nested tables and associative arrays, the behavior is consistent for both<br />nested tables stored in the database and for those in PL/SQL, namely, the upper limit CAN be exceeded,<br />at least during specific operations, so probably those arrays are implemented internally<br />simply as indexed by PLS_INTEGER, just like in Nikotin's quiz the INTEGER datatype was in fact<br />a NUMBER(*,0) in the database, but NOT in PL/SQL ...<br /><br />Who can say that these are indeed bugs, and not just undocumented internal implementations ?<br />( as we all know, most bugs are first considered "features" :) :) :) ... )<br /><br />This case strongly resembles the issue of the inheritance from the formal parameter of a procedure<br />to the actual value passed to that parameter, namely, if a formal parameter is of a constrained <br />subtype, then the actual parameter DOES NOT inherit the size of that subtype,<br />which though documented, however does contradict common sense, <br />for ex. how can you pass/store 10 characters in a varchar2(5) variable ?<br /><br />(to be continued)iudithhttps://www.blogger.com/profile/04905902445036068357noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-46876010422589810992011-05-27T17:10:40.477+01:002011-05-27T17:10:40.477+01:00Gary makes an important point: bugs may be correct...Gary makes an important point: bugs may be corrected by a patch that does not alter the release level. It is also possible that defects may manifest differently with different patch levels. The problem with bug questions is that they depend on experience with a specific case that is not indicative of a developer’s competence or overall knowledge. For players lacking that specific experience the only reliable way to identify the correct responses is to run the code. This reduces the competitive aspect of the PL/SQL Challenge to a test of typing skills.<br /><br />Knowledge of defects in Oracle’s PL/SQL implementation is important, but is not a proper domain for quizzes that purport to assess one’s PL/SQL language knowledge and skills. Bugs are not part of the language (if they were then they would be features, not defects). One means of using the Challenge to convey knowledge of these defects is to identify the issue in the question, present code that is affected by the bug, and ask which of the choices are viable workarounds. Framed in this manner the important bug details are presented while preserving language competence as the basis for competition. Encyclopedic knowledge of PL/SQL implementation defects is not the mark of a competent PL/SQL developer; however, the ability to effectively work around an identified defect is.<br /><br />Iudith’s description of how her quiz evolved illustrates my point that bug quizzes rely on special experience. I laud her for her curiosity and efforts to explore this strange behavior. Although the results of her investigation are interesting, they demonstrate what most of us probably already knew: unexpected results may occur when one executes code that compiles in spite of violating language specifications.jhall62https://www.blogger.com/profile/10339038131928463003noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-79140465755783010632011-05-27T13:50:13.727+01:002011-05-27T13:50:13.727+01:00Iudith,
I agree with you that the PL/SQL challeng...Iudith,<br /><br />I agree with you that the PL/SQL challenge is meant to learn and teach besides being a competition - definitely!<br /><br />And I am not bashing your quiz particularly - maybe I just feel there has been a bit too many quizzes lately where I have had the feeling that I could not possibly answer based on knowledge alone, but would have had to run the code to answer correctly.<br /><br />I still say any PL/SQL question is welcome in the quiz. And even though I advocate a new quiz type for "Weekly Weirdo" - I do not say that ALL "special" quizzes should be relegated to "Weekly Weirdo". The daily challenge should still have some learning experience.<br /><br />I just say it should be a balanced diet so we won't scare half the people away because they feel half the questions are impossible to know. Having the new 2.0 framework in place makes it so much easier to balance the quizzes that in my opinion it should be considered now.Kim Berg Hansenhttps://www.blogger.com/profile/06491635470794828550noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-75921711333868765632011-05-27T12:36:54.468+01:002011-05-27T12:36:54.468+01:00== PART3 ==
If already speaking of tricks ... doe...== PART3 ==<br /><br />If already speaking of tricks ... does anybody remember Nikotin's quiz from March 23,<br />regarding integer values with 41 digits that can be stored in a database INTEGER column<br />but CANNOT be selected back into a PL/SQL variable anchored on the same column ?<br /><br />Was that also a trick or just some strange Oracle behavior, at least up to the existing versions ?<br /><br />Do we always strictly stick to the documentation ?<br /><br />This question was also asked many times in the past.<br />We can just think of the many quizes we had around the issue of procedures overloading in packages,<br />about which Oracle documentation states clearly that they CANNOT be overloaded,<br />however, they do compile successfully even in cases where they can never be executed without<br />raising the "PLS-00307: too many declarations of match this call" error.<br /><br /><br />Reading of a few suggestions about having a separate "Extreme" or "Trivia" quiz<br />just brings me one month back to that DBMS_XA quiz ... when I suggested something similar<br />for "Expert" quizes of "super-specialized" domains, while others opposed it, <br />saying that ANY pl/sql question is welcome ...<br /><br />It looked to me that once we agreed that the PL/SQL Challenge is meant to learn and to teach<br />(or, better said, to communicate experience) and I would be very happy if I could find myself in both <br />these positions over the time.<br /><br />Hope that many others still think the same.<br /><br />Best Regards,<br />Iudith Mentzeliudithhttps://www.blogger.com/profile/04905902445036068357noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-69872434578427222532011-05-27T12:36:08.688+01:002011-05-27T12:36:08.688+01:00== PART2 ==
But I can suggest also the following ...== PART2 ==<br /><br />But I can suggest also the following test case:<br /><br />rem - index by a user-defined subtype<br />DECLARE<br /> SUBTYPE t_index IS PLS_INTEGER RANGE 1..100 ;<br /><br /> TYPE t_parts IS TABLE OF plch_parts%ROWTYPE <br /> INDEX BY t_index ;<br /><br /> l_parts t_parts;<br />BEGIN<br /> BEGIN<br /> FOR rec IN (SELECT * FROM plch_parts ORDER BY partnum)<br /> LOOP<br /> l_parts(rec.partnum) := rec;<br /> END LOOP;<br /> EXCEPTION<br /> WHEN OTHERS <br /> THEN <br /> -- DBMS_OUTPUT.put_line('ERROR');<br /> DBMS_OUTPUT.put_line(SQLERRM);<br /> END;<br /><br /> DBMS_OUTPUT.put_line( l_parts(l_parts.LAST).partname );<br /><br /> BEGIN<br /> SELECT * BULK COLLECT INTO l_parts<br /> FROM plch_parts<br /> ORDER BY partnum ;<br /> EXCEPTION<br /> WHEN OTHERS <br /> THEN<br /> -- DBMS_OUTPUT.put_line('ERROR');<br /> DBMS_OUTPUT.put_line(SQLERRM);<br /> END;<br /><br /> DBMS_OUTPUT.put_line( l_parts(l_parts.LAST).partname );<br />END;<br />/<br /><br /><br />I thought even of suggesting such a case for the quiz itself, because a range of 100 elements<br />looks much more useful in practice than one of 3 rows only ... and I expected objections from<br />this direction ...<br />On the other hand, choosing a much smaller range limit already brought me back to the<br />"small range" of SIGNTYPE, which maybe does have an "additional flavour of curiosity" ...<br /><br /><br />Sorry to say, but in my opinion nothing prevents us from using any SUBTYPE of a PLS_INTEGER<br />as an array index in PL/SQL.<br />If Oracle were considering such a restriction as limiting, then it would have probably<br />implemented a compiler error similar to the one received when you try to BULK SELECT into<br />an associative array indexed by a VARCHAR2(n), namely:<br /><br />PLS-00657: Implementation restriction: bulk SQL with associative arrays with VARCHAR2 key is not<br />supported.<br /><br />The only problem here is that Oracle does not really impelement an "upper range exceeded"<br />test for such a subtype, I really wonder whether it does implement it even for a PLS_INTEGER<br />index type when using BULK SELECT ... (as I reminded at the beginning, for a nested table<br />stored in the database this limit IS NOT enforced !).<br /><br />It is true that this behavior is contrary to common sense, just as much as the VARRAY behavior<br />is different and in fact conformant with what one would expect.<br />(Once in the past there was even a quiz which stated that VARRAY can be used as a "limiting tool"<br />for the number of rows returned from a cursor, some of you maybe remember it).<br /><br />But by no means was any trick involved here, just a strange behavior of which maybe <br />some of the players would prefer to be aware.<br /><br />( to be continued )iudithhttps://www.blogger.com/profile/04905902445036068357noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-68210332163835864482011-05-27T12:34:50.026+01:002011-05-27T12:34:50.026+01:00Hello All,
I will post my comments in several part...Hello All,<br />I will post my comments in several parts, because of length limitations.<br /><br />== PART1 ==<br /><br />Just a few clarifications, if anybody is interested to know how this quiz was born.<br /><br />Maybe you remember that several months ago, on January 13 there was a quiz followed <br />by a wide debate having a choice stating the following:<br /><br />"A nested table can have as many elements in it as a relational table can have rows."<br /><br />After initially scored as wrong, because nested tables do have an index limit set by the<br />PLS_INTEGER type's upper limit itself, it was however proven afterwards that<br />a nested table stored in the database CAN contain more elements than its index limit.<br /><br />This was proven by a test case set up very cleverly by Nikotin, and the choice was rescored.<br /><br /><br />After that quiz I started to perform some simple tests around the behavior of the different<br />collection types when we try to exceed their index values upper limits.<br /><br />Thus I found for example that for a VARRAY type, as naturally expected, you CANNOT exceed <br />the upper limit set in the TYPE defintion, neither manually, by direct assignment to an element <br />nor by performing a BULK SELECT.<br /><br />For example, if you perform a SELECT BULK COLLECT that returns more than 10 elements<br />into a VARRAY(10), then at the 11-th element the following error is raised:<br /><br />ORA-22165: given index [11] must be in the range of [1] to [10]<br /><br /><br />Then, naturally, I started asking whether a NESTED TABLE does exhibit similar behavior.<br />But, since the upper limit of POWER(2,31)-1 is difficult to be reached practically,<br />I thought of testing the same on an ASSOCIATIVE ARRAY, that closely mimics the NESTED TABLE<br />behavior with regard to populating through a BULK COLLECT, and which also<br />offers the possibility to have its INDEX type declared as a "smaller range" type<br />than the usual PLS_INTEGER ...<br /><br />I did not see any interdiction documented for using a SUBTYPE in any place where its parent type<br />can be used, subject, of course, to the natural limitations that the subtype values impose.<br /><br />From here, up to considering the "smallest range" subtype, which is SIGNTYPE, <br />there was only a small step left ...<br /><br />Then, the quiz reviewers and I myself did perform tests using other subtypes of PLS_INTEGER, <br />like NATURAL and POSITIVE and all of them compiled correctly, though, of course,<br />we did not set up a test case for trying to exceed the limit of those subtypes,<br />which is the same as that of PLS_INTEGER.<br />( to be continued )iudithhttps://www.blogger.com/profile/04905902445036068357noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-42271673054782473052011-05-27T11:30:08.487+01:002011-05-27T11:30:08.487+01:00I think the only reason why every one is participa...I think the only reason why every one is participating in this quiz is to know about PL-sql and to know more about it. To get the knowledge of bugs is great as every on will come to know the area of improvements. Rather then rectifying bugs in production.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-8488860590601314702011-05-27T07:50:21.388+01:002011-05-27T07:50:21.388+01:00Like jhall I feel that even "trick" ques...Like jhall I feel that even "trick" questions should be such that highly experienced developers have a chance of knowing the answer without running the code.<br /><br />But I also like to learn and be aware of "weird" behaviour of PL/SQL so that perhaps some day I may save days of frustrating debugging :-) So a sprinkle of "bug" oriented quizzes now and then are okay by me - just not too often and preferably "bug" quizzes should be bugs there is a chance that we might encounter unknowingly in our work.<br /><br />This one is intrigueing to know but not really much chance I'll encounter it, since I would not have thought of using a constrained subtype to index by :-)<br /><br />I like Gary's suggestion - that would allow such questions to be given now and then without complaints that it punishes competitive players. Perhaps call the category 'Educational' - meaning that "This quiz is given to educate you players, it is not really a part of the competition."<br /><br />Alternatively it could be another quiz type in the new framework. We would have the daily PL/SQL quiz, the weekly(?) SQL quiz, and then perhaps every fortnight the "Beware of bugs" quiz (or maybe more generically the "Weekly Weirdo"?) Then it would be very clear for players, that these are quizzes that might stretch your mind in ways you hadn't thought of :-)Kim Berg Hansenhttps://www.blogger.com/profile/06491635470794828550noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-61846205583531812652011-05-27T02:20:24.035+01:002011-05-27T02:20:24.035+01:00As Vitaliy points out, the quiz is clearly outside...As Vitaliy points out, the quiz is clearly outside of what Oracle documentation describes - based on the documentation this should not have compiled. I answered based on what I thought the code should do and I was wrong - yes it would be nice if I got a better score(and I do feel a bit hard done by), but I have certainly learnt something. Sometimes I can forget that the purpose of the challenge is to improve us as developers, rather than getting a good score.theFurryOnehttps://www.blogger.com/profile/14190803496589452553noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-27458434687331193622011-05-27T01:36:10.878+01:002011-05-27T01:36:10.878+01:00That's a nice proposal of Gary. It seems to be...That's a nice proposal of Gary. It seems to be fair not to punish players for such questions. And still such questions are very useful for learning.<br />I've raised that point, that this quiz doesn't deserved to be Advanced.<br />Using Gary's proposal we may finally find a reasonable solution for such quizes.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-84065263210940922572011-05-27T00:01:50.651+01:002011-05-27T00:01:50.651+01:00I think there is room for the 'undocumented/un...I think there is room for the 'undocumented/unexpected behaviour as a warning' type questions. My concern about questions that are a real 'bug' is that it might get fixed in 10.2.0.6/11.2.0.3 or whatever, thus reducing the reliability of the archive of questions.<br /><br />One thought is to classify these questions outside the beginner/intermediate/advanced category. Perhaps as 'Trivia' or 'Extreme'. If that category were given a very low (or zero) difficulty, the scoring would be irrelevant and people wouldn't feel punished for not knowing.SydOraclehttps://www.blogger.com/profile/08828771074492585943noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-5603187906750323132011-05-26T21:25:01.772+01:002011-05-26T21:25:01.772+01:00I agree with those who advocate against the inclus...I agree with those who advocate against the inclusion of quizzes that exploit defects found in Oracle’s implementation of PL/SQL. Such defects are not features of the language and knowledge of them is not an indication of PL/SQL programming proficiency. The excerpt in Vitaliy’s post shows that Oracle’s documentation unambiguously restricts which types may be used indexes for associative arrays. Even if subtypes of BINARY_INTEGER were permitted, the code in question would still violate Oracle’s specification because constrained subtypes are not permitted to have values that violate their constraints.<br /><br />The following lessons may be gleaned from the quiz on May 24 (as well as the quiz on May 17 when considering the scoring challenge):<br /><br />1. Oracle’s PL/SQL compiler isn’t perfect.<br />2. Oracle’s PL/SQL runtime isn’t perfect.<br />3. Code that successfully compiles despite violating language specifications may behave in unexpected ways.<br />3. Always run the code in the quiz before answering; don’t rely on knowledge of specified behavior (you might be punished).<br /><br />My biggest complaint against this particular quiz is that competent developers are unlikely to have ever encountered this defect. This means that a correct answer was likely the result of a random click, a lucky guess that the author was being intentionally tricky, or running the code before responding. I have no issues with players testing the code prior to answering, the time penalty adjusts for that; however, it should be possible for a knowledgeable player to correctly identify correct choices without resorting to running the code.<br /><br />Some argue that "bug" quizzes offer important information. I agree that knowledge of PL/SQL implementation defects may be important; however, discussion forums are more suitable venues for conveying such information.jhall62https://www.blogger.com/profile/10339038131928463003noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-14770940959281153132011-05-26T21:12:07.290+01:002011-05-26T21:12:07.290+01:00Bugs to some could be a feature for others.
It...Bugs to some could be a feature for others.<br /><br />It's a challenge. You take it in a true spirit. Know the facts and learn a bit.<br /><br />I say bring it on...bugs, features, tricks, pitfalls etc.Sandeep Bramhenoreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-40492190532951404402011-05-26T18:21:01.043+01:002011-05-26T18:21:01.043+01:00Knowledge of "bugs" teach us to be bette...Knowledge of "bugs" teach us to be better PL/SQL developers. Bottom line - I believe "bugs" are a fair and good topic for the daily quiz.Jennifer Schiltznoreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-31710423750913844922011-05-26T15:25:03.947+01:002011-05-26T15:25:03.947+01:00I can see a few sides to this.
If you are in the ...I can see a few sides to this.<br /><br />If you are in the Challenge because you want to see how well you can play (or how well you code, or how clearly and quickly you think,...) then there is no place for bugs and "trick" questions (anyone remember the "end loop" without the semicolon?).<br /><br />If you are in the Challenge because you want to learn new, interesting, or powerful features, then the occasional bug or trick is acceptable. However, the questions need to be reasonable. This particular question I felt was rather pointless because I could not imagine a case where indexing by a type as limited as SIGNTYPE would reasonably occur.random dughttps://www.blogger.com/profile/17841819935804420777noreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-82508902020185748572011-05-26T14:47:26.885+01:002011-05-26T14:47:26.885+01:00I don't agree with this complain. I would like...I don't agree with this complain. I would like to know as much Oracle bugs as possible, and I prefer to get this knowledge before I encounter them in real life. Therefore, I reckon until this behaviour is corrected in production Oracle databases this topics must be used in PL/SQL Challenge.Oleg Gorskinnoreply@blogger.comtag:blogger.com,1999:blog-8677649049588007585.post-71401292514853326502011-05-26T14:24:44.428+01:002011-05-26T14:24:44.428+01:00http://download.oracle.com/docs/cd/B19306_01/appde...http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collection_definition.htm#sthref2535<br />"type_name can be BINARY_INTEGER, PLS_INTEGER, or VARCHAR2, or one of VARCHAR2 subtypes VARCHAR, STRING, or LONG. v_size specifies the length of the VARCHAR2 key."<br /><br />The bug is compiling successfully SIGNTYPE as INDEX BY. The rest bug(s) are only side effects.<br /><br />Such bugs teach nothing useful. It doesn't deserve challenge. But they are suitable for forums as joke.Vitaliy Lyanchevskiyhttps://www.blogger.com/profile/03394959689295703518noreply@blogger.com