Wanna Peek Inside?

  • Are you interested in looking under the covers of SQL Server? Not inside the box, but actually at the source code?

    In an interview last week with Tom Rizzo, C|Net learned Microsoft may share the source of SQL Server if enough customers want it. Or at least they are considering the idea. They already have a Shared Source program under which certain customers and MVPs can get a view into the source code behind the program.

    I have to admit, that at first glance, this seems pretty cool. Get the code, look through it, maybe tweak it to fix a bug if you need it, etc. After all, that's the best part about Open Source, right? You can change it to meet your needs.

    But think about it. While there are some people that could probably pore over the code, maybe find some problems and let Microsoft know, maybe check for security issues, etc. But most of us couldn't do it.

    Think about the most complex program you've ever worked on. The biggest, the most stuff, etc. Does it even approach what SQL Server does? Probably not. I'm not a top 10% coder in the world, but I've looked at the GNU-SQL database server code with the lofty idea of contributing. Anyone understand what this snippet does?


    i4_t
    buflock (u2_t conn, u2_t segn, u2_t pn, char type, u2_t prget)
    /* conn - a connection to user */
    /* segn, pn - full page number */
    /* type - type of lock */
    /* prdet - get page or not */
    {
    struct PAGE *page;

    page = find_page (segn, pn);
    if (page == NULL)
    {
    page = new_page (segn, pn);
    page->p_ltype = type;
    }
    else
    {
    u2_t ptype;
    struct BUFF *buf;
    ptype = page->p_ltype;
    if ((ptype == STRONG) || (type == STRONG && ptype == WEAK))
    {
    struct WAIT *wait;
    wait = new_wait (conn, type, C_tact, prget);
    into_wait (page, wait);
    PRINTF (("BUF.buflock.e: ret -1 sn=%d,pn=%d, ptype = %d, "
    "type = %d\n", segn, pn, ptype, type));
    return (-1);
    }
    else
    page->p_ltype = type;
    if ((buf = page->p_buf) != NULL)/* if it can be locked */
    if (buf->b_status < LOCKED)
    change_prio (buf, LOCKED);
    }
    if (page->p_ltype == WEAK)
    page->p_status++;
    return (0);
    }

    Not quite fair, without the context, but it locks a page. Without the comment, would I understand it? No chance. It's beyond me and I'd bet the same for the SQL Server code for most of you. Having the source code is a good idea, but for most companies, they don't have the personnel that would understand the code. And even if they had people that could understand it in a meaningful enough way to make changes, do they have the desire to fund someone(s) to look through source code and make changes every time some bug occurs.

    Still, it's a good idea for the few that can, like the government and it might lead to a more secure product 🙂 In either case, our very own MVP, Brian Knight, will make an attempt to get it, at least for the bragging rights.

    Steve Jones

  • Absolutely not a single clue what that code would do.  Aside from the comments, I'd really be struggling.

    Tweaking the code is interesting though.  How many of you would allow developers to make changes?  On one hand it sounds like a neat idea and could fix all your problems....On the other hand....What problems could be introduced by the *fix*??

  • #include

    #include

    #include /* Microsoft Network Connectivity library */

    #include /* For the court of law */

    #define say(x) lie(x)

    #define computeruser ALL_WANT_TO_BUY_OUR_BUGWARE

    #define next_year soon

    #define the_product_is_ready_to_ship   another_beta_version

    void main()

    {

      if (latest_window_version>one_month_old)

      {

        if (there_are_still_bugs)

          market(bugfix);

        if (sales_drop_below_certain_point)

          raise(RUMOURS_ABOUT_A_blank_BUGLESS_VERSION);

      }

      while(everyone_chats_about_blank_version)

      {

        make_false_promise(it_will_be_multitasking); /* Standard Call, in

                                                        lie.h */

        if (rumours_grow_wilder)

          make_false_promise(it_will_be_plug_n_play);

        if (rumours_grow_even_wilder)

        {

          market_time=ripe;

          say("It will be ready in one month);

          order(programmers, stop_fixing_bugs_in_old_version);

          order(programmers, start_brainstorm_about_blank_version);

          order(marketingstaff, permission_to_spread_nonsense);

          vapourware=TRUE;

          break;

         }

      }

      switch (nasty_questions_of_the_worldpress)

      {

         case WHEN_WILL_IT_BE_READY:

           say("It will be ready in", today+30_days," we're just testing");

           break;

        case WILL_THIS_PLUG_AND_PLAY_THING_WORK:

           say("Yes it will work");

           ask(programmers, why_does_it_not_work);

           pretend(there_is_no_problem);

           break;

         case WHAT_ARE_MINIMAL_HARDWARE_REQUIREMENTS:

           say("It will run on a 8086 with lightning speed due to"

               " the 32 bits architecture");

           inform(INTEL, "Pentium sales will rise skyhigh");

           inform(SAMSUNG, "Start a new memorychip plant"

                  "'cos all those customers will need at least 32 megs");

           inform(QUANTUM, "Thanks to our fatware your sales will triple");

           get_big_bonus(INTEL, SAMSUNG, QUANTUM);

           break;

         case DOES_MICROSOFT_GET_TOO_MUCH_INFLUENCE:

           say("Oh no, we are just here to make a better world for

                everyone");

           register(journalist, Big_Bill_Book);

           when(time_is_ripe)

           {

             arrest(journalist);

             brainwash(journalist);

             when(journalist_says_windows_95_is_bugfree)

             {

               order(journalist, "write a nice objective article");

               release (journalist);

             }

           }

           break;

       }

       while (vapourware)

       {

         introduction_date++; /* Delay */

         if (no_one_believes_anymore_there_will_be_a_release)

           break;

         say("It will be ready in",today+ONE_MONTH);

      }

      release(beta_version)

      while (everyone_is_dumb_enough_to_buy_our_bugware)

      {

        bills_bank_account += 150*megabucks;

        release(new_and_even_better_beta_version);

        introduce(more_memory_requirements);

        if (customers_report_installation_problems)

        {

          say("that is a hardware problem, not a software problem");

          if (smart_customer_says_but_you_promised_plug_and_play)

          {

            ignore(customer);

            order(microsoft_intelligence_agency, "Keep an eye on this

                                                  bastard");

          }

        }

        if ( bills_bank_account>skyhigh && marriage>two_years )

        {

          divorce(woman_that_was_beatifull_when_I_married_her);

          wave(dollars, at_lusty_chicks);

          marry(young_blond_virgin_with_big_boobies);

          devirginize(young_blond_virgin_with_big_boobies);

          if (boobies_start_to_hang)

            dump(young_blond_virgin_with_big_boobies);

        }

        if (there_is_another_company)

        {

          steal(their_ideas);

          accuse(compagny, stealing_our_ideas);

          hire(a_lot_of_lawyers); /* in process.h */

          wait(until_other_company_cannot_afford_another_lawsuit);

          buy_out(other_company);

        }

      }

      /* Now everyone realizes that we sell bugware and they are all angry at

         us */

      order(plastic_surgeon, make_bill_look_like_poor_bastard);

      buy(nice_little_island); hire(harem);

      laugh_at(everyone,

    for_having_the_patience_year_after_year_for_another_unfinished_version);

    }

    void bugfix(void)

    {

      charge (a_lot_of_money)

      if (customer_says_he_does_not_want_to_pay_for_bugfix)

        say("It is not a bugfix but a new version");

      if (still_complaints)

      {

        ignore(customer);

        register(customer, big_Bill_book);

        /* We'll get him when everyone uses Billware!!*/

      }

    }

    I would second Steve. It takes a real knowledgeable coder to deal with such a complex product. I guess that are those geeks who do their tax declaration in hexadecimal.  

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Very nice Frank. I'd be willing to work on your code if you need help

  • Are you saying, this could be optimised?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • The point of whether developers would be able to benefit from being able to inspect the source code is irrelevant. It is like saying "why give people freedom when they might not know how to make best use of it".

    Darius Z.

  • Darius,

    Somewhat correct.

    The point is that the idea that you'd go chanding things, fixing bugs, etc. to make it work better is a fallacy. There might be a few people that would find issues and suggest changes, but most would not and it's an appearence that it's better because it's open.

    And Frank, I wouldn't optmize, might want to enhance a little

  • Honestly, though the code of such a product like a RDBMS is surely very complex, I guess you'll find your way through when you work each day with it. If not, I think it's very likely that you cause more harm than any good.

    Or in short, it will be a good idea, but for the vast majority of DBA's, developers or users there won't change anything.

    Curious what questions then will come up here, though

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply