Skip to content
This repository has been archived by the owner on May 10, 2020. It is now read-only.

Guid assertion failed \tiberius-0.3.0\src\types\mod.rs:344:25 #80

Open
johnfercher opened this issue Sep 29, 2018 · 3 comments
Open

Guid assertion failed \tiberius-0.3.0\src\types\mod.rs:344:25 #80

johnfercher opened this issue Sep 29, 2018 · 3 comments

Comments

@johnfercher
Copy link
Contributor

Tiberius is crashing when SELECT returns this guid F72BDC04-8837-4D3E-8C54-84A50A996BB1. This is a valid guid in Azure SQL Server.

Here is the code where panic is called.

VarLenType::Guid => {
    assert_eq!(trans.inner.read_u8()? as usize, *len);
    let mut data = [0u8; 16];
    try_ready!(trans.inner.read_bytes_to(&mut data));
    ColumnData::Guid(Cow::Owned(Guid(data)))
}

Here is the full error.

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `160`,
 right: `16`', C:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tiberius-0.3.0\src\types\mod.rs:344:25
note: Run with `RUST_BACKTRACE=1` for a backtrace.
@steffengy
Copy link
Owner

select cast('F72BDC04-8837-4D3E-8C54-84A50A996BB1' as uniqueidentifier) works fine for me, can you give me more information to reproduce?
A minimal query + dataset would be nice.

@johnfercher
Copy link
Contributor Author

I made some tests with the query and I noticed a strange behavior.

This query works.

SELECT TOP(20) 
[Id], 
[YId], 
[ReceivedDate], 
[Status], 
[BuyerName], 
[IpAddress], 
[CustomerEmail], 
[CustomerIdentification], 
[HolderName], 
[Top], 
[Top12], 
[ShipPostalCode], 
[CustomerPostalCode], 
[OrderId] 
FROM [dbo].[Transaction]
WHERE [YId] = '9AAB0758-6666-7777-8888-AC506513739E'
AND [ReceivedDate] BETWEEN '2018-03-01T00:00:04.000000153+00:00' AND '2018-03-31T23:57:23.000000523+00:00'
ORDER BY ReceivedDate;

If I add a column Amount, the error assertion failed \tiberius-0.3.0\src\types\mod.rs:344:25 occurs.

SELECT TOP(20)
[Id],
[YId], 
[ReceivedDate], 
[Status], 
[BuyerName], 
[IpAddress], 
[CustomerEmail], 
[CustomerIdentification], 
[HolderName], 
[Top], 
[Top12], 
[ShipPostalCode], 
[CustomerPostalCode], 
[OrderId], 
[Amount]
FROM [dbo].[Transaction]
WHERE [YId] = '9AAB0758-6666-7777-8888-AC506513739E'
AND [ReceivedDate] BETWEEN '2018-03-01T00:00:04.000000153+00:00'
AND '2018-03-31T23:57:23.000000523+00:00'
ORDER BY ReceivedDate;

If run a query selecting only Amount it works.

SELECT TOP(20)
[Amount]
FROM [dbo].[Transaction]
WHERE [YId] = '9AAB0758-6666-7777-8888-AC506513739E'
AND [ReceivedDate] BETWEEN '2018-03-01T00:00:04.000000153+00:00' AND '2018-03-31T23:57:23.000000523+00:00'
ORDER BY ReceivedDate;

Table creation

CREATE TABLE [Transaction] (
	Id uniqueidentifier not null,
	ReceivedDate DateTime2 null,
	YId uniqueidentifier null,
	Amount varchar(50) null,
	Status integer null,
	BuyerName varchar(100) null,
	IpAddress varchar(20) null,
	CustomerEmail varchar(100) null,
	CustomerIdentification bigint null,
	HolderName varchar(100) null,
	Top varchar(100) null,
	Top12 varchar(100) null,
	ShipPostalCode varchar(100) null,
	CustomerPostalCode varchar(100) null,
	OrderId varchar(100) null,
	PRIMARY KEY (Id)
);

Inserting data

Line 15 has the guid F72BDC04-8837-4D3E-8C54-84A50A996BB1

INSERT INTO [dbo].[Transaction] VALUES ('12345678-1234-1234-1234-84C72AECDF9A','2018-03-01 00:00:04.153','9AAB0758-6666-7777-8888-AC506513739E','39.99',3,'JOHN DOE FERNANDES COELHO',NULL,'johndoe1@live.com',NULL,'0x4007ff106921e529f27b9bdec3f234','0x9183bca89e161470f08656cea02b20','0xf63cafb46405d39e117aaa22774db8',NULL,NULL,'24fcd856-1234-1234-1234-4e22b739b956');
INSERT INTO [dbo].[Transaction] VALUES ('389C41C8-1234-1234-1234-84C72AECDF9A','2018-03-01 00:00:05.543','9AAB0758-6666-7777-8888-AC506513739E','49.99',2,'JOHN DOE MACHADO CYSNE',NULL,'johndoe2@gmail.com',67923319666,'0xca1ecdac0b4da140ed3443c4322116','0x45138c104cb7477003cedb8893d971','0xeab2a5b5b10718d5733f66f7b3e302',NULL,NULL,'c4ea59e8-1234-1234-1234-eceb36ef174b');
INSERT INTO [dbo].[Transaction] VALUES ('EEA769B7-1234-1234-1234-ED64A413EA81','2018-03-01 00:00:05.763','9AAB0758-6666-7777-8888-AC506513739E','99.99',3,'JOHN DOE STAROSTA WAJS',NULL,'johndoe3@gmail.com',43267778845,'0xf0070ab7d4cab2b2d564fe72369268','0x24c7b72b8a54f34370653af057f92e','0xf14366ef7300ef8844483c946bd1749',NULL,NULL,'4929c3e2-1234-1234-1234-c77c76b8693a');
INSERT INTO [dbo].[Transaction] VALUES ('6EA3CE94-1234-1234-1234-D9F179C1F7B6','2018-03-01 00:00:06.080','9AAB0758-6666-7777-8888-AC506513739E','49.99',2,'JOHN DOE VENTURA DA COSTA',NULL,'johndoe4@gmail.com',NULL,'0x47a9d78dc4d117be3c509a8a789707','0x1ede21fe44f1de3b083b767a40ac52','0x06874d98ca4bd6c261ff5a788d242c',NULL,NULL,'7ee335df-1234-1234-1234-dd98c050fc55');
INSERT INTO [dbo].[Transaction] VALUES ('12345632-1234-1234-1234-2FAF3AE09C3A','2018-03-01 00:00:10.880','9AAB0758-6666-7777-8888-AC506513739E','39.99',3,'JOHN DOE PAMPLONA SILVA',NULL,'johndoe5@hotmail.com',43668947761,'0xaf32da7ae22e3712d8235ee5a48672','0xcfdfa06e0133d499ba4771a3095240','0x3a69589b454a23989e1d22c72f9ddd',NULL,NULL,'c2526ea0-1234-1234-1234-bcb03b03ec85');
INSERT INTO [dbo].[Transaction] VALUES ('D82DDF22-1234-1234-1234-34F32607AD42','2018-03-01 00:00:12.337','9AAB0758-6666-7777-8888-AC506513739E','9.99',3,'JOHN DOE INACIO DE SOUZA CARVALHO',NULL,'johndoe6@gmail.com',NULL,'0x0c55d842a2f0feadab4449dce1929e','0x87d7957de581b64451af578840fa44','0x5285782877e00ed6983a6f5f586193',NULL,NULL,'a17cd15c-1234-1234-1234-7286d0a4884b');
INSERT INTO [dbo].[Transaction] VALUES ('58DE3E30-1234-1234-1234-E8068A8BCF4A','2018-03-01 00:00:12.910','9AAB0758-6666-7777-8888-AC506513739E','39.99',2,'JOHN DOE Pereira Martins',NULL,'johndoe7@hotmail.com',42123451238,'0xba2aaa4a7666496bffe11b84744a32','0x01b891a6bcee4542fe7e6649e2a2df','0x632a88ab1582dc555fdde2ade21c6e',NULL,NULL,'cddaa69c-1234-1234-1234-ee20f643826e');
INSERT INTO [dbo].[Transaction] VALUES ('12FDFA45-1234-1234-1234-4C179EE47508','2018-03-01 00:00:16.017','9AAB0758-6666-7777-8888-AC506513739E','39.99',3,'JOHN DOE DOS SANTOS MACHADO',NULL,'johndoe8@icloud.com',41231494416,'0xa049a6c344767b74b0ea9f96cbb624','0xdad35eadff898a60800a4775c42c69','0x88b42434a1cb3f898a95231da36197',NULL,NULL,'03d561e2-1234-1234-1234-a8b25468274f');
INSERT INTO [dbo].[Transaction] VALUES ('770E1222-1234-1234-1234-34F32607AD42','2018-03-01 00:00:16.040','9AAB0758-6666-7777-8888-AC506513739E','39.99',3,'JOHN DOE SILVA CARRARO',NULL,'johndoe9@gmail.com',10456123218,'0xf44f58b7b15560be44499269948dfb','0x99f17714111abedc777eee7598b685','0x9f88ac2edfd6ac3a73e3456e7bb252',NULL,NULL,'af3e2934-1234-1234-1234-0a9211992e69');
INSERT INTO [dbo].[Transaction] VALUES ('0867EFFB-1234-1234-1234-F071125255FE','2018-03-01 00:00:18.487','9AAB0758-6666-7777-8888-AC506513739E','39.99',3,'JOHN DOE MARTINS',NULL,'johndoe10@hotmail.com',39614672899,'0x2452e48cafd97dbe3c323fafeb9392','0x91257c16835670608fa9761ca6387f','0x45a6050339634187899e8c1f92e7e7',NULL,NULL,'cd34211c-1234-1234-1234-43af83f6596c');
INSERT INTO [dbo].[Transaction] VALUES ('00AB2066-1234-1234-1234-EA3131C5623A','2018-03-01 00:00:19.253','9AAB0758-6666-7777-8888-AC506513739E','69.99',2,'JOHN DOE DA SILVA MACEDO',NULL,'johndoe11@gmail.com',3658789705,'0xb0e7de6046436ece676e31b9e17cd0','0x3454eafd577782f6ee6e953cfe771f','0x0f5d11f65fd15789226545e5fab597',NULL,NULL,'9701a68a-1234-1234-1234-15c8960b29a4');
INSERT INTO [dbo].[Transaction] VALUES ('45CD544E-1234-1234-1234-8577901F2A46','2018-03-01 00:00:20.080','9AAB0758-6666-7777-8888-AC506513739E','9.99',2,'JOHN DOE CAMPOS ALMEIDA',NULL,'johndoe12@gmail.com',NULL,'0x94a125e4c5c6d3986b82b748897e3a','0x6d4c4106102343fb25d3c81014353a','0xa5081ab9650cebdb698983f624731c',NULL,NULL,'c3b0433e-1234-1234-1234-81096ce6e1ab');
INSERT INTO [dbo].[Transaction] VALUES ('0867EFFB-1234-1234-1234-5C63C1F3D34E','2018-03-01 00:00:20.200','9AAB0758-6666-7777-8888-AC506513739E','74.99',3,'JOHN DOE DOS SANTOS',NULL,'johndoe13@hotmail.com',16249287806,'0xcc780fb8103bd71b378984c6f13e81','0xffbbe8995b68942ef3599ae07957a3','0x56134638acaebeadd6f23433d94df7',NULL,NULL,'b776411f-1234-1234-1234-a2d320b2f46d');
INSERT INTO [dbo].[Transaction] VALUES ('891B23E7-1234-1234-1234-E8068A8BCF4A','2018-03-01 00:00:22.390','9AAB0758-6666-7777-8888-AC506513739E','79.99',2,'JOHN DOE DA SILVA GOUVEA',NULL,'johndoe14@gmail.com',15390979770,'0xb6936a15c9b9139989991e1e91ab08','0x217b47c5cbf130da509aa5788a60e5','0x5293b26c8789a0df876d9a82373ec7',NULL,NULL,'aa954cd6-1234-1234-1234-993773c0c1ff');
INSERT INTO [dbo].[Transaction] VALUES ('F72BDC04-8837-4D3E-8C54-84A50A996BB1','2018-03-01 00:00:24.570','9AAB0758-6666-7777-8888-AC506513739E','12.99',2,'JOHN DOE DOS SANTOS',NULL,'johndoe15@gmail.con',NULL,'0xb7295108fdb7b4c02c5d6140988a4c','0xcf6fc64fdac7e4aa702166800666d3','0x04bcb555b3497c61718266c075240f',NULL,NULL,'c4edd591-1234-1234-1234-c4f06a444cc7');
INSERT INTO [dbo].[Transaction] VALUES ('D9BDE111-1234-1234-1234-9BFBA44B0E49','2018-03-01 00:00:24.653','9AAB0758-6666-7777-8888-AC506513739E','39.99',2,'JOHN DOE SOUZA FELISMINO',NULL,'johndoe16@hotmail.com',NULL,'0x47f4e986a8c3392233c087bb949b90','0x14900151965655793747529887f6f7','0x989b83b387c8b9899a1eaef47940e2',NULL,NULL,'84957ea9-1234-1234-1234-c0b6a8f2efbd');
INSERT INTO [dbo].[Transaction] VALUES ('758C8C01-1234-1234-1234-F06B21BB10A5','2018-03-01 00:00:25.630','9AAB0758-6666-7777-8888-AC506513739E','39.99',3,'JOHN DOE Dos Santos Terroso',NULL,'johndoe17@gmail.com',9687334771,'0xa4ae176c9da8980afb6eecd48d7792','0x7ffb6d6964bf99d6c878b48d638cbf','0xc2e4769be0aff5d820f93e989b7fc1',NULL,NULL,'09787201-1234-1234-1234-24109372c0fd');
INSERT INTO [dbo].[Transaction] VALUES ('D98DE19A-1234-1234-1234-DBB4D315E5F0','2018-03-01 00:00:28.090','9AAB0758-6666-7777-8888-AC506513739E','39.99',3,'JOHN DOE NASCIMENTO THOMAZ',NULL,'johndoe18@gmail.com',17298954864,'0x7e025a61398443c86eb2d5973fb173','0xee7f848458e5ad069190ceb7b14dd3','0x231c8a9b99c6769c67934dc33ebfcf',NULL,NULL,'3f1d8049-1234-1234-1234-051e84b4a6ff');
INSERT INTO [dbo].[Transaction] VALUES ('93651711-1234-1234-1234-D4816DA3C373','2018-03-01 00:00:29.167','9AAB0758-6666-7777-8888-AC506513739E','49.99',2,'JOHN DOE REGO FERREIRA',NULL,'johndoe19@hotmail.com',5788589769,'0x52df7c14a09e2171378908e6825071','0xca5915d3ed6ba48282d2fb00557429','0x0fee889b0c8861074c75d967efc30b',NULL,NULL,'d6ca51b0-1234-1234-1234-800f20923d1b');
INSERT INTO [dbo].[Transaction] VALUES ('CC03EBE1-1234-1234-1234-5C63C1F3D34E','2018-03-01 00:00:29.883','9AAB0758-6666-7777-8888-AC506513739E','69.99',3,'JOHN DOE FONSECA DA SILVA',NULL,'johndoe20@gmail.com',72862323104,'0x08cc0daff1eaa1489809b2a71e3e9a','0x76e99985977875c990724e07d947e8','0x921ddfd427b6a0205fd2b999bb323d',NULL,NULL,'9fd5e0fc-1234-1234-1234-312f95292a0b');

@steffengy
Copy link
Owner

Works for me without hitting an assertion

#[test]
    fn test_guid_bug() {
        let future =
            SqlConnection::connect(connection_string().as_ref()).and_then(|conn| {
                conn.simple_query("SELECT TOP(20)
[Id],
[YId], 
[ReceivedDate], 
[Status], 
[BuyerName], 
[IpAddress], 
[CustomerEmail], 
[CustomerIdentification], 
[HolderName], 
[Top], 
[Top12], 
[ShipPostalCode], 
[CustomerPostalCode], 
[OrderId], 
[Amount]
FROM [dbo].[Transaction]
WHERE [YId] = '9AAB0758-6666-7777-8888-AC506513739E'
AND [ReceivedDate] BETWEEN '2018-03-01T00:00:04.000000153+00:00'
AND '2018-03-31T23:57:23.000000523+00:00'
ORDER BY ReceivedDate;")
                    .for_each(|row| {
                        println!("{:?}", row.get::<_, &Guid>(0));
                        Ok(())
                    })
            });
        current_thread::block_on_all(future).unwrap();
    }

Have you already tested against master?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants