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

Corrupt BLOB in UDF if followed by a char* that is a timestamp [CORE1579] #1998

Closed
firebird-issue-importer opened this issue Nov 9, 2007 · 6 comments

Comments

@firebird-issue-importer
Copy link

@firebird-issue-importer firebird-issue-importer commented Nov 9, 2007

Submitted by: James Linse (jlinse)

If I call the following with BLOB_IS_NULL('abc', NULL, CURRENT_TIMESTAMP) the blob in the udf will get corrupted.
This only happens on a 64 bit system as I've tested it on a 32bit system and it works as I would expect.
If I rearrange the parameters as BLOB_IS_NULL('abc', CURRENT_TIMESTAMP, NULL) things seem to be ok.
If I try to cast the timestamp explicitly BLOB_IS_NULL('abc', NULL, CAST(CURRENT_TIMESTAMP AS CHAR(30))) the blob still gets corrupted.
If I just pass a regular string as parameter 3 everything is fine also. BLOB_IS_NULL('abc', NULL, 'abc')

DECLARE EXTERNAL FUNCTION BLOB_IS_NULL
CSTRING(32767),
BLOB null,
CSTRING(32767) NULL
RETURNS INTEGER BY VALUE
ENTRY_POINT 'blobisnull' MODULE_NAME 'mptfbudf';

__int32 blobisnull(char* name, blobcallback* blob_in, char* data)
{
if(blob_in && blob_in->blob_handle && (blob_in->blob_total_length > 0)) {
if(blob_in->blob_total_length > 0) {
return 0; // Blob is not null
}
} else {
return 1;
}
}

Commits: aadc4e6 bc42dd3

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Nov 13, 2007

Modified by: @dyemanov

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Nov 16, 2007

Commented by: @AlexPeshkoff

Bug happened only for NULL BLOBS. This was due to incorrect space allocation for them on UDF parameters' stack. On 64-bit builds it was more destructive cause blob_handle could be overwritten by next parameter (not a case for 32-bit builds due to smaller pointer size).

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Nov 16, 2007

Modified by: @AlexPeshkoff

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.1 RC1 [ 10201 ]

Fix Version: 2.0.4 [ 10211 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 26, 2007

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jan 28, 2008

Modified by: @pcisar

Workflow: jira [ 13394 ] => Firebird [ 14049 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jan 19, 2016

Modified by: @pavel-zotov

QA Status: No test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants