Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly handle null values in columns #286

Merged
merged 1 commit into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions decryptor/postgresql/packet_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ type ColumnData struct {

// Length return column length converted from LengthBuf
func (column *ColumnData) Length() int {
if column.isNull {
return 0
}
return int(binary.BigEndian.Uint32(column.LengthBuf[:]))
}

Expand Down
11 changes: 6 additions & 5 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('data', sa.LargeBinary(length=COLUMN_DATA_SIZE)),
sa.Column('raw_data', sa.Text),
sa.Column('nullable_column', sa.Text, nullable=True),
)

acrarollback_output_table = sa.Table('acrarollback_output', metadata,
Expand Down Expand Up @@ -1781,7 +1782,7 @@ def testShutdown(self):
result = self.engine1.execute(
sa.select([sa.cast(zone, BYTEA), test_table])
.where(test_table.c.id == row_id))
for zone, _, data, raw_data in result:
for zone, _, data, raw_data, _ in result:
self.assertEqual(zone, zone)
self.assertEqual(data, poison_record)

Expand All @@ -1796,7 +1797,7 @@ def testShutdown2(self):
result = self.engine1.execute(
sa.select([test_table])
.where(test_table.c.id == row_id))
for _, data, raw_data in result:
for _, data, raw_data, _ in result:
self.assertEqual(data, poison_record)

def testShutdown3(self):
Expand All @@ -1809,7 +1810,7 @@ def testShutdown3(self):

result = self.engine1.execute(
sa.select([test_table]))
for _, data, raw_data in result:
for _, data, raw_data, _ in result:
self.assertEqual(data, poison_record)

def testShutdown4(self):
Expand All @@ -1826,7 +1827,7 @@ def testShutdown4(self):

result = self.engine1.execute(
sa.select([test_table]))
for _, data, raw_data in result:
for _, data, raw_data, _ in result:
self.assertEqual(testData, data)


Expand Down Expand Up @@ -1920,7 +1921,7 @@ def testNoDetect(self):
self.assertNotIn('Check poison records', log)
result = self.engine1.execute(
sa.select([test_table]))
for _, data, raw_data in result:
for _, data, raw_data, _ in result:
self.assertEqual(poison_record, data)


Expand Down