-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[YSQL] add lint rule for yb_typedefs.list Form_* and YB_DEFINE_HANDLE_TYPE #28549
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
base: master
Are you sure you want to change the base?
[YSQL] add lint rule for yb_typedefs.list Form_* and YB_DEFINE_HANDLE_TYPE #28549
Conversation
✅ Deploy Preview for infallible-bardeen-164bc9 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
fi | ||
done | ||
|
||
find src -name '*.h' -exec grep -l 'YB_DEFINE_HANDLE_TYPE' {} \; 2>/dev/null | \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check adds a lot of time (around 4 seconds on my Mac). Are we ok with this?
YB_DEFINE_HANDLE_TYPE is only used in src/yb/yql/pggate/ybc_pg_typedefs.h
, so it feels almost odd to check the entire src/
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please only check src/yb/yql/pggate
: grep -rl YB_DEFINE_HANDLE_TYPE src/yb/yql/pggate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arc lint src/postgres/src/tools/pgindent/yb_typedefs.list
to test
fi | ||
done | ||
|
||
find src -name '*.h' -exec grep -l 'YB_DEFINE_HANDLE_TYPE' {} \; 2>/dev/null | \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please only check src/yb/yql/pggate
: grep -rl YB_DEFINE_HANDLE_TYPE src/yb/yql/pggate
grep -o 'Form_[a-zA-Z0-9_]*' "$1" | while read -r form; do | ||
formdata="FormData_${form#Form_}" | ||
if ! grep -q "^$formdata$" "$1"; then | ||
echo "error:missing_FormData:$formdata is missing for $form" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "error:missing_FormData:$formdata is missing for $form" | |
echo "error:missing_formdata:$formdata is missing for $form" |
grep -o 'FormData_[a-zA-Z0-9_]*' "$1" | while read -r formdata; do | ||
form="Form_${formdata#FormData_}" | ||
if ! grep -q "^$form$" "$1"; then | ||
echo "error:missing_Form:$form is missing for $formdata" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "error:missing_Form:$form is missing for $formdata" | |
echo "error:missing_form:$form is missing for $formdata" |
sed 's/YB_DEFINE_HANDLE_TYPE(//' | sed 's/)//' | sort -u | while read -r handle_type; do | ||
transformed_type="Ybc${handle_type}" | ||
if ! grep -q "^$transformed_type$" "$1"; then | ||
echo "error:missing_handle_type:$transformed_type is missing for YB_DEFINE_HANDLE_TYPE($handle_type)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long
grep -o 'Form_[a-zA-Z0-9_]*' "$1" | while read -r form; do | ||
formdata="FormData_${form#Form_}" | ||
if ! grep -q "^$formdata$" "$1"; then | ||
echo "error:missing_FormData:$formdata is missing for $form" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git i/src/postgres/src/tools/pgindent/yb_typedefs.list w/src/postgres/src/tools/pgindent/yb_typedefs.list
index 53ecb19f4b..86c2d322f1 100644
--- i/src/postgres/src/tools/pgindent/yb_typedefs.list
+++ w/src/postgres/src/tools/pgindent/yb_typedefs.list
@@ -1,6 +1,5 @@
FormData_pg_yb_migration
FormData_pg_yb_profile
-FormData_pg_yb_role_profile
FormData_pg_yb_tablegroup
FormData_yb_pg_catalog_version
FormData_yb_pg_invalidation_messages
does not cause lint failure. you are missing filename and line number from the message
@@ -25,6 +25,29 @@ if [[ "$1" == */yb_typedefs.list ]]; then | |||
grep -Env "$pattern" "$1" \ | |||
| sed 's/^/error:missing_yb_in_type_name:'\ | |||
'Types in yb_typedefs.list should have "yb":/' | |||
|
|||
grep -o 'Form_[a-zA-Z0-9_]*' "$1" | while read -r form; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep -o 'Form_[a-zA-Z0-9_]*' "$1" | while read -r form; do | |
grep -o '^Form_[a-zA-Z0-9_]*' "$1" | while read -r form; do |
fi | ||
done | ||
|
||
grep -o 'FormData_[a-zA-Z0-9_]*' "$1" | while read -r formdata; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep -o 'FormData_[a-zA-Z0-9_]*' "$1" | while read -r formdata; do | |
grep -o '^FormData_[a-zA-Z0-9_]*' "$1" | while read -r formdata; do |
grep -o 'FormData_[a-zA-Z0-9_]*' "$1" | while read -r formdata; do | ||
form="Form_${formdata#FormData_}" | ||
if ! grep -q "^$form$" "$1"; then | ||
echo "error:missing_Form:$form is missing for $formdata" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git i/src/postgres/src/tools/pgindent/yb_typedefs.list w/src/postgres/src/tools/pgindent/yb_typedefs.list
index 53ecb19f4b..f16a49fe48 100644
--- i/src/postgres/src/tools/pgindent/yb_typedefs.list
+++ w/src/postgres/src/tools/pgindent/yb_typedefs.list
@@ -9,7 +9,6 @@ Form_pg_yb_migration
Form_pg_yb_profile
Form_pg_yb_role_profile
Form_pg_yb_tablegroup
-Form_yb_pg_catalog_version
Form_yb_pg_invalidation_messages
Form_yb_pg_logical_client_version
YBExecuteMessageFunctorContext
does not cause lint failure for same reason
sed 's/YB_DEFINE_HANDLE_TYPE(//' | sed 's/)//' | sort -u | while read -r handle_type; do | ||
transformed_type="Ybc${handle_type}" | ||
if ! grep -q "^$transformed_type$" "$1"; then | ||
echo "error:missing_handle_type:$transformed_type is missing for YB_DEFINE_HANDLE_TYPE($handle_type)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff --git i/src/postgres/src/tools/pgindent/yb_typedefs.list w/src/postgres/src/tools/pgindent/yb_typedefs.list
index 53ecb19f4b..c655a151ab 100644
--- i/src/postgres/src/tools/pgindent/yb_typedefs.list
+++ w/src/postgres/src/tools/pgindent/yb_typedefs.list
@@ -267,7 +267,6 @@ YbcPgSession
YbcPgSessionState
YbcPgSessionTxnInfo
YbcPgSplitDatum
-YbcPgStatement
YbcPgSysColumns
YbcPgSysTablePrefetcherCacheMode
YbcPgTableDesc
does not cause lint failure for same reason
Closes #27319
Summary
Add lint checks for Form/FormData pairs and handle type transformations
Enhancements: