cstack / db_tutorial

Writing a sqlite clone from scratch in C
https://cstack.github.io/db_tutorial
MIT License
9.56k stars 968 forks source link

Part4 Error #110

Open shinyewon opened 2 months ago

shinyewon commented 2 months ago
it 'prints error message when table is full' do
  script = (1..1401).map do |i|
    "insert #{i} user#{i} person#{i}@example.com"
  end
  script << ".exit"
  result = run_script(script)
  expect(result[-2]).to eq('db > Error: Table full.')
end

Testing of the above code runs successfully after applying the following changes:

 const uint32_t COLUMN_EMAIL_SIZE = 255;
 typedef struct {
   uint32_t id;
-  char username[COLUMN_USERNAME_SIZE];
-  char email[COLUMN_EMAIL_SIZE];
+  char username[COLUMN_USERNAME_SIZE + 1];
+  char email[COLUMN_EMAIL_SIZE + 1];
 } Row;