Quiz 1
Quiz 1
Question 1
- The target file, data.txt, has exactly 36409 bytes.
- The C code defines the BUF_SIZE as 2048.
- The while loop invokes the read() function and continues as long as the returned character count is > 0.
- The first 17 times the read() function is invoked, it will grab a full block of 2048 bytes (17×2048=34816 bytes).
- There are 1593 bytes remaining (36409−34816=1593).
- The 18th invocation will read those final 1593 bytes and return the integer 1593, which satisfies the > 0 condition.
- The 19th invocation will attempt to read more data, hit the End Of File (EOF), and return 0, which finally fails the > 0 check and breaks the loop.
Answer: the read function will be invoked 19 times
Question 2
Answer: the read function will be invoked 19 times All user tables plus some catalog tables are located under base; global contains catalog tables shared by all databases.
Question 3
Answer: select c.relname, pg_relation_filepath(c.oid) as relfile from pg_class c join pg_namespace n on (c.relanmespace = n.oid) where c.relkind = ‘r’ and n.namespace = ‘public’;
