Skip to content

Commit 5ec68bc

Browse files
committed
New file open operators
1 parent 7c0e3ea commit 5ec68bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+524
-240
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* oltp: Save and report buffer cache/shared pool size
1010
* oltp: Output details about aw\_cols size and access
1111
* oltp: Option to emulate batch with no wait time
12+
* New more secure syntax for file/pipe open
13+
* Public utility netthroughput.rwl replaces nettest.rwl
1214

1315
## 3.0.2
1416

admin/.vim/syntax/rwl.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ syn match rwlDirective '\$nameexpand:on'
102102
syn match rwlDirective '\$nameexpand:off'
103103
syn match rwlDirective '\$reconnect1017:on'
104104
syn match rwlDirective '\$reconnect1017:off'
105+
syn match rwlDirective '\$pre31fileassign:warn'
106+
syn match rwlDirective '\$pre31fileassign:on'
107+
syn match rwlDirective '\$pre31fileassign:off'
105108
syn match rwlDirective '\$queue:on'
106109
syn match rwlDirective '\$queue:off'
107110
syn match rwlDirective '\$setaction:on'

docs/ERRORLIST.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,21 @@ are recommended making sure no sensitive information is included in the
11471147
generated executable. Note that rwloadsim cannot complete verify no sensitive
11481148
inforation is put in the executable.
11491149

1150+
### RWL-291 warning: "opening a file with '%s' in the file name is deprecated"
1151+
In version 3.1, you need to change your syntax for opening files to use
1152+
either of these assignment operators: >=, >>=, <=, |=, =| in stead of using
1153+
similar characters as part of the text string assigned to the file variable.
1154+
1155+
### RWL-292 error: "opening a file with '%s' in the file name is no longer supported"
1156+
In version 3.1, you need to change your syntax for opening files to use
1157+
either of these assignment operators: >=, >>=, <=, |=, =| in stead of using
1158+
similar characters as part of the text string assigned to the file variable.
1159+
To allow the previous behavior, use $pre31fileassign:on directive.
1160+
1161+
### RWL-293 warning: "closing a file with an operator used for open"
1162+
You are using one of the operators used to open a file or pipeline to
1163+
close a file by assigning null to it. You should use the := operator.
1164+
11501165
### RWL-600 internal error: '%s'
11511166
An abnormal situation caused an internal error in rwloadsim.
11521167
This is in most cases due to a programming error and it

docs/FILE.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,30 @@ Variables of type file are grossly comparable to FILE * variables in C
33
and most operations on files in rwloadsim are implemented using
44
standard calls like fopen(), popen(), fgets(), fprintf() etc.
55
All files are line oriented.
6-
You open a file by assigning a string to it, and close a file by
6+
You open a file for writing by assigning a string to it, and close a file by
77
assigning null to it.
88
Depending on how it was opened, you can use operations like readline
99
and writeline.
1010

11-
The string that is assigned to the file is interpreted similar to how the shell does it,
12-
and the file can be opened in one of these five ways:
11+
There are different assignment operators to allow for read, append, etc:
1312

14-
* To open for write, simply assign a string containing the file name to it; for completeness with the other options, a single initial ">" can be used.
15-
* To open for append, the first two characters of the string must be "\>\>"
16-
* To open for read, the first character of the string must be "<"
17-
* To open a pipeline for write, the first character of the string must be "\|" and the following characters will be the actual pipeline.
18-
* To open a pipeline for read, the last character of the string must be "\|".
13+
* To open for write, simply assign a string containing the file name to it using := or >=.
14+
* To open for append, use the >>= assignment operator.
15+
* To open for read, use the <= assignment operator.
16+
* To open a pipeline for write, use the \|= operator, the concatenation will be the command to execute.
17+
* To open a pipeline for read, use the =\| operator, the concatenation will be the command to execute.
1918

20-
In all cases, the initial or terminating character(s) are removed and will not be part of the file or pipe-line.
21-
22-
Rwloadsim does not include advanced output formatting, strings are
19+
The writeline and printline commands of rwloadsim do not include
20+
advanced output formatting, strings are
2321
output as is and integers or doubles are output using a predefined
2422
printf format of %d and %.2f respectively; these can be changed at
2523
compile time using directives.
24+
To get output formatting, use fprintf.
2625

2726
This simple example
2827
```
2928
file hello;
30-
hello := "hello.txt";
29+
hello >= "hello.txt";
3130
writeline hello, "Hello, World";
3231
hello := null;
3332
```
@@ -38,7 +37,7 @@ A simple example of reading from a pipeline is:
3837
file id;
3938
string(1000) myid;
4039
41-
id := "id|";
40+
id =| "id";
4241
readline id,myid;
4342
id := null;
4443
@@ -70,8 +69,8 @@ double a, b;
7069
7170
file yt;
7271
73-
# The initial > is optional here as the default is to open for writing
74-
yt:=">numbers.txt";
72+
# You could also use the := operator
73+
yt >= "numbers.txt";
7574
7675
# write number from 1 until 10 and their
7776
# squares to the file numbers.txt
@@ -82,7 +81,7 @@ end loop;
8281
yt := null; # close the file
8382
8483
# use a pipeline to read the file
85-
yt := "cat numbers.txt|";
84+
yt =| "cat numbers.txt";
8685
8786
for readline yt,a,b loop # similar to read a,b in the shell
8887
printline a,b,sqrt(b);

docs/NEWS30.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## Changed behavior in version 3.0.3 of the RWP\*Load Simulator
2+
3+
The syntax for opening files and pipelines has been enhanced with
4+
new operators: >=, >>=, <=, |= and =|.
5+
These replace the previous behavior where the contents of the
6+
concatenation being assigned to a file would be interpreted to
7+
imply open for read, append, or as a pipeline respectively.
8+
This has a security concern and is deprecated, it will
9+
be desupported in an upcoming 3.1 release.
10+
You can enable warnings when using the current approach via
11+
the $pre31fileassign:warn directive, and it is suggested
12+
you put this directive in your .rwloadsim.rwl startup file.
13+
114
## Changed behavior in version 3.0.1 of the RWP\*Load Simulator
215

316
### Keywords initiating SQL

docs/refman/directive.html

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/refman/filestatement.html

Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/refman/statement.html

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/man1rwl/directive.1rwl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,25 @@ Be default, the flag OCI_SPC_NO_RLB is set, to not set this flag, use the second
349349
directive before the database using a session pool is declared.
350350
.RE
351351
.P
352+
.B $pre31fileassign:on
353+
.br
354+
.B $pre31fileassign:warn
355+
.br
356+
.B $pre31fileassign:off
357+
.RS 4
358+
These directives control how file assignment using the \fB:=\fR operator behave.
359+
When the directive is set to \fBon\fR, you can use re-direction characters
360+
such as "<", ">>", "|" as part of the name of the file causing the file to
361+
be opened for read, append or as a pipeline.
362+
When set to \fBwarn\fR, you will get a runtime warning about such use,
363+
and if set to \fBoff\fR, you will get a runtime error.
364+
In the current release (3.0.3), the default is \fBoff\fR; it will be set
365+
to \fBon\fR in release 3.1.
366+
.P
367+
It is recommended that you run your rwloadsim with \fBwarn\fR and use the
368+
generated warnings to modify your code to use the newer file assignment operators.
369+
.RE
370+
.P
352371
.B $useroption:name
353372
.br
354373
.B $userswitch:name
@@ -369,4 +388,4 @@ Licensed under the Universal Permissive License v 1.0
369388
as shown at https://oss.oracle.com/licenses/upl
370389
.SH "SEE ALSO"
371390
rwloadsim(1rwl), useroption(1rwl), longoption(1rwl), include(1rwl),
372-
conditional(1rwl), sqldeclaration(1rwl), printfstatement(1rwl)
391+
conditional(1rwl), sqldeclaration(1rwl), printfstatement(1rwl), filestatement(1rwl)

0 commit comments

Comments
 (0)