Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions scripts/generate_fingerprint_outfuncs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ def initialize
['JsonTablePathSpec', 'name_location'] => :skip,
['JsonTablePathSpec', 'location'] => :skip,
['VariableSetStmt', 'jumble_args'] => :skip, # TODO: Should we be smarter about using this flag ourselves?
['CreateRoleStmt', 'role'] => :skip,
['RenameStmt', 'newname'] => :skip,
['RenameStmt', 'subname'] => :skip,
['RoleSpec', 'rolename'] => :skip,
}
INT_TYPES = ['bits32', 'uint32', 'int', 'int32', 'uint16', 'int16', 'Oid', 'Index', 'AttrNumber', 'SubTransactionId', 'RelFileNumber', 'ParseLoc']
LONG_INT_TYPES = ['long']
Expand Down
20 changes: 4 additions & 16 deletions src/include/pg_query_fingerprint_defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4688,10 +4688,7 @@ _fingerprintRoleSpec(FingerprintContext *ctx, const RoleSpec *node, const void *
{
// Intentionally ignoring node->location for fingerprinting

if (node->rolename != NULL) {
_fingerprintString(ctx, "rolename");
_fingerprintString(ctx, node->rolename);
}
// Intentionally ignoring node->rolename for fingerprinting

if (true) {
_fingerprintString(ctx, "roletype");
Expand Down Expand Up @@ -11828,10 +11825,7 @@ _fingerprintCreateRoleStmt(FingerprintContext *ctx, const CreateRoleStmt *node,
}
XXH3_freeState(prev);
}
if (node->role != NULL) {
_fingerprintString(ctx, "role");
_fingerprintString(ctx, node->role);
}
// Intentionally ignoring node->role for fingerprinting

if (true) {
_fingerprintString(ctx, "stmt_type");
Expand Down Expand Up @@ -13289,10 +13283,7 @@ _fingerprintRenameStmt(FingerprintContext *ctx, const RenameStmt *node, const vo
_fingerprintString(ctx, "true");
}

if (node->newname != NULL) {
_fingerprintString(ctx, "newname");
_fingerprintString(ctx, node->newname);
}
// Intentionally ignoring node->newname for fingerprinting

if (node->object != NULL) {
XXH3_state_t* prev = XXH3_createState();
Expand Down Expand Up @@ -13338,10 +13329,7 @@ _fingerprintRenameStmt(FingerprintContext *ctx, const RenameStmt *node, const vo
_fingerprintString(ctx, _enumToStringObjectType(node->renameType));
}

if (node->subname != NULL) {
_fingerprintString(ctx, "subname");
_fingerprintString(ctx, node->subname);
}
// Intentionally ignoring node->subname for fingerprinting

}

Expand Down
29 changes: 28 additions & 1 deletion test/fingerprint_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const char* tests[] = {
"MERGE into measurement m USING new_measurement nm ON (m.city_id = nm.city_id and m.logdate=nm.logdate) WHEN MATCHED AND nm.peaktemp IS NULL THEN DELETE WHEN MATCHED THEN UPDATE SET peaktemp = greatest(m.peaktemp, nm.peaktemp), unitsales = m.unitsales + coalesce(nm.unitsales, 0) WHEN NOT MATCHED THEN INSERT (city_id, logdate, peaktemp, unitsales) VALUES (city_id, logdate, peaktemp, unitsales)",
"4e3d1136f89c4229",
"ALTER TABLE ALL IN TABLESPACE foo OWNED BY bar, quux SET TABLESPACE fred NOWAIT",
"1bcfca993d29bc0f",
"b29772e8207534a5",
"CREATE PUBLICATION foo FOR TABLES IN SCHEMA bar",
"7dfa0872d08125e6",
"COPY vistest FROM stdin FREEZE CSV",
Expand Down Expand Up @@ -203,5 +203,32 @@ const char* tests[] = {
"1a16559b625d7498",
"ALTER TABLE baz.bar ADD COLUMN c int",
"2f36adf7ba9689b8",

// Test normalization of role name during fingerprinting.
"CREATE ROLE a",
"652129c250e27e46",
"CREATE ROLE b",
"652129c250e27e46",
"ALTER ROLE some_role RENAME TO some_other_role",
"6eea95cb0eaf740c",
"ALTER ROLE a RENAME TO b",
"6eea95cb0eaf740c",
"DROP ROLE a",
"f538c9be30bdfedc",
"DROP ROLE b",
"f538c9be30bdfedc",
"DROP ROLE IF EXISTS a",
"8966c75ff804a16c",
"DROP ROLE IF EXISTS b",
"8966c75ff804a16c",
"GRANT SELECT ON some_table TO some_role",
"b07ebf0c371d057a",
"GRANT SELECT ON some_table TO some_other_role",
"b07ebf0c371d057a",
"REASSIGN OWNED BY old_role TO new_role",
"30516c6e029e9e94",
"REASSIGN OWNED BY role_a TO role_b",
"30516c6e029e9e94",

NULL // Trailing NULL to tell the test runner we're done.
};
Loading