I would like to use pgsl as an interpreter (in the sense of execve(2)). In short, if a file begins with the line
#! /path/to/psql -f it should be interpretable by psql. The normal semantics of execve(2) ensure that this will work perfectly (indeed a file containing "#!/path/to/psql -l" works as expected), except for psql's nasty habit of not interpreting the first line as a comment. It seems that a simple fix to the following function in src/bin/psql/input.c would do the trick. char * gets_fromFile(FILE *source) { PQExpBufferData buffer; char line[1024]; initPQExpBuffer(&buffer); while (fgets(line, sizeof(line), source) != NULL) { appendPQExpBufferStr(&buffer, line); if (buffer.data[buffer.len - 1] == '\n') { buffer.data[buffer.len - 1] = '\0'; return buffer.data; } } if (buffer.len > 0) return buffer.data; /* EOF after reading some bufferload(s) */ /* EOF, so return null */ termPQExpBuffer(&buffer); return NULL; } For example, this feature could be achieved by 1) including a static variable to differentiate the first from subsequent calls and 2) discarding the first line (and returning the second) on the first call if the first line begins with #!. Thus, I have two questions. - Is this a feature that would be generally accepted and useful for the postgresql community (i.e., would it be incorporated into the code base)? - Is this the correct solution or are there other portions of the code that need to be considered? I appreciate any feedback you can give me on this. Thank you very much. Cheers, Brook ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match