-
Notifications
You must be signed in to change notification settings - Fork 48
Add support for XEvent logging and bump API version to v3 #90
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
Open
miljann995
wants to merge
22
commits into
main
Choose a base branch
from
dev/mveljovic/host-callback-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
15aa08e
feat: add v3 of extension api with host callbacks
miljann995 ffc94f4
feat: remove extension name from parameters list
miljann995 effc829
Revert "feat: remove extension name from parameters list"
miljann995 4aa44e8
fix: adjust parameters
miljann995 d62a9de
chore: comments
miljann995 0adb869
feat: add test
miljann995 058e1a0
chore: comments
miljann995 6c2ba56
fix: add version check
miljann995 7060815
fix: set LogXEvent callback to nullptr if not provided by the host
miljann995 7329d03
fix: address nullptr concern
miljann995 8d50d54
fix: add version check
miljann995 80a7076
fix: address code review comments
miljann995 44b3f23
fix: address code review comments
miljann995 87b8636
fix: avoid race condition on concurrent cleanups
miljann995 dfc2d4d
fix: type mismatch
miljann995 01d9889
fix: address race condition concerns
miljann995 456aa78
fix: avoid dangling pointer of host callbacks
miljann995 011520d
feat: extract trace level into separate header file
miljann995 e726883
fix: extract trace level enum in a separate header file
miljann995 74d7a5b
fix: use caller-supplied extension name, if provided, or default exte…
miljann995 b5c7417
fix: forward compatibility on host callback versions
miljann995 2f9a8c9
fix: forward compatibility test
miljann995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| //********************************************************************* | ||
| // Copyright (c) Microsoft Corporation. | ||
| // | ||
| // Host callbacks protocol between the host and extensions. | ||
| // Optional API surface introduced alongside v3 of the Extension API. | ||
| // | ||
| // @File: sqlextensionhostcallbacks.h | ||
| // | ||
| //********************************************************************* | ||
|
|
||
| #ifndef __SQLEXTENSIONHOSTCALLBACKS | ||
| #define __SQLEXTENSIONHOSTCALLBACKS | ||
|
|
||
| #include "sqlexternallanguage.h" | ||
| #include "sqlextensiontracelevel.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif /* __cplusplus */ | ||
|
|
||
| // Callback function provided by the host for logging XEvents from Extension. | ||
| // | ||
| typedef void (*PFunc_ExtensionLogXEvent)( | ||
| const SQLCHAR *ExtensionName, | ||
| SQLULEN ExtensionNameLength, | ||
| SQLGUID SessionId, | ||
| SQLUSMALLINT TaskId, | ||
| SQLUSMALLINT TraceLevel, | ||
| SQLINTEGER ErrorCode, | ||
| const SQLCHAR *Message, | ||
| SQLULEN MessageLength | ||
| ); | ||
|
|
||
| // Host callbacks structure passed from host to Extension. | ||
| // | ||
| #define SQLEXTENSION_HOST_CALLBACKS_VERSION_1 1 | ||
| #define SQLEXTENSION_HOST_CALLBACKS_MIN_SUPPORTED_VERSION SQLEXTENSION_HOST_CALLBACKS_VERSION_1 | ||
|
|
||
| typedef struct _SQLEXTENSION_HOST_CALLBACKS | ||
| { | ||
| // Highest SQLEXTENSION_HOST_CALLBACKS_VERSION_* the host populates. | ||
| // Extension must validate before reading version-gated fields. | ||
| // | ||
| SQLUSMALLINT Version; | ||
|
|
||
| // Explicit padding so SizeInBytes is naturally 4-byte aligned regardless | ||
| // of compiler packing settings. Must be zero. | ||
| // | ||
| SQLUSMALLINT Reserved0; | ||
|
|
||
| // sizeof(SQLEXTENSION_HOST_CALLBACKS) as the host saw it at build time. | ||
| // Extension must validate this is greater or equal the size of every field it intends | ||
| // to read. Lets a newer Extension safely run against an older host that supplied a smaller struct. | ||
| // | ||
| SQLUINTEGER SizeInBytes; | ||
|
|
||
| // Version 1 callbacks. | ||
| // | ||
| PFunc_ExtensionLogXEvent LogXEvent; | ||
|
|
||
| // Reserved for future expansion. Zero-initialized by the host. Extension must not read or call these. | ||
| // | ||
| void *Reserved1; | ||
| void *Reserved2; | ||
| } SQLEXTENSION_HOST_CALLBACKS; | ||
|
|
||
| // Optional API (v3+) | ||
| // Receives host callback functions from the host. | ||
| // | ||
| SQLEXTENSION_INTERFACE | ||
| SQLRETURN SetHostCallbacks( | ||
| SQLEXTENSION_HOST_CALLBACKS *Callbacks | ||
| ); | ||
|
|
||
| #ifdef __cplusplus | ||
| } /* End of extern "C" { */ | ||
| #endif/* __cplusplus */ | ||
|
|
||
| #endif/* __SQLEXTENSIONHOSTCALLBACKS */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //********************************************************************* | ||
| // Copyright (c) Microsoft Corporation. | ||
| // | ||
| // ExtensionTraceLevel enum shared between the host and extensions. | ||
| // | ||
| // @File: sqlextensiontracelevel.h | ||
| // | ||
| //********************************************************************* | ||
|
|
||
| #ifndef __SQLEXTENSIONTRACELEVEL | ||
| #define __SQLEXTENSIONTRACELEVEL | ||
|
|
||
| // Trace levels for events logged via the LogXEvent host callback. | ||
| // Lowest numeric value is the most severe, matching the Windows ETW | ||
| // TRACE_LEVEL_* convention. | ||
| // | ||
| enum ExtensionTraceLevel | ||
| { | ||
| Extension_Critical = 1, | ||
| Extension_Error = 2, | ||
| Extension_Warning = 3, | ||
| Extension_Information = 4, | ||
| Extension_Verbose = 5 | ||
| }; | ||
|
|
||
| #endif /* __SQLEXTENSIONTRACELEVEL */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.