cmu-db / noisepage

Self-Driving Database Management System from Carnegie Mellon University
https://noise.page
MIT License
1.75k stars 503 forks source link

libpg_query limits string lengths to 63 bytes if double-quoted, ok if single-quoted. #1606

Closed lmwnshn closed 3 years ago

lmwnshn commented 3 years ago

Bug Report

Summary

I was trying to run

SET ou_model_input_path="/home/kapi/CLionProjects/noisepage/cmake-build-release/bin/ou_runner_input";

which always got truncated to /home/kapi/CLionProjects/noisepage/cmake-build-release/bin/ou_r.

A null byte appears to be forcefully written at byte 64...

   2f 68 6f 6d   65 2f 6b 61   70 69 2f 43   4c 69 6f 6e   │ /home/kapi/CLion │
   50 72 6f 6a   65 63 74 73   2f 6e 6f 69   73 65 70 61   │ Projects/noisepa │
   67 65 2f 63   6d 61 6b 65   2d 62 75 69   6c 64 2d 72   │ ge/cmake-build-r │
   65 6c 65 61   73 65 2f 62   69 6e 2f 6f   75 5f 72 00   │ elease/bin/ou_r· │
   6e 6e 65 72   5f 69 6e 70   75 74 00 be   be be be be   │ nner_input······ │
lmwnshn commented 3 years ago

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

lmwnshn commented 3 years ago

This happens if you use "string" instead of 'string' as your arg. So use the latter.

lmwnshn commented 3 years ago

This is quite the footgun. Fwiw, 4096 is the linux limit

> cat /usr/include/linux/limits.h | grep -A 1 "#define NAME_MAX" 
#define NAME_MAX         255    /* # chars in a file name */
#define PATH_MAX        4096    /* # chars in a path name including nul */