1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shardingsphere.db.protocol.postgresql.packet.command.query;
19
20 import lombok.Getter;
21 import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLArrayColumnType;
22 import org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLValueFormat;
23 import org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
24
25 import java.sql.Types;
26
27
28
29
30 @Getter
31 public final class PostgreSQLColumnDescription {
32
33 private final String columnName;
34
35 private final int tableOID = 0;
36
37 private final int columnIndex;
38
39 private final int columnLength;
40
41 private final int typeOID;
42
43 private final int typeModifier = -1;
44
45 private final int dataFormat;
46
47 public PostgreSQLColumnDescription(final String columnName, final int columnIndex, final int columnType, final int columnLength, final String columnTypeName) {
48 this(columnName, columnIndex, columnType, columnLength, columnTypeName, PostgreSQLValueFormat.TEXT.getCode());
49 }
50
51 public PostgreSQLColumnDescription(final String columnName, final int columnIndex, final int columnType, final int columnLength, final String columnTypeName, final int dataFormat) {
52 this.columnName = columnName;
53 this.columnIndex = columnIndex;
54 this.columnLength = columnLength;
55 this.dataFormat = dataFormat;
56 typeOID = Types.ARRAY == columnType ? PostgreSQLArrayColumnType.getTypeOid(columnTypeName) : PostgreSQLColumnType.valueOfJDBCType(columnType, columnTypeName).getValue();
57 }
58 }