You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pg_select fails to cleanly unset the data array on each iteration of the code block. It only reliably clears out array elements that exist in the SELECT statement, but neglects to clear any array elements that were added during the execution of the code block.
This can be reproduced using this code:
#!/usr/bin/env tclsh
package require Pgtcl
set db [pg_connect -connlist {dbname nugget}]
pg_select $db "SELECT generate_series(1,10) as id" buf {
if {$buf(id) == 5} {
set buf(interloper) "this field should only be in record number 5"
}
puts [array get buf]
}
Which runs with this output:
.tupno 0 id 1 .headers id .numcols 1
.tupno 1 id 2 .headers id .numcols 1
.tupno 2 id 3 .headers id .numcols 1
.tupno 3 id 4 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 4 id 5 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 5 id 6 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 6 id 7 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 7 id 8 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 8 id 9 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 9 id 10 .headers id .numcols 1
I expected the buf array to be reset completely each time the code block is evaluated.
Notably, the buf array is properly unset (all values) at the conclusion of the pg_select operation.
The text was updated successfully, but these errors were encountered:
A related bug was fixed by commit 3521d22, which could cause a crash if you happened to try to actually unset the array variable within the pg_select code body.
pg_select fails to cleanly unset the data array on each iteration of the code block. It only reliably clears out array elements that exist in the SELECT statement, but neglects to clear any array elements that were added during the execution of the code block.
This can be reproduced using this code:
Which runs with this output:
.tupno 0 id 1 .headers id .numcols 1
.tupno 1 id 2 .headers id .numcols 1
.tupno 2 id 3 .headers id .numcols 1
.tupno 3 id 4 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 4 id 5 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 5 id 6 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 6 id 7 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 7 id 8 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 8 id 9 .headers id .numcols 1
interloper {this field should only be in record number 5} .tupno 9 id 10 .headers id .numcols 1
I expected the buf array to be reset completely each time the code block is evaluated.
Notably, the buf array is properly unset (all values) at the conclusion of the pg_select operation.
The text was updated successfully, but these errors were encountered: