Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/lint/typedefs_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

formdata="FormData_${form#Form_}"
if ! grep -q "^$formdata$" "$1"; then
echo "error:missing_FormData:$formdata is missing for $form"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "error:missing_FormData:$formdata is missing for $form"
echo "error:missing_formdata:$formdata is missing for $form"

Copy link
Contributor

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

fi
done

grep -o 'FormData_[a-zA-Z0-9_]*' "$1" | while read -r formdata; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "error:missing_Form:$form is missing for $formdata"
echo "error:missing_form:$form is missing for $formdata"

Copy link
Contributor

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

fi
done

find src -name '*.h' -exec grep -l 'YB_DEFINE_HANDLE_TYPE' {} \; 2>/dev/null | \
Copy link
Contributor Author

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.

Copy link
Contributor

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

xargs grep -ho 'YB_DEFINE_HANDLE_TYPE([A-Z][a-zA-Z0-9_]*)' 2>/dev/null | \
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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long

Copy link
Contributor

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

fi
done
else
grep -En "$pattern" "$1" \
| sed 's/^/error:bad_yb_in_type_name:'\
Expand Down