question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception when executing with custom type parameter and at least one of its fields is null

See original GitHub issue

Hello everyone!

We have a stored procedure that takes custom type parameter on the input. If we set one of the fields of this type to null described exception happens.

Custom type example:

CREATE TYPE TItem AS
(
	ID int,
	ParentID smallint
);

SP example:

CREATE OR REPLACE FUNCTION spSaveItem(
	_Item TItem
) 
RETURNS void AS
$BODY$
BEGIN
	-- any process code
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;

Code example:

using (var cmd = new NpgsqlCommand("spSaveItem", conn))
{
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add(new NpgsqlParameter()
            {
                ParameterName = "_Item",
                Value = new { ID = 5, ParentID = null },
                DataTypeName = $"public.TItem",
            });
    cmd.ExecuteNonQuery();
}

Same thing happens if set ParentID to DBNull.Value.

Result is:

Exception message: 08P01:  invalid frontend message type 1
Stack trace:
NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
    NpgsqlDataReader.NextResult()
    NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
    NpgsqlCommand.ExecuteReader(CommandBehavior behavior)

Npgsql version: 4.1.3 PostgreSQL version: 12.1 Operating system: Ubuntu 12.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewvanpersiecommented, Jun 16, 2020

Thank you guys, you’re doing really a tremendous job! Hope you’re well and safe!

1reaction
rojicommented, Feb 12, 2020

@YohDeadfall modified the milestone to 4.1.4. Since github allows only one milestone to be select on an issue, I think it’s better to use it to express the latest stable patch release where the fix was merged (users can scan the issue to see other versions as well).

Read more comments on GitHub >

github_iconTop Results From Across the Web

IllegalArgumentException or NullPointerException for a ...
The NullPointerException is an exception thrown by the Java Virtual Machine when you try to execute code on null reference (Like toString()). ...
Read more >
Should one check for null if he does not expect null?
Throw a custom exception that describes the problem on a higher level; this can be achieved either by throwing in the null check, ......
Read more >
How to Handle the ArgumentNullException in C# | Rollbar
The ArgumentNullException occurs in C# when null arguments are passed to a method in that expects non-null values.
Read more >
ArgumentNullException Class (System)
An ArgumentNullException exception is thrown when a method is invoked and at least one of the passed arguments is null but should never...
Read more >
Understanding null safety
If you run this Dart program without null safety, it throws a NoSuchMethodError exception on the call to .length . The null value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found