blob: 0a488f7be5dd59c8e7d0ef750a011f05647e9c1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include "pq-binarycolumn.h"
#include "column.h"
#include "dbTypes.h"
#include "pq-column.h"
#include <cstdint>
#include <endian.h>
#include <error.h>
PQ::BinaryColumn::BinaryColumn(const PQ::SelectBase * s, unsigned int f) : PQ::Column(s, f) { }
void
PQ::BinaryColumn::apply(DB::HandleField & h) const
{
if (isNull()) {
h.null();
return;
}
switch (oid) {
case 18: // CHAROID:
case 1043: // VARCHAROID:
case 25: // TEXTOID:
case 142: // XMLOID:
h.string({value(), length()});
break;
case 16: // BOOLOID:
h.boolean(valueAs<bool>());
break;
case 21: // INT2OID:
h.integer(static_cast<int64_t>(be16toh(valueAs<uint16_t>())));
break;
case 23: // INT4OID:
h.integer(static_cast<int64_t>(be32toh(valueAs<uint32_t>())));
break;
case 20: // INT8OID:
h.integer(static_cast<int64_t>(be64toh(valueAs<uint64_t>())));
break;
case 17: // BYTEAOID
h.blob(DB::Blob(value(), length()));
break;
default:
throw DB::ColumnTypeNotSupported();
}
}
|