<commit_before>using System;
using System.Text;
using MySqlConnector.Protocol.Serialization;
using MySqlConnector.Utilities;

namespace MySqlConnector.Protocol.Payloads
{
	internal sealed class ColumnDefinitionPayload
	{
		public string Name
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_name;
			}
		}

		public CharacterSet CharacterSet { get; private set; }

		public uint ColumnLength { get; private set; }

		public ColumnType ColumnType { get; private set; }

		public ColumnFlags ColumnFlags { get; private set; }

		public string SchemaName
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_schemaName;
			}
		}

		public string CatalogName
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_catalogName;
			}
		}

		public string Table
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_table;
			}
		}

		public string PhysicalTable
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_physicalTable;
			}
		}

		public string PhysicalName
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_physicalName;
			}
		}

		public byte Decimals { get; private set; }

		public static ColumnDefinitionPayload Create(ArraySegment<byte> arraySegment)
		{
			var reader = new ByteArrayReader(arraySegment);
			SkipLengthEncodedByteString(ref reader); // catalog
			SkipLengthEncodedByteString(ref reader); // schema
			SkipLengthEncodedByteString(ref reader); // table
			SkipLengthEncodedByteString(ref reader); // physical table
			SkipLengthEncodedByteString(ref reader); // name
			SkipLengthEncodedByteString(ref reader); // physical name
			reader.ReadByte(0x0C); // length of fixed-length fields, always 0x0C
			var characterSet = (CharacterSet) reader.ReadUInt16();
			var columnLength = reader.ReadUInt32();
			var columnType = (ColumnType) reader.ReadByte();
			var columnFlags = (ColumnFlags) reader.ReadUInt16();
			var decimals = reader.ReadByte(); // 0x00 for integers and static strings, 0x1f for dynamic strings, double, float, 0x00 to 0x51 for decimals
			reader.ReadByte(0);
			if (reader.BytesRemaining > 0)
			{
				int defaultValuesCount = checked((int) reader.ReadLengthEncodedInteger());
				for (int i = 0; i < defaultValuesCount; i++)
					reader.ReadLengthEncodedByteString();
			}

			if (reader.BytesRemaining != 0)
			{
				throw new FormatException("Extra bytes at end of payload.");
			}

			return new ColumnDefinitionPayload
			{
				OriginalData = arraySegment,
				CharacterSet = characterSet,
				ColumnLength = columnLength,
				ColumnType = columnType,
				ColumnFlags = columnFlags,
				Decimals = decimals
			};
		}<commit_msg>Fix column definition payload deserialization.<commit_after>using System;
using System.Text;
using MySqlConnector.Protocol.Serialization;
using MySqlConnector.Utilities;

namespace MySqlConnector.Protocol.Payloads
{
	internal sealed class ColumnDefinitionPayload
	{
		public string Name
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_name;
			}
		}

		public CharacterSet CharacterSet { get; private set; }

		public uint ColumnLength { get; private set; }

		public ColumnType ColumnType { get; private set; }

		public ColumnFlags ColumnFlags { get; private set; }

		public string SchemaName
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_schemaName;
			}
		}

		public string CatalogName
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_catalogName;
			}
		}

		public string Table
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_table;
			}
		}

		public string PhysicalTable
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_physicalTable;
			}
		}

		public string PhysicalName
		{
			get
			{
				if (!m_readNames)
					ReadNames();
				return m_physicalName;
			}
		}

		public byte Decimals { get; private set; }

		public static ColumnDefinitionPayload Create(ArraySegment<byte> arraySegment)
		{
			var reader = new ByteArrayReader(arraySegment);
			SkipLengthEncodedByteString(ref reader); // catalog
			SkipLengthEncodedByteString(ref reader); // schema
			SkipLengthEncodedByteString(ref reader); // table
			SkipLengthEncodedByteString(ref reader); // physical table
			SkipLengthEncodedByteString(ref reader); // name
			SkipLengthEncodedByteString(ref reader); // physical name
			reader.ReadByte(0x0C); // length of fixed-length fields, always 0x0C
			var characterSet = (CharacterSet) reader.ReadUInt16();
			var columnLength = reader.ReadUInt32();
			var columnType = (ColumnType) reader.ReadByte();
			var columnFlags = (ColumnFlags) reader.ReadUInt16();
			var decimals = reader.ReadByte(); // 0x00 for integers and static strings, 0x1f for dynamic strings, double, float, 0x00 to 0x51 for decimals
			reader.ReadByte(0); // reserved byte 1
			reader.ReadByte(0); // reserved byte 2

			return new ColumnDefinitionPayload
			{
				OriginalData = arraySegment,
				CharacterSet = characterSet,
				ColumnLength = columnLength,
				ColumnType = columnType,
				ColumnFlags = columnFlags,
				Decimals = decimals
			};
		}
{'fraction_non_alphanumeric': 0.08918813427010149, 'fraction_numerical': 0.00975800156128025, 'mean_word_length': 3.288702928870293, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '417000', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1527, 'n_words': 407}