internal void GetParametersFromShowCreate(MyCatSchemaCollection parametersTable,
                                                  string[] restrictions, MyCatSchemaCollection routines)
        {
            // this allows us to pass in a pre-populated routines table
            // and avoid the querying for them again.
            // we use this when calling a procedure or function
            if (routines == null)
            {
                routines = GetSchema("procedures", restrictions);
            }

            MyCatCommand cmd = connection.CreateCommand();

            foreach (MyCatSchemaRow routine in routines.Rows)
            {
                string showCreateSql = String.Format("SHOW CREATE {0} `{1}`.`{2}`",
                                                     routine["ROUTINE_TYPE"], routine["ROUTINE_SCHEMA"],
                                                     routine["ROUTINE_NAME"]);
                cmd.CommandText = showCreateSql;
                try
                {
                    string nameToRestrict = null;
                    if (restrictions != null && restrictions.Length == 5 &&
                        restrictions[4] != null)
                    {
                        nameToRestrict = restrictions[4];
                    }
                    using (MyCatDataReader reader = cmd.ExecuteReader())
                    {
                        reader.Read();
                        string body = reader.GetString(2);
#if NETSTANDARD1_3
                        reader.Dispose();
#else
                        reader.Close();
#endif
                        ParseProcedureBody(parametersTable, body, routine, nameToRestrict);
                    }
                }
#if NETSTANDARD1_3
                catch (MyCatNullValueException snex)
#else
                catch (System.Data.SqlTypes.SqlNullValueException snex)
#endif
                {
                    throw new InvalidOperationException(
                              String.Format(Resources.UnableToRetrieveParameters, routine["ROUTINE_NAME"]), snex);
                }
            }
        }
예제 #2
0
        /// <include file='docs/mysqlcommand.xml' path='docs/ExecuteNonQuery/*'/>
        public override int ExecuteNonQuery()
        {
#if !NETSTANDARD1_3
            int records = -1;
            // give our interceptors a shot at it first
            if (connection != null &&
                connection.commandInterceptor != null &&
                connection.commandInterceptor.ExecuteNonQuery(CommandText, ref records))
            {
                return(records);
            }
#endif

            // ok, none of our interceptors handled this so we default
            using (MyCatDataReader reader = ExecuteReader())
            {
#if !NETSTANDARD1_3
                reader.Close();
#else
                reader.Dispose();
#endif
                return(reader.RecordsAffected);
            }
        }