I refer to this file, function addColumn

I need to confirm whether I have understood correctly or not the null value of field size. When I set size null , does this mean that the index's size will be set by the maximum size of the current table's data? If not, please explain. Thank you

1 Answer 1


If you pass $size as null then it's take default value.

Check following code sample

case self::TYPE_NUMERIC:
    $match = [];
    $scale = 0;
    $precision = 10;
    // parse size value
    if (is_array($size)) {
        if (count($size) == 2) {
            $size = array_values($size);
            $precision = $size[0];
            $scale = $size[1];
    } elseif (preg_match('#^(\d+),(\d+)$#', $size, $match)) {
        $precision = $match[1];
        $scale = $match[2];
    // check options
    if (isset($options['precision'])) {
        $precision = $options['precision'];

    if (isset($options['scale'])) {
        $scale = $options['scale'];

    if (!empty($options['unsigned'])) {
        $unsigned = true;
case self::TYPE_DATE:
case self::TYPE_DATETIME:
case self::TYPE_TIMESTAMP:
case self::TYPE_TEXT:
case self::TYPE_BLOB:
case self::TYPE_VARBINARY:
    $length = $size;

Here default value of $precision is 10.

Check following code

case self::TYPE_VARBINARY:
    $length = $size;

If $size is null, $length is also null but check following code what happened

Click here


Check following code

case Table::TYPE_TEXT:
case Table::TYPE_BLOB:

That means type text, blob and varbinary takes default value if you pass size as a null. Default value is 1024

  • Yes, I had seen that in TYPE_NUMERIC default is 10, but what about TYPE_TEXT? Here is a special case for TYPE_VARBINARY. I need some detail on TYPE_TEXT if you know. Thanks! Commented Jun 14, 2017 at 17:35
  • Check updated answer
    – Sohel Rana
    Commented Jun 15, 2017 at 5:26
  • Thank you! What about the final type on the database. Is a 1024 sized TYPE_TEXT saved as varchar, whereas a 1000000 sized TYPE_TEXT saved as text? Commented Jun 15, 2017 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.