Warns if MySQL log file size is not large enough for blob insertions.
491232
def _CheckLogFileSize(cursor):
  """"""

  # Do not fail, because users might not be able to change this for their
  # database. Instead, warn the user about the impacts.

  innodb_log_file_size = int(_ReadVariable("innodb_log_file_size", cursor))
  required_size = 10 * mysql_blobs.BLOB_CHUNK_SIZE
  if innodb_log_file_size < required_size:
    # See MySQL error 1118: The size of BLOB/TEXT data inserted in one
    # transaction is greater than 10% of redo log size. Increase the redo log
    # size using innodb_log_file_size.
    max_blob_size = innodb_log_file_size / 10
    max_blob_size_mib = max_blob_size / 2**20
    logging.warning(
        "MySQL innodb_log_file_size of %d is required, got %d. "
        "Storing Blobs bigger than %.4f MiB will fail.", required_size,
        innodb_log_file_size, max_blob_size_mib)
1325818
def validate_instance_dbname(self, dbname):
        '''  '''
        # 1-64 alphanumeric characters, cannot be a reserved MySQL word
        if re.match('[\w-]+$', dbname) is not None:
            if len(dbname) <= 41 and len(dbname) >= 1:
                if dbname.lower() not in MYSQL_RESERVED_WORDS:
                    return True
        return '*** Error: Database names must be 1-64 alphanumeric characters,\
            cannot be a reserved MySQL word.'
1126175
def before_blobput(self, field: str, fileobj: BinaryIO,
                       filename: str,
                       mimetype: Optional[str] = None,
                       size: Optional[int] = None,
                       encoding: Optional[str] = None) -> None:
        """"""
925364
private function checkMemoryLimit()
    {
        if (function_exists('ini_get')) {
            /**
             * Note that this calculation is incorrect for memory limits that
             * exceed the value range of the underlying platform's native
             * integer.
             * In practice, we will get away with it, because it doesn't make
             * sense to configure PHP's memory limit to half the addressable
             * RAM (2 GB on a typical 32-bit system).
             */
            $memoryInBytes = function ($value) {
                    $unit = strtolower(substr($value, -1, 1));
                    $value = (int) $value;
                    switch ($unit) {
                        case 'g':
                            $value *= 1024 * 1024 * 1024;
                            break;
                        case 'm':
                            $value *= 1024 * 1024;
                            break;
                        case 'k':
                            $value *= 1024;
                            break;
                    }

                    return $value;
                };

            $memoryLimit = trim(ini_get('memory_limit'));
            // Increase memory_limit if it is lower than 512M
            if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 512 * 1024 * 1024) {
                trigger_error("Configured memory limit ($memoryLimit) is lower " .
                              "than 512M; composer-wrapper may not work " .
                              "correctly. Consider increasing PHP's " .
                              "memory_limit to at least 512M.",
                              E_USER_NOTICE);
            }
        }

    }
1360275
def _ensure_valid_record_size(self, size):
        """"""
        if size > self.config['max_request_size']:
            raise Errors.MessageSizeTooLargeError(
                "The message is %d bytes when serialized which is larger than"
                " the maximum request size you have configured with the"
                " max_request_size configuration" % (size,))
        if size > self.config['buffer_memory']:
            raise Errors.MessageSizeTooLargeError(
                "The message is %d bytes when serialized which is larger than"
                " the total memory buffer you have configured with the"
                " buffer_memory configuration." % (size,))
1095841
public function bellowSizeLimit($file)
    {
        $content = @file_get_contents($file['tmp_name']);
        $filesize = strlen($content);
        $uploadlimit = $this->_max_upload_limit * 1024 * 1024;

        if ($filesize > $uploadlimit) {
            throw new LibBaseControllerExceptionBadRequest('Exceed maximum size');
        }

        return true;
    }
1211855
public void bumpTableSize(int iBumpIncrement, boolean bInsertRowsInModel)
    {
        int iRowCount = this.setRowCount(this.getRowCount(false) + iBumpIncrement);          // Theoretical EOF value for table scroller (Actual when known).
        if (m_iLastRecord != RECORD_UNKNOWN)
            m_iLastRecord = iRowCount - 1;     // Sync
        if (bInsertRowsInModel)
            this.fireTableRowsInserted(this.getRowCount(true) - iBumpIncrement, this.getRowCount(true) - 1);
    }
