コード例 #1
0
        /**
         * Method declaration
         *
         *
         * @param c
         * @param channel
         *
         * @return
         *
         * @throws Exception
         */
        private Result processDrop(Tokenizer c,
                                   Channel channel)
        {
            channel.checkReadWrite();
            channel.checkAdmin();

            string sToken = c.getstring();

            if (sToken.Equals("TABLE"))
            {
                sToken = c.getstring();

                if (sToken.Equals("IF"))
                {
                    sToken = c.getstring();                        // EXISTS
                    sToken = c.getstring();                        // <table>

                    dropTable(sToken, true);
                }
                else
                {
                    dropTable(sToken, false);
                }
                channel.commit();
            }
            else if (sToken.Equals("USER"))
            {
                aAccess.dropUser(c.getstringToken());
            }
            else if (sToken.Equals("INDEX"))
            {
                sToken = c.getstring();

                if (!c.wasLongName())
                {
                    throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken);
                }

                string table = c.getLongNameFirst();
                string index = c.getLongNameLast();
                Table  t     = getTable(table, channel);

                t.checkDropIndex(index);

                Table tn = t.moveDefinition(index);

                tn.moveData(t);
                dropTable(table);
                linkTable(tn);
                channel.commit();
            }
            else
            {
                throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken);
            }

            return(new Result());
        }