Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db.pg: fix invalid memory access in res_to_rows (#20248)
- Loading branch information
1 parent
944b955
commit 06a536e
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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,24 @@ | ||
module main | ||
|
||
import db.pg | ||
|
||
const query = 'SELECT ischema.table_schema, c.relname, a.attname, t.typname, t.typalign, t.typlen | ||
FROM pg_class c | ||
JOIN information_schema.tables ischema on ischema.table_name = c.relname | ||
JOIN pg_attribute a ON (a.attrelid = c.oid) | ||
JOIN pg_type t ON (t.oid = a.atttypid) | ||
WHERE | ||
a.attnum >= 0' | ||
|
||
fn test_large_exec() { | ||
db := pg.connect(pg.Config{ user: 'postgres', password: 'secret', dbname: 'postgres' })! | ||
defer { | ||
db.close() | ||
} | ||
|
||
rows := db.exec(query)! | ||
for row in rows { | ||
// We just need to access the memory to ensure it's properly allocated | ||
row.str() | ||
} | ||
} |