func TestMessageLengthCornerCases(t *testing.T) {
	dbh := testSetup(t)
	defer testTeardown(t, dbh)

	testMassive := (os.Getenv("TestMassiveEmbeddedMessage") == "PLEASE")

	sql := `
BEGIN;
-- 127 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 110));
-- 128 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 111));
-- 129 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 112));
-- 16383 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16365));
-- 16384 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16366));
-- 16385 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16367));
-- 2097151 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097132));
-- 2097152 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097133));
-- 2097153 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097134));
COMMIT;
`
	if testMassive {
		sql += `
BEGIN;
-- 268435455 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435435));
COMMIT;
BEGIN;
-- 268435456 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435436));
COMMIT;
BEGIN;
-- 268435457 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435437));
COMMIT;
`
	}

	options := []string{
		"enable_begin_messages",	"off",
		"enable_commit_messages",	"off",
	}

	trl := func(repeat_length int) *InsertDescription {
		return &InsertDescription{
			Table: tblIdentityFullDescription,
			NewValues: &FieldSetDescription{
				Names: tblIdentityFullFieldNames,
				Values: createStringValues(2, "1", strings.Repeat("j", repeat_length)),
				Nulls: createNulls(options,2),
			},
		}
	}

	var expected []proto.Message
	expected = append(expected, trl(110))
	expected = append(expected, trl(111))
	expected = append(expected, trl(112))
	expected = append(expected, trl(16365))
	expected = append(expected, trl(16366))
	expected = append(expected, trl(16367))
	expected = append(expected, trl(2097132))
	expected = append(expected, trl(2097133))
	expected = append(expected, trl(2097134))
	if testMassive {
		expected = append(expected, trl(268435435))
		expected = append(expected, trl(268435436))
		expected = append(expected, trl(268435437))
	}

	runTest(t, dbh, sql, options, expected)
}
// This is supposed to test pb3_fix_reserved_length.  It's relying quite a lot
// on the exact structure of the message, but I'm a bit too lazy to build any
// better tests for this right now.
This is supposed to test pb3_fix_reserved_length.  It's relying quite a lot
on the exact structure of the message, but I'm a bit too lazy to build any
better tests for this right now.
// This is supposed to test pb3_fix_reserved_length . It ' s relying quite a lot // on the exact structure of the message but I ' m a bit too lazy to build any // better tests for this right now .
func TestMessageLengthCornerCases(t *testing.T) {
	dbh := testSetup(t)
	defer testTeardown(t, dbh)
	testMassive := (os.Getenv("TestMassiveEmbeddedMessage") == "PLEASE")
	sql := `
BEGIN;
-- 127 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 110));
-- 128 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 111));
-- 129 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 112));
-- 16383 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16365));
-- 16384 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16366));
-- 16385 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16367));
-- 2097151 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097132));
-- 2097152 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097133));
-- 2097153 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097134));
COMMIT;
`
	if testMassive {
		sql += `
BEGIN;
-- 268435455 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435435));
COMMIT;
BEGIN;
-- 268435456 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435436));
COMMIT;
BEGIN;
-- 268435457 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435437));
COMMIT;
`
	}
	options := []string{
		"enable_begin_messages",	"off",
		"enable_commit_messages",	"off",
	}
	trl := func(repeat_length int) *InsertDescription {
		return &InsertDescription{
			Table: tblIdentityFullDescription,
			NewValues: &FieldSetDescription{
				Names: tblIdentityFullFieldNames,
				Values: createStringValues(2, "1", strings.Repeat("j", repeat_length)),
				Nulls: createNulls(options,2),
			},
		}
	}
	var expected []proto.Message
	expected = append(expected, trl(110))
	expected = append(expected, trl(111))
	expected = append(expected, trl(112))
	expected = append(expected, trl(16365))
	expected = append(expected, trl(16366))
	expected = append(expected, trl(16367))
	expected = append(expected, trl(2097132))
	expected = append(expected, trl(2097133))
	expected = append(expected, trl(2097134))
	if testMassive {
		expected = append(expected, trl(268435435))
		expected = append(expected, trl(268435436))
		expected = append(expected, trl(268435437))
	}
	runTest(t, dbh, sql, options, expected)
}
func TestMessageLengthCornerCases ( t * testing . T ) { dbh := testSetup ( t ) defer testTeardown ( t , dbh ) testMassive := ( os . Getenv ( " " ) == " " ) sql := `
BEGIN;
-- 127 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 110));
-- 128 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 111));
-- 129 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 112));
-- 16383 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16365));
-- 16384 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16366));
-- 16385 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 16367));
-- 2097151 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097132));
-- 2097152 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097133));
-- 2097153 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 2097134));
COMMIT;
` if testMassive { sql += `
BEGIN;
-- 268435455 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435435));
COMMIT;
BEGIN;
-- 268435456 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435436));
COMMIT;
BEGIN;
-- 268435457 bytes
INSERT INTO tbl_identity_full (f1, f2) VALUES (1, repeat('j', 268435437));
COMMIT;
` } options := [ ] string { " " , " " , " " , " " , } trl := func ( repeat_length int ) * InsertDescription { return & InsertDescription { Table : tblIdentityFullDescription , NewValues : & FieldSetDescription { Names : tblIdentityFullFieldNames , Values : createStringValues ( 2 , " " , strings . Repeat ( " " , repeat_length ) ) , Nulls : createNulls ( options , 2 ) , } , } } var expected [ ] proto . Message expected = append ( expected , trl ( 110 ) ) expected = append ( expected , trl ( 111 ) ) expected = append ( expected , trl ( 112 ) ) expected = append ( expected , trl ( 16365 ) ) expected = append ( expected , trl ( 16366 ) ) expected = append ( expected , trl ( 16367 ) ) expected = append ( expected , trl ( 2097132 ) ) expected = append ( expected , trl ( 2097133 ) ) expected = append ( expected , trl ( 2097134 ) ) if testMassive { expected = append ( expected , trl ( 268435435 ) ) expected = append ( expected , trl ( 268435436 ) ) expected = append ( expected , trl ( 268435437 ) ) } runTest ( t , dbh , sql , options , expected ) }
This is supposed to test pb3_fix_reserved_length.
This is supposed to test pb3_fix_reserved_length .