129868
function _BlobDecode_old( $blob )
	{
		$blobid = ibase_blob_open($this->_connectionID, $blob );
		$realblob = ibase_blob_get( $blobid,$this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet <kevinboillet@yahoo.fr>
		while($string = ibase_blob_get($blobid, 8192)){
			$realblob .= $string;
		}
		ibase_blob_close( $blobid );

		return( $realblob );
	}
672845
private acolyte.jdbc.Blob createBlob(InputStream stream, long length) 
        throws SQLException {

        final acolyte.jdbc.Blob blob = acolyte.jdbc.Blob.Nil();

        blob.setBytes(0L, createBytes(stream, length));

        return blob;
    }
1148786
def logical_size(self, name):
        """"""
        digest = self._digest_for_link(name)
        logical_size = self.db.get('{}:logical_size'.format(digest).encode())

        if logical_size:
            return int(logical_size.decode())
        else:
            raise RuntimeError(
                    'Blob doesn\'t have :logical_size in DB: try recovering')
613973
private void ensureLength(FieldDescriptorDef fieldDef, String checkLevel)
    {
        if (!fieldDef.hasProperty(PropertyHelper.OJB_PROPERTY_LENGTH))
        {
            String defaultLength = JdbcTypeHelper.getDefaultLengthFor(fieldDef.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE));

            if (defaultLength != null)
            {
                LogHelper.warn(true,
                               FieldDescriptorConstraints.class,
                               "ensureLength",
                               "The field "+fieldDef.getName()+" in class "+fieldDef.getOwner().getName()+" has no length setting though its jdbc type requires it (in most databases); using default length of "+defaultLength);
                fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_LENGTH, defaultLength);
            }
        }
    }
257705
function dbinomLog(size, p) {
      if (p === 0) { return function(x) { return x === 0 ? 0 : -Infinity; }; }
      if (p === 1) { return function(x) { return x === size ? 0 : -Infinity; }; }
      return function(x) {
         if (x === 0) {
            if (size === 0) { return 0; }
            return size * log1p(-p);
         }
         if (x === size) { return size * Math.log(p); }
         return stirlerr(size) - stirlerr(x) - stirlerr(size - x) -
            bd0(x, size * p) - bd0(size - x, size * (1 - p)) +
            0.5 * Math.log(size / (C.twopi * x * (size - x)));
      };
   }
1008293
static int mysqlToJavaType(int type, final int meta, boolean isBinary) {
        int javaType;

        if (type == LogEvent.MYSQL_TYPE_STRING) {
            if (meta >= 256) {
                int byte0 = meta >> 8;
                if ((byte0 & 0x30) != 0x30) {
                    /* a long CHAR() field: see #37426 */
                    type = byte0 | 0x30;
                } else {
                    switch (byte0) {
                        case LogEvent.MYSQL_TYPE_SET:
                        case LogEvent.MYSQL_TYPE_ENUM:
                        case LogEvent.MYSQL_TYPE_STRING:
                            type = byte0;
                    }
                }
            }
        }

        switch (type) {
            case LogEvent.MYSQL_TYPE_LONG:
                javaType = Types.INTEGER;
                break;

            case LogEvent.MYSQL_TYPE_TINY:
                javaType = Types.TINYINT;
                break;

            case LogEvent.MYSQL_TYPE_SHORT:
                javaType = Types.SMALLINT;
                break;

            case LogEvent.MYSQL_TYPE_INT24:
                javaType = Types.INTEGER;
                break;

            case LogEvent.MYSQL_TYPE_LONGLONG:
                javaType = Types.BIGINT;
                break;

            case LogEvent.MYSQL_TYPE_DECIMAL:
                javaType = Types.DECIMAL;
                break;

            case LogEvent.MYSQL_TYPE_NEWDECIMAL:
                javaType = Types.DECIMAL;
                break;

            case LogEvent.MYSQL_TYPE_FLOAT:
                javaType = Types.REAL; // Types.FLOAT;
                break;

            case LogEvent.MYSQL_TYPE_DOUBLE:
                javaType = Types.DOUBLE;
                break;

            case LogEvent.MYSQL_TYPE_BIT:
                javaType = Types.BIT;
                break;

            case LogEvent.MYSQL_TYPE_TIMESTAMP:
            case LogEvent.MYSQL_TYPE_DATETIME:
            case LogEvent.MYSQL_TYPE_TIMESTAMP2:
            case LogEvent.MYSQL_TYPE_DATETIME2:
                javaType = Types.TIMESTAMP;
                break;

            case LogEvent.MYSQL_TYPE_TIME:
            case LogEvent.MYSQL_TYPE_TIME2:
                javaType = Types.TIME;
                break;

            case LogEvent.MYSQL_TYPE_NEWDATE:
            case LogEvent.MYSQL_TYPE_DATE:
                javaType = Types.DATE;
                break;

            case LogEvent.MYSQL_TYPE_YEAR:
                javaType = Types.VARCHAR;
                break;

            case LogEvent.MYSQL_TYPE_ENUM:
                javaType = Types.INTEGER;
                break;

            case LogEvent.MYSQL_TYPE_SET:
                javaType = Types.BINARY;
                break;

            case LogEvent.MYSQL_TYPE_TINY_BLOB:
            case LogEvent.MYSQL_TYPE_MEDIUM_BLOB:
            case LogEvent.MYSQL_TYPE_LONG_BLOB:
            case LogEvent.MYSQL_TYPE_BLOB:
                if (meta == 1) {
                    javaType = Types.VARBINARY;
                } else {
                    javaType = Types.LONGVARBINARY;
                }
                break;

            case LogEvent.MYSQL_TYPE_VARCHAR:
            case LogEvent.MYSQL_TYPE_VAR_STRING:
                if (isBinary) {
                    // varbinary在binlog中为var_string类型
                    javaType = Types.VARBINARY;
                } else {
                    javaType = Types.VARCHAR;
                }
                break;

            case LogEvent.MYSQL_TYPE_STRING:
                if (isBinary) {
                    // binary在binlog中为string类型
                    javaType = Types.BINARY;
                } else {
                    javaType = Types.CHAR;
                }
                break;

            case LogEvent.MYSQL_TYPE_GEOMETRY:
                javaType = Types.BINARY;
                break;

            // case LogEvent.MYSQL_TYPE_BINARY:
            // javaType = Types.BINARY;
            // break;
            //
            // case LogEvent.MYSQL_TYPE_VARBINARY:
            // javaType = Types.VARBINARY;
            // break;

            default:
                javaType = Types.OTHER;
        }

        return javaType;
    }
806874
def is_valid_size(size, chunk_size):
        """"""
        min_csize = current_app.config['FILES_REST_MULTIPART_CHUNKSIZE_MIN']
        max_size = \
            chunk_size * current_app.config['FILES_REST_MULTIPART_MAX_PARTS']
        return size > min_csize and size <= max_size
456205
def check(repair = false)
      # Determine size of the data blobs file.
      data_file_size = File.exist?(@blobs_file_name) ?
        File.size(@blobs_file_name) : 0

      next_start = 0
      prev_entry = nil
      @entries.each do |entry|
        # Entries should never overlap
        if prev_entry && next_start > entry[START]
          PEROBS.log.fatal
                "#{@dir}: Index entries are overlapping\n" +
                "ID: #{'%016X' % prev_entry[ID]}  " +
                "Start: #{prev_entry[START]}  " +
                "Bytes: #{prev_entry[BYTES]}\n" +
                "ID: #{'%016X' % entry[ID]}  Start: #{entry[START]}  " +
                "Bytes: #{entry[BYTES]}"
        end
        next_start = entry[START] + entry[BYTES]

        # Entries must fit within the data file
        if next_start > data_file_size
          PEROBS.log.fatal
                "#{@dir}: Entry for ID #{'%016X' % entry[ID]} " +
                "goes beyond 'data' file " +
                "size (#{data_file_size})\n" +
                "ID: #{'%016X' % entry[ID]}  Start: #{entry[START]}  " +
                "Bytes: #{entry[BYTES]}"
        end

        prev_entry = entry
      end

      true
    end
745431
public function isValidSize()
    {
        // If file was blocked via PHP for being excessive size, shortcut here
        switch ($this->tmpFile['error']) {
            case UPLOAD_ERR_INI_SIZE:
            case UPLOAD_ERR_FORM_SIZE:
                return false;
        }
        $maxSize = $this->getAllowedMaxFileSize($this->getFileExtension());
        return (!$this->tmpFile['size'] || !$maxSize || (int)$this->tmpFile['size'] < $maxSize);
    }
1029186
def disk_check_size(ctx, param, value):
    
    if value:
        # if we've got a prefix
        if isinstance(value, tuple):
            val = value[1]
        else:
            val = value
        if val % 1024:
            raise click.ClickException('Size must be a multiple of 1024.')
    return